yasnippet ã emacs lisp ã®å°ãã¿ãªã©
yasnippet ã¯å®åã³ã¼ããªã©ãç´ æ©ãå±éãããã¨ãåºæ¥ãæ±ç¨ãã³ãã¬ã¼ããã¬ã¼ã ã¯ã¼ã¯ã§ãã
æ®éã®ä½¿ãæ¹
yasnippetã®ããã¥ã¡ã³ãã¯æ¬å®¶ã®ãã¼ã¸ã«è¯ãã¾ã¨ã¾ã£ã¦ãã¾ããelispæ¸ãã人ã¯å ¨é¨èªãã¨ããªãsnippetåãä¸ããã¨æãã¾ãã®ã§ããã²èªãã§ã¿ããããã¨æãã¾ãã
- http://yasnippet-doc-jp.googlecode.com/svn/trunk/doc-jp/index.html (2011/09/15 追è¨)
ãã¨ã以ä¸ã®ãã¼ã¸ã§ãã¿ããªãã³ã·ã§ã³é«ããªã£ã¦ã¾ããï¼ãã3å¹´ãããåã®ç¥ãã§ãããããï¼
- yasnippetがすごい!!!!1112345! - Kentaro Kuribayashi's blog
- yasnippet.elをインストールしてみた
- yasnippet, anything-c-yasnippetのまとめエントリー - IMAKADO::BLOG
åºæ¬çã«ãããããã¾snippetã²ããããï¼ãã¨æã£ãç¬éã«ã M-x yas/new-snippet ã§æ°è¦ã¹ããããç»é²ãããã¡ãéãã¦ã C-c ã§ä¿åã»ç»é²ãè¾¼ã¿å ¥ã£ããã®ã ã¨ä½åº¦ããã¹ãã¨æ¸ãæããããã¨æãã¾ãã
以åæ¸ããã¹ããããã®ä¿®æ£ã¯ M-x yas/visit-snippet-file ï¼ä»ãããããã¡ã®ã¹ããããããé¸ã¶ï¼ããã㯠M-x yas/find-snippets ï¼ã¹ããããã®ãã£ã¬ã¯ããªããæ¢ãï¼ã§åºæ¥ã¾ãã
ã¡ãªã¿ã«ãyasnippetã¨zencodingãåãããã¨å±éãã¬ãã¥ã¼ãè£å®ãå¹ãã¾ãã£ã¦HTMLãããããæ¸ããããã«ãªãããã§ãã®ã§ããããã§ãã
çµã¿åãããå¹²æ¸ãªã©
yasnippetã大éã«ããã¨è¦ããããªããªãã®ã§ãanythingã§çµãè¾¼ãã¨ããæ¹æ³ãããã¾ãã以ä¸ã®ãã¼ã¸ãåèã«ãªãã¨æãã¾ãããã¡ãã¯snippetãé¸ã¶ã ãã§ãªããæ°è¦è¿½å ãªã©ã®ã¢ã¯ã·ã§ã³ãããã¾ãã
auto-completeã®ã½ã¼ã¹ã«ãã¦ãã¾ã£ã¦ãæã£ã端ãããã«ãã¦ã³ã§è¦ããã¨ããæ¹æ³ãããã¾ããauto-completeã«æ¨æºã§å«ã¾ãã¦ãã¾ãã®ã§ã ac-source ã« ac-source-yasnippet ãå ¥ã£ã¦ããã°ä½¿ãã¾ãã auto-complete-config.el ã確èªãã¦ã¿ã¦ãã ããã
yasnippetã¨å¹²æ¸ãããã®ãããã¤ãããã¾ãã
flymakeã¨ã®å¹²æ¸ã«ã¤ãã¦ã¯ antipopããã®è¨äº yasnippet関連の設定 - Kentaro Kuribayashi's blog ã«è¨å®ä¾ãããã¾ãã
auto-complete ãå±éä¸ã«ç¡å¹ã«ããè¨å®ã以ä¸ã®gistã«æ¸ãã¦ã¿ã¾ããã
åºæ¬çã« yas/before-expand-snippet-hook 㨠yas/after-exit-snippet-hook ã®hookã§ä»ã®æ©è½ãä¸æåæ¢ãããåéãããã¨è¯ãã¨æãã¾ãã
èªåsnippets
ããã©ã«ãã§ã¯ããã¤ããã³ãã¬ã¼ããããã¾ããããªããªã人ã®ä½ã£ãç縮ã³ã¼ãã¯è¦ããããªããã®ã§ãããªã®ã§æåããç¨æããã¦ãããã³ãã¬ã¼ãã¯åèç¨åº¦ã«ãã¦ããã¦ãèªåã§ç»é²ãã¦ãã£ã¦å¢ããã¦ããã®ãè¯ãã®ã§ã¯ãªããã¨æãã¾ãã
èªåã¯ããã¾ãæ°ã¯å¤ããªãã§ããä¾ãã°elispã¯ä»¥ä¸ãç»é²ãã¦ãã¾ãã
å±éå | å±éå | |
---|---|---|
defvar | da | (defvar |
internal | ã³ã¡ã³ã㧠int | [internal] |
let | let | (let (( |
defun | df | (defun |
interactive | éã³ã¡ã³ã㧠int | (interactive) |
lambda | la | (lambda () ) |
lexical-let | ll | (lexical-let (( |
let ãã(let ((ãã«ãªãã ãã§ãããªãéãã¾ããã¡ãªã¿ã«ãããã¯imakadoåã«æãã¦ãããã¾ããã
ä¸ã®ä¾ã§ã¯æåãå ¥ãã ãã§ã¯ãªãã¦ãããããä»æããå ¥ã£ã¦ãã¾ããä¾ãã°ãdefvar, defun ã¯ãå±éæã«åå¾ã®ã³ã¼ããè¦ã«è¡ã£ã¦ãããããããã¬ãã£ã¯ã¹ãæ¢ãã¦ãã¦èªåã§å ¥ãã¾ããããã«ãå¼æ°ã®æååããdocstringãå¼·å¶çã«çæãããç¯ä»æ©è½ãããã¾ãã
defunå±éã®æ§å
defun ã® yasnippetï¼
# name : defun template # group : defun # key : df # contributor : kiwanami # -- (defun ${1:`(save-excursion (let ((re "(def\\\\(un\\\\|var\\\\)[ \t\n]*\\\\([a-z0-9]*[:-]\\\\)")) (cond ((or (re-search-backward re nil t) (re-search-forward re nil t)) (match-string 2)) (t ""))))`}${2:func-name} (${3:args}) "$2 ${3:$(mapconcat 'upcase (split-string (replace-regexp-in-string "&[a-z]+" "" yas/text)) " \n")}" $0 )
ãã®ããã«ãããªãæ¬æ°ã® elisp ãæ¸ãã¾ããåèã«ãªãã°ã¨æãã¾ãã
注æç¹ã¨ãã¦ãæååã®ä¸ã®ããã¯ã¹ã©ãã·ã¥ãä¸åº¦å±éããã¦ãã¾ããããªã®ã§ãæ£è¦è¡¨ç¾ãæ¸ãå ´åã¯ããã¯ã¹ã©ãã·ã¥ãå¤ãã«æ¸ãå¿ è¦ãããã¾ãã
ãããã°ãé£ããã®ã§ãå°ããªãã®ããæ¸ãã¦ãã£ããããã£ã±ã yasnippet ã®ã³ã¼ããå¼ãã ããã¦ãã¬ã¼ã¯ãã¤ã³ããä»æããã®ãæ©ãã§ãã
ã¯ã¾ãæã¨ãã¦ã¯ãåæå¤ãç¡ããã£ã¼ã«ããé£æ¥ãã¦ããã¨ããã£ã¼ã«ããæ¶ãã¦ãã¾ãã¾ããã$0ãã¨ãã¯è¦æ³¨æã§ããããã¯ãã£ã¼ã«ãã®ä½ç½®ããã¼ã«ã¼ãªãã¸ã§ã¯ãã§å°ãã¤ãã¦ãã¦ããã®ããéå§çµäºä½ç½®ãéãªã£ã¦ãã¾ãã¨ãã¼ã«ã¼ããã£ã¤ãã¦é¢ããªããªã£ã¦ãã¾ãããã§ããå®è£ ä¸ã®å¶éã ã¨æãã¾ãã®ã§ããã£ã¼ã«ããæ¶ãã¦ãã¾ãç¾è±¡ã§å°ã£ãå ´åã¯ãã¹ãã¼ã¹ãªã©ã§éããããã¨è¯ãã¨æãã¾ãã
ããã¤ãã¯ããã®gistã«ããã¦ãã¾ãã
ãã®ä»ãã¯
ãã£ã±ããyasnippetã®å¿ç¨æã®è§£èª¬ã¯ããã»ã©å¤ããªãã®ã§ããããã¤ãç´¹ä»ãã¦ã¿ã¾ãã
ãããã社ã®æ·±çºããããæ¨å¹´ã® Software Design 㧠yasnippet ã®è¨äºãæ¸ããã¦ãã¾ããï¼ããããªãããã¾ã èªãã§ãªãã§ãï¼ï¼ï¼ï¼
ãã³ãã¡ããã¯ãé£ç¶ãã¦å±éãããããã工夫ãç´¹ä»ããã¦ãã¾ãã
yasnippet.elを256倍にパワーアップ!連続展開と条件分岐テンプレートを使おう - (rubikitch loves (Emacs Ruby CUI Books))
ãã£ã±ããyasnippetã®ãããã¯ç®ã®åã§ä½¿ã£ã¦ããã®ãè¦ãã®ãä¸çªããã¨æãã¾ããã¨ãããã¨ã§ãè¿æã®Emacsåå¼·ä¼ã«ãã²åå ãã¦ã¿ã¾ãããã
ãã¾ã: let ã® * ãåãæ¿ãã
lisp系㧠let ã¨ãã®ä¸èº«ãæ¸ãã¦ããã¨ãã«ãã*ããä»ãããæ¶ãããããã®ãæãåºãã¦è¡ã£ããæ¥ãããããã¨ãå¤ãã£ãã®ã§ãä¸çºã§ãã°ã«ã§ããæ©è½ãæ¸ãã¦ã¿ã¾ããã
let, lexical-let ã®å¤æ°å®£è¨ãªã¹ãã®ä¸ï¼ä¸ã®ã³ã¼ãã®hereã®ãããï¼ã§ã toggle-let-astah ãå®è¡ããã¨letã®ã*ããåãæ¿ãã¾ãã
(let ( ; here (a 1) ; here (b 2) ; here ) body...)
èªåã®æã§ã¯ C-8 ã«å²ãå½ã¦ã¦ãã¾ããï¼USé åã§*ãããã®ã¨ãC-[æ°å]ã使ããªãã®ã§ï¼
Så¼ãè¦ãªããletãæ¢ãã«è¡ãã¾ãã®ã§ãäºæ³ãããªãã¨ããã®letãæ¸ãæãããã¯ããªãã¯ãã ã¨æãã¾ããæ£è¦è¡¨ç¾ãæ¸ãæããã°ãä»ã®ãã®ã«ã使ããã¨æãã¾ãã
以ä¸ãå°ãã¿ã§ããã