* Menu
[[About:self:AboutPage.txt]] | [[Profile:file/southly/]] | [[まとめ:self:1163859357.txt]] | [[オリジナル:http://ninjinix.x0.com/rn/]] | [[xyzzy:lisp/]] | [[あんてな:listall]] | [[■:lisp]] | [[buzz:files/southly#buzz]]
- xyzzy lisp : format ~&
- xyzzy lisp : format ~{
- xyzzy lisp : format ~(
- xyzzy lisp : format ~?
- 2006-09-20
- memo : iterationで最後だけ出力しない
- xyzzy lisp : へなちょこ補完その3
- xyzzy lisp : なんとなく
- xyzzy lisp : 位置とサイズの操作
- xyzzy lisp : format ~*
- xyzzy lisp : format ~T
- xyzzy lisp : format ~\n(改行)
- xyzzy lisp : format ~|
- xyzzy lisp : format ~~
- Scrapbook : format関数
* xyzzy lisp : format ~&
- 現在の桁が0になるように改行を出力(すでに0ならなにもしない)
- パラメータは最大1つ
- Nが与えられたら通常の動作1回、その後 (N-1) 個の改行を出力
(format nil "~&") ; 何もしない "" (format nil "xyzzy~&") ; 改行を出力 "xyzzy " (format nil "~2&") ; 何もしない + 1つ改行を出力 " " (format nil "xyzzy~3&") ; 改行を出力 + 2つ改行を出力 "xyzzy "
* xyzzy lisp : format ~{
- 繰り返し出力
- ~} で範囲を終了
- ~:} で範囲の終了を示したときは必ず1回は繰り返しを実行
- "{" リストを引数にとる
- ":{" リストを引数にとり、かつ繰り返し1回に1つのリストを消費
- "@{" 元のformatの引数をそのまま消費
- ":@{" 元のformatの引数をそのまま消費、かつ繰り返し1回に1つのリストを消費
- パラメータは1つ
- 繰り返し回数の上限
(format nil "~{~A ~}" '(a b c d)) "a b c d " (format nil "~:{~A ~}" '((a) (b) (c) (d))) "a b c d " (format nil "~@{~A ~}" 'a 'b 'c 'd) "a b c d " (format nil "~:@{~A ~}" '(a) '(b) '(c) '(d)) "a b c d " (format nil "~2{~A ~}" '(a b c d)) "a b " (format nil "~{~A ~}" nil) "" (format nil "~{~A ~:}" '(a)) ; nilが引数だとエラー "a " ; "~^"と一緒に使うのが便利 (format nil "~{~A~^, ~}~%" '(one two three four)) ; 最後に", "はいらない "one, two, three, four "
* xyzzy lisp : format ~(
- 大文字・小文字の変換をして出力
- ~) で範囲を終了
- "~(" すべて小文字
- "~:(" 単語の先頭の一文字のみ大文字で後は小文字
- "~@(" 先頭の一文字のみ大文字で後は小文字
- "~:@(" すべて大文字
- パラメータは無し
(format nil "~(~A fUga~)" "hoGe") "hoge fuga" (format nil "~:(~A fUga~)" "hoGe") "Hoge Fuga" (format nil "~@(~A fUga~)" "hoGe") "Hoge fuga" (format nil "~:@(~A fUga~)" "hoGe") "HOGE FUGA"
* xyzzy lisp : format ~?
(format nil "~D, ~?" 10 "[~A ~D]" '(hoge 30)) "10, [hoge 30]" (format nil "~D, ~@?" 10 "[~A ~D]" 'hoge 30) "10, [hoge 30]"
* 2006-09-20
で、移植の手順。
1. [[Emacs lisp 移植キット:xyzzy.html]]を使えるようにする。
2. 使えないもの(defgroup, font-lock関係, フレーム関係, etc)をコメントアウト
3. 文字の表現を書き直し(?a → #\a) 特に#\SPCとか
4. キーバインドの記述を書き直し(文字列 → 文字 or cons)
5. formatの引数を直す
6. 無い関数を記述 & 無い変数を代替の関数へ
7. 位置の調整(xyzzyは0 origin, emacsは1 origin)
8. functionとsymbol
9. その他こまごまとした修正
1. [[Emacs lisp 移植キット:xyzzy.html]]を使えるようにする。
2. 使えないもの(defgroup, font-lock関係, フレーム関係, etc)をコメントアウト
3. 文字の表現を書き直し(?a → #\a) 特に#\SPCとか
4. キーバインドの記述を書き直し(文字列 → 文字 or cons)
5. formatの引数を直す
6. 無い関数を記述 & 無い変数を代替の関数へ
7. 位置の調整(xyzzyは0 origin, emacsは1 origin)
8. functionとsymbol
9. その他こまごまとした修正
* memo : iterationで最後だけ出力しない
(format nil "~{~A~^ ~}" '(a b c)) =>"a b c"
* xyzzy lisp : へなちょこ補完その3
* xyzzy lisp : なんとなく
(defun sort-by-column-region (beg end &optional (f #'<)) (interactive "*r") (let ((lines (split-string (buffer-substring beg end) #\LFD t)) (pred #'(lambda (x y) (funcall f (length x) (length y))))) (setq lines (sort lines pred)) (goto-char (min beg end)) (delete-region beg end) (insert (format nil "~{~A~%~}" lines))))
* xyzzy lisp : 位置とサイズの操作
* xyzzy lisp : format ~*
- 引数の参照を操作
- "~*" 相対位置正方向(スキップする)
- "~:*" 相対位置負方向(バックする)
- "~@*" 絶対位置(0〜)
- パラメータは最大1つ
- 位置
(format nil "~A ~A ~*~A ~A ~A" 'a 'b 'c 'd 'e 'f) "a b d e f" (format nil "~A ~A ~2*~A ~A" 'a 'b 'c 'd 'e 'f) "a b e f" (format nil "~A ~A ~A ~2:*~A ~A ~A ~A" 'a 'b 'c 'd 'e 'f) "a b c b c d e" (format nil "~A ~A ~4@*~A ~A" 'a 'b 'c 'd 'e 'f) "a b e f"