PREFERENCE


"メイリオ" hash dictionary


文字列(string)





delete-char


SYNTAX (delete-char NUMBER) DESC Cursor 直後の N 文字を削除


following-char


SYNTAX (following-char) DESC Cursor 位置の 文字を Code 値として返す


mapcar


SYNTAX (mapcar FUNC SEQUENCE) DESC SEQUENCE の各要素に FUNC をあてる
;; (3 5 7) (mapcar '1+ '(2 4 6))



boundp


SYNTAX (boundp SYMBOL) DESC Symbol の値が void でないかどうかかえす
;; symbol "foobar" が 定義されているかどうかしらべる (if (boundp 'foobar) (message "foobar is not void") (message "foobar is void") )



zerop


SYNTAX (zerop NUMBER) DESC 引数が 0 かどうかかえす


insert-rectangle


insert-rectangle '("aaa" "bbb" "ccc")) SYNTAX (insert-rectangle list ;; string list ) DESC 現在のポイント位置に list の文字列を矩形に挿入する
(insert-rectangle '("aaa" "bbb" "ccc"))



make-string


SYNTAX (make-string NUMBER)
;; RET: "aaa" (make-string 3 ?a)



int-to-string


SYNTAX (int-to-string NUMBER) DESC 数値から文字列変換 (number-to-string) の別名


文字列(string)





string-match


SYNTAX (string-match "n" "tanuki") DESC
(looking-at "tanuki")



string-match


SYNTAX (string-match "regexp" "string") DESC regexp 検索


file-name-nondirectory


SYNTAX (file-name-nondirectory) DESC Directory 名削除


Buffer





buffer-string


SYNTAX (buffer-string) DESC buffer 全体文字列を返す


buffer-file-name


SYNTAX (buffer-file-name) DESC buffer名


pop-to-buffer


SYNTAX pop-to-buffer DESC 新しい window に buf 生成
(pop-to-buffer "foo")



検索(Search)





re-search-forward


SYNTAX (re-search-forward REGEXP &opt BOUND NOERROR COUNT) DESC REGEXP にマッチした文字の直後に point を移動
;; abc の後ろに移動 (re-search-forward "abc") ;; tab 検索 (re-search-forward "\t") ;; ERROR ;; "\\t" ではない -> "\t" という REGEXP はなし -> だから "t" を検索 (re-search-forward "\\t") ;; MultiByte 文字も 文字クラスに指定できる (re-search-forward "[あい]") ;; あい ;; c の直後( "d" )に point が移動 abcd WARNING 現在の point の文字も検索対象になる (re-search-forward "a") ;; [] abca ;; 末尾の a に移動するつもりだが, b に移動してしまう



re-search-backward


SYNTAX (re-search-backward REGEXP &opt BOUND NOERROR COUNT) DESC REGEXP にマッチした文字の先頭に point を移動
;; a に point が移動 abc (re-search-backward "abc")



buffer-substring


SYNTAX (buffer-substring s e) DESC point 位置 s 以上 , e 未満の Buffer 文字列をかえす
abcdefghijk ;; RET: abcde (buffer-substring 1 6)



file-name-directory . dirname


SYNTAX (file-name-directory path) DESC パスから Directory 部分をかえす
;; d:/ (file-name-directory "d:/foo.txt") (file-name-directory "d:/bar/")



(directory-files "/log") getFileList


(directory-files "/log")



switch-to-buffer


SYNTAX DESC EX WARNING


file-name-extension . extname


(file-name-extension) txt
(file-name-extension "d:/foo/bar.txt")
DESC Query SYNTAX (y-or-n-p "string") DESC 文字列の長さを取得. SYNTAX (length "string") DESC 文字列結合 SYNTAX (concat "string" ...) DESC 文字列比較 SYNTAX (string-equal "str1" "str2") ret t | nil DESC 部分文字列 SYNTAX (substring "str" idxS, idxE ) TIP idxE = -n で 最後の n 文字削除 DESC file 読み込み(存在)確認 SYNTAX (file-readable-p "file") DESC file 挿入 SYNTAX (insert-file "file") DESC buf の名前( file full path をかえす ) SYNTAX (buffer-file-name) ret d:/foo/bar/foo.cpp DESC 現在時刻をかえす


insert-word . insert


(insert "aaa")



にほんご





current-word


カーソル位置の単語を返す
(current-word)



current-time-string


SYNTAX (current-time-string) DESC 現在時刻 DESC 指定 regexp を含むかcheck


string-match


SYNTAX (string-match "regexp" name) DESC buf の編集状態を終了させる.


set-buffer-modified-p


SYNTAX (set-buffer-modified-p nil) DESC 任意の数のリスト引数を連結する


list





append


SYNTAX (append list...)
;; ~/mylisp を load-path に追加 (append load-path (list "~/mylisp"))



cons


SYNTAX (cons atom ...) (cons CAR CDR) DESC リストの先頭に要素を追加する Constructure RET 作成した list
;; list 構造に便利 (cons "~/mylisp" load-path) (cons 1 (list 2 3 4 5)) ;; PUSH (setq calc-stack (cons x calc-stack)) ;; POP (setq calc-stack (cdr calc-stack))



defcustom


SYNTAX (defcustom SYMBOL VALUE DOC &rest ARGS) DESC カスタム可能な Symbol を定義. ( Default 値つき ) Declare SYMBOL as a customizable variable that defaults to VALUE. DOC is the variable documentation.
(defcustom perl-indent-level 2 "*Indentation of Perl statements with respect to containing block." :type 'integer :group 'perl) :type VALUE should be a widget type for editing the symbols value. :options VALUE should be a list of valid members of the widget type. :group VALUE should be a customization group.



where-is-internal


SYNTAX (where-is-internal cmd) DESC cmd に bind されている Key list をかえす. ある cmd の keybind を変更する際に便利


read


SYNTAX (read tkn) DESC token を symbol に変換


set-buffer


SYNTAX DESC 編集に利用する buf を指定 LISP code のみ有効 WARNING (getenv "USER")


defun


DESC 関数を定義する関数 ret 関数名


let


DESC 変数の宣言. セット 2. Block の定義 SYNTAX (let ((var1 value1)...) state-block) TIP 変数宣言しない(setq) は global


save-excursion


DESC cursor 位置を保存


condition


DESC 条件文 SYNTAX (while condition state-block) (following-char)aaa (delete-char 1) TIP c-g : 中止


message


DESC min buf に出力 書式命令: %s %d %c %e %f %g


lisp関数をemacsCommand.にする


Lisp Interaction Mode : c-j : eval-print-last-sexp 登録する (interactive "prompt-string") arg を関数にわたす. prompt-string: arg に格納される n : 整数 s : 文字列 \n: argument 区切り文字 "document" : c-h f で表記 TIP * (interactive "r") : 引数を point , mark にセット


argument . 引数


(defun wwi( word path ) "desc" (interactive "sWordPub :\nsPath : " ) (message (concat word path)) )



lisp基本関数


DESC 算術 [ +-*/ % 1+ 1- max min ] : arg が浮動小数点ならば float 扱い 比較 [ > < >= <= /= = equal] 論理 [ and not or ]


ERROR


Q. symbols value as variable is void // 空 A. 変数を初期化しないとでる ERR.


制御構文





if


SYNTAX (if cond true-case false-block) TIP true-case : 単文 false-blcok: 複文


cond(while)


SYNTAX (cond (cond1 state-block) (cond2 state-block) ... ) TIP switch ( foo ) { case: .. } と思おう.
(defun howmany (cnt) (cond // zero p( 述語 ) == arg に基づいて t, nil をかえす ((zerop cnt) "no") ((= cnt 1) "one") ((= cnt 2) "two") (t "many") ) )



複文


SYNTAX (progn state-block) DESC {} {} ( Block と考えるとわかりやすい ) (let (var1 var2 ...) state-block)
(let (foo (coo 10) bar) (message "foo %s bar %s %d" foo bar coo)) nil に初期化
(defun goto-pct (pct) (interactive "nGoto percent: ") (goto-char (/ (* (point-max) pct) 100)) ) (defun pluralize (word cnt &optional plural) (if (= cnt 1) word (if (null plural) (concat word "s") plural ) ) ) (defun count-words-buffer (nr num) ("this is my first lisp function ") (interactive "nEnter integer: \nnEnter Second: ") (let ((cnt 0)) (save-excursion (goto-char (point-min)) ; top (while (< (point) (point-max)) (forward-word 1) (setq cnt (1+ cnt)) ) (message "buf contanis %d word arg %d arg %d" cnt nr num) ) ) ) (let () (if (equal (getenv "USER") "usr") (setq width 10)(setq width 20)) (message "width %d" width) )


便利な組み込み関数


// 文字位置 point // mark 位置 (mark) // 最小文字位置 point-min // 行頭にあるか // b of line ? bolp // 行末にあるか eolp : bobp : buf 先頭 eobp : buf 先頭 (insert) : point に挿入 number-to-string: 10 -> "10" string-to-number: "100" -> 100 char-to-string: substring: (substring "this is a pen" 0 4) aref: 配列参照 (aref "test" 3)


REGEXP


DESC emacs での 正規表現です // [a-c] の文字 [a-c] $ | ' : 行末 WARNING regexp 文字を指定するには [\\] 2個必要 Emacs Interpreter が解釈するため
* にマッチするには \\* ;; Lisp interpriter が \\ -> \ として解釈 [\*] を lisp 関数にわたす (search-forward-regexp "foobar\\*") -> [foobar*]
WARNING: 上記の仕様は regexp の関数のみ意味をもつことを忘れないこと (search-forward "test*test") // 通常文字の "test*test"検索 実験するなら次を利用する (search-forward-regexp) (replace-regexp)


LIST


DESC quot して meta chara 扱い
[()|]
* quot しないで meta chara 扱い
[+*.]
* : 直前の文字の 0 回以上の繰り返し + : 直前の文字の 1 回以上の繰り返し : 任意の文字 [] : 文字セット [^] REGEXP [ : NRML \\[ -> [*?.] // 通常文字あつかい () : group REGEXP \( :: NRML ( | : 選択 REGEXP \| :: NRML | ^$<>: 文脈指定 ( 日本語でも Token の指定できる ) \w : 単語を構成する文字 \w : 単語を構成しない文字 \b : 単語の境界 単語境界
VAR::sentence-end regexp の参考になる (defun del-header-outline () "this is rm *" (interactive) (replace-regexp "^\\*+" "") ) \\* == アスタリスク
[^A-z] (replace-regexp "^aaaa\nbbbb" "") // 改行こみ