はじめてのanything-c-source-*
TRANSCRIPT
はじめてのanything-c-source-*
Kenichirou Oyama(k1LoW@fukuoka-emacs)
-uuu:---F1 tokyo-emacs #x02 2009.9.6 All(1.0) (Emacs-Lisp ppt)---- 2
• type:– Programmer
• Emacs Lisp– http://emacswiki.org/k1LoW
• Membership:– fukuoka-emacs– Fusic Co.,Ltd >> http://fusic.co.jp
– codecheck.in >> http://trac.codecheck.in
and 101000code / 3rdSTONE
(self-intoroduce 'k1LoW)
-uuu:---F1 tokyo-emacs #x02 2009.9.6 All(1.0) (Emacs-Lisp ppt)---- 3
-uuu:---F1 tokyo-emacs #x02 2009.9.6 All(1.0) (Emacs-Lisp ppt)---- 4
ここ数年で発生し蔓延している感染症があります
-uuu:---F1 tokyo-emacs #x02 2009.9.6 All(1.0) (Emacs-Lisp ppt)---- 5
この中の人にも何人かいるかと思います
-uuu:---F1 tokyo-emacs #x02 2009.9.6 All(1.0) (Emacs-Lisp ppt)---- 6
感染源
-uuu:---F1 tokyo-emacs #x02 2009.9.6 All(1.0) (Emacs-Lisp ppt)---- 7
id:rubikitch
-uuu:---F1 tokyo-emacs #x02 2009.9.6 All(1.0) (Emacs-Lisp ppt)---- 8
病名
-uuu:---F1 tokyo-emacs #x02 2009.9.6 All(1.0) (Emacs-Lisp ppt)---- 9
anything脳
-uuu:---F1 tokyo-emacs #x02 2009.9.6 All(1.0) (Emacs-Lisp ppt)---- 10
• Emacs Lispの候補選択フレームワークであるanything.elの操作性に慣れきってしまい、なんでもかんでも「完全一致」、「部分一致+AND検索」、「正規表現」、「migemo」で絞り込み検索ができないのか考えてしまう中毒症状。
• Emacs環境以外でのプログラム生活で支障をきたし、「Emacsキーバインド以来の中毒性が見られる」と提言する専門家も。
• anything.elのメンテナであるid:rubikitchもanything脳であることが本人の告白により明らかになっている。
症状
-uuu:---F1 tokyo-emacs #x02 2009.9.6 All(1.0) (Emacs-Lisp ppt)---- 11
みなさん注意喚起をお願いします!!
-uuu:---F1 tokyo-emacs #x02 2009.9.6 All(1.0) (Emacs-Lisp ppt)---- 12
さて
-uuu:---F1 tokyo-emacs #x02 2009.9.6 All(1.0) (Emacs-Lisp ppt)---- 13
はじめてのanything-c-source-*
-uuu:---F1 tokyo-emacs #x02 2009.9.6 All(1.0) (Emacs-Lisp ppt)---- 14
anything-c-source-*• anything.elの選択候補となるコード• anything.elはanything-c-source-*を選
択候補させるフレームワーク– anything.elはanything-c-
source-*がないとはじまらない
-uuu:---F1 tokyo-emacs #x02 2009.9.6 All(1.0) (Emacs-Lisp ppt)---- 15
anything-c-source-*....?
-uuu:---F1 tokyo-emacs #x2009.9.6 02 All(1.0) (Emacs-Lisp ppt)---- 16
• `anything-c-source-complex-command-history' (Complex Command History)
• `anything-c-source-extended-command-history' (Emacs Commands History)
• `anything-c-source-emacs-commands' (Emacs Commands)
• `anything-c-source-lacarte' (Lacarte)
• `anything-c-source-emacs-functions' (Emacs Functions)
• `anything-c-source-emacs-functions-with-abbrevs' (Emacs Functions)
• `anything-c-source-emacs-variables' (Emacs Variables)
• `anything-c-source-bookmarks' (Bookmarks)
• `anything-c-source-bookmark-set' (Set Bookmark)
• `anything-c-source-bookmarks-ssh' (Bookmarks-ssh)
• `anything-c-source-bookmarks-su' (Bookmarks-root)
• `anything-c-source-bookmarks-local' (Bookmarks-Local)
• `anything-c-source-w3m-bookmarks' (W3m Bookmarks)
• `anything-c-source-elisp-library-scan' (Elisp libraries (Scan))
• `anything-c-source-imenu' (Imenu)
anything-config.el
-uuu:---F1 tokyo-emacs #x02 2009.9.6 All(1.0) (Emacs-Lisp ppt)---- 17
anything-config.el• `anything-c-source-ctags' (Exuberant ctags)
• `anything-c-source-semantic' (Semantic Tags)
• `anything-c-source-simple-call-tree-functions-callers' (Function is called by)
• `anything-c-source-simple-call-tree-callers-functions' (Function calls)
• `anything-c-source-commands-and-options-in-file' (Commands/Options in file)
• `anything-c-source-customize-face' (Customize Face)
• `anything-c-source-colors' (Colors)
• `anything-c-source-tracker-search' (Tracker Search)
• `anything-c-source-mac-spotlight' (mdfind)
• `anything-c-source-icicle-region' (Icicle Regions)
• `anything-c-source-kill-ring' (Kill Ring)
• `anything-c-source-mark-ring' (mark-ring)
• `anything-c-source-global-mark-ring' (global-mark-ring)
• `anything-c-source-register' (Registers)
• `anything-c-source-fixme' (TODO/FIXME/DRY comments)
-uuu:---F1 tokyo-emacs #x02 2009.9.6 All(1.0) (Emacs-Lisp ppt)---- 18
anything-config.el• `anything-c-source-rd-headline' (RD HeadLine)
• `anything-c-source-oddmuse-headline' (Oddmuse HeadLine)
• `anything-c-source-emacs-source-defun' (Emacs Source DEFUN)
• `anything-c-source-emacs-lisp-expectations' (Emacs Lisp Expectations)
• `anything-c-source-emacs-lisp-toplevels' (Emacs Lisp Toplevel / Level 4 Comment / Linkd Star)
• `anything-c-source-org-headline' (Org HeadLine)
• `anything-c-source-yaoddmuse-emacswiki-edit-or-view' (Yaoddmuse Edit or View (EmacsWiki))
• `anything-c-source-yaoddmuse-emacswiki-post-library' (Yaoddmuse Post library (EmacsWiki))
• `anything-c-source-eev-anchor' (Anchors)
• `anything-c-source-picklist' (Picklist)
• `anything-c-source-bbdb' (BBDB)
• `anything-c-source-evaluation-result' (Evaluation Result)
• `anything-c-source-calculation-result' (Calculation Result)
-uuu:---F1 tokyo-emacs #x02 2009.9.6 All(1.0) (Emacs-Lisp ppt)---- 19
anything-config.el• `anything-c-source-google-suggest' (Google Suggest)
• `anything-c-source-surfraw' (Surfraw)
• `anything-c-source-emms-streams' (Emms Streams)
• `anything-c-source-emms-dired' (Music Directory)
• `anything-c-source-jabber-contacts' (Jabber Contacts)
• `anything-c-source-call-source' (Call anything source)
• `anything-c-source-occur' (Occur)
• `anything-c-source-create' (Create)
• `anything-c-source-minibuffer-history' (Minibuffer History)
• `anything-c-source-elscreen' (Elscreen)
• `anything-c-source-xrandr-change-resolution' (Change Resolution)
• `anything-c-source-xfonts' (X Fonts)
• `anything-c-source-gentoo' (Portage sources)
• `anything-c-source-use-flags' (Use Flags)
• `anything-c-source-emacs-process' (Emacs Process)
-uuu:---F1 tokyo-emacs #x02 2009.9.6 All(1.0) (Emacs-Lisp ppt)---- 20
anything-function• anything()を利用して独自の関数を作成• anything-c-source-*をリストするだけでも
OK(defun my-anything-find-file () "My `anything'." (interactive) (anything (list anything-c-source-buffers anything-c-source-files-in-current-dir anything-c-source-file-name-history) initial-pattern "Find File: " nil))
-uuu:---F1 tokyo-emacs #x02 2009.9.6 All(1.0) (Emacs-Lisp ppt)---- 21
anything-function• anything()を利用して独自の関数を作成• anything-c-source-*をリストするだけでも
OK(defun my-anything-find-file () "My `anything'." (interactive) (anything (list anything-c-source-buffers anything-c-source-files-in-current-dir anything-c-source-file-name-history) initial-pattern "Find File: " nil))
-uuu:---F1 tokyo-emacs #x02 2009.9.6 All(1.0) (Emacs-Lisp ppt)---- 22
anything-function• anything()を利用して独自の関数を作成• anything-c-source-*をリストするだけでも
OK(defun my-anything-find-file () "My `anything'." (interactive) (anything (list anything-c-source-buffers anything-c-source-files-in-current-dir anything-c-source-file-name-history) initial-pattern "Find File: " nil))
-uuu:---F1 tokyo-emacs #x02 2009.9.6 All(1.0) (Emacs-Lisp ppt)---- 23
anything()の引数• ANY-SOURCES
– anything-c-source-*リスト
• ANY-INPUT– anything()に渡す初期入力
• ANY-PROMPT– mini-bufferに出るプロンプト文字列
• ANY-RESUME– anything()実行する際に初期かするか
• ANY-PRESELECT– anything()実行時に選択する文字列
• ANY-BUFFER– anything()実行時に使用するバッファ
-uuu:---F1 tokyo-emacs #x02 2009.9.6 All(1.0) (Emacs-Lisp ppt)---- 24
anything()の引数• ANY-SOURCES
– anything-c-source-*リスト
• ANY-INPUT– anything()に渡す初期入力
• ANY-PROMPT– mini-bufferに出るプロンプト文字列
• ANY-RESUME– anything()実行する際に初期かするか
• ANY-PRESELECT– anything()実行時に選択する文字列
• ANY-BUFFER– anything()実行時に使用するバッファ
-uuu:---F1 tokyo-emacs #x02 2009.9.6 All(1.0) (Emacs-Lisp ppt)---- 25
簡単anything-c-source
-uuu:---F1 tokyo-emacs #x02 2009.9.6 All(1.0) (Emacs-Lisp ppt)---- 26
anything-c-source-*の設定(自分が使ったことあるものだけ)
• Init– 初期処理
• name– anytnig-c-sourceの名前(呼び出されたときに名前がつ
く)
• candidates– 候補リスト
• (candidate-in-buffer)– candidatesをbufferで作ったとき設定する
• action– 選択した候補から渡される値をもとに実行する関数
-uuu:---F1 tokyo-emacs #x02 2009.9.6 All(1.0) (Emacs-Lisp ppt)---- 27
anything-c-source-*の設定(自分が使ったことあるものだけ)
• display-to-real– candidatesから選択した候補を調整してactionに渡す
replace関数• type
– 候補リストのタイプ。設定するとデフォルトactionが設定される
まだ多くあるけれども、使ったことないので省略(いろいろ教えてください!)
-uuu:---F1 tokyo-emacs #x02 2009.9.6 All(1.0) (Emacs-Lisp ppt)---- 28
/tmpディレクトリのファイルを開くanything-c-source
• nameとcandidatesとtypeだけで作成できる
-uuu:---F1 tokyo-emacs #x02 2009.9.6 All(1.0) (Emacs-Lisp ppt)---- 29
STEP1
(defvar anything-c-source-tmp-dir
'())
• anything-c-sourceの変数を作成– 変数名はanything-c-source-
tmp-dir
-uuu:---F1 tokyo-emacs #x02 2009.9.6 All(1.0) (Emacs-Lisp ppt)---- 30
STEP2
(defvar anything-c-source-tmp-dir
'((name . "Tmp dir")
)
• nameを決定– “Tmp dir”
-uuu:---F1 tokyo-emacs #x02 2009.9.6 All(1.0) (Emacs-Lisp ppt)---- 31
STEP3
(defvar anything-c-source-tmp-dir
'((name . "Tmp dir")
(type . file)))
• typeを決定– ファイルなのでfile
-uuu:---F1 tokyo-emacs #x02 2009.9.6 All(1.0) (Emacs-Lisp ppt)---- 32
STEP4
(defvar anything-c-source-tmp-dir
'((name . "Tmp dir")
(candidates . (lambda () (directory-files "/tmp")))
(type . file)))
• candidatesを作成– /tmp内のファイルをリストで
返す関数をセット
-uuu:---F1 tokyo-emacs #x02 2009.9.6 All(1.0) (Emacs-Lisp ppt)---- 33
anything-c-source-tmp-dir完成!
-uuu:---F1 tokyo-emacs #x02 2009.9.6 All(1.0) (Emacs-Lisp ppt)---- 34
STEP5• anything-c-source-tmp-dirを
my-anything-find-fileに追加(defun my-anything-find-file () "My `anything'." (interactive) (anything (list anything-c-source-buffers anything-c-source-files-in-current-dir anything-c-source-file-name-history anything-c-source-tmp-dir) initial-pattern "Find File: " nil))
-uuu:---F1 tokyo-emacs #x02 2009.9.6 All(1.0) (Emacs-Lisp ppt)---- 35
簡単!
-uuu:---F1 tokyo-emacs #x02 2009.9.6 All(1.0) (Emacs-Lisp ppt)---- 36
まとめ
• anything-c-source-*を作成するのは簡単!
• より高度なことをしたいときは、同じようなことをしているanything-c-source-*をみてみればOK
-uuu:---F1 tokyo-emacs #x02 2009.9.6 All(1.0) (Emacs-Lisp ppt)---- 37
伝言
-uuu:---F1 tokyo-emacs #x02 2009.9.6 All(1.0) (Emacs-Lisp ppt)---- 38
skype.elがEmacs22系でも動くようになりました。NTEmacsなどでも動きます。
id:kiwanami
-uuu:---F1 tokyo-emacs #x02 2009.9.6 All(1.0) (Emacs-Lisp ppt)---- 39
近々codecheck.inにコミットします
id:kiwanami
-uuu:---F1 tokyo-emacs #x2009.9.6 02 All(1.0) (Emacs-Lisp ppt)---- 40
id:IMAKADO君、デバッグよろしく
id:kiwanami