unite.vim ã® action ãå®ç¾©ãã
ãã®è¨äºã¯ Vim Advent Calendar 2012 332æ¥ç®ã®è¨äºã«ãªãã¾ãã
ãã¦ãunite.vim ãªã®ã§ãã unite-menu ãªã©ã§åè£ã Vim ã®ã³ãã³ãã¨ãã¦å®è¡ããäºãã§ãã¾ãã
ãã®æã«ã³ãã³ããå®è¡ããã¨ãã®ã³ãã³ããã³ãã³ãå±¥æ´ã«è¿½å ããã¾ãã
ãããããã®æã«å±¥æ´ã«æ®ã£ã¦ã»ãããªãå ´åãããã¾ãã
ã¨ãããäºã§ãã³ãã³ããå®è¡ããæã«å±¥æ´ã«è¿½å ããªãããã㪠unite.vim ã® action ãå®ç¾©ãã¦ã¿ã¾ããã
[ã½ã¼ã¹]
" action ãå®ç¾© " ä»å㯠kind ã§ã¯ãªã㦠action åä½ãå®ç¾©ãã " action ã®è¨å®ãªã©ã¯ãã®è¾æ¸ã«è¨è¿°ãã " è¨å®ã§ããé ç®ã¯ " :help unite-kind-attribute-action_table " ãåç § let s:action = { \ 'is_selectable' : 0, \} " action ã®æåãå¦çãã " å¼æ°ã® candidate ã¯é¸æãããåè£ã®ãã¼ã¿ã§ãã " ã¾ã candidate 㯠" 'is_selectable' : 0 ã®å ´åã¯ãè¾æ¸ " 'is_selectable' : 1 ã®å ´åã¯ãè¾æ¸ã®ãªã¹ã " ã«ãªã function! s:action.func(candidate) " 'action__command' 㯠unite-source å´ã§è¨å®ããã¦ããæ å ± " ãã® action ã使ç¨ãããã®ã§ããã° " unite-source å´ã§ action__command ãè¨å®ãã¦ããå¿ è¦ããã let command = a:candidate.action__command let type = get(a:candidate, 'action__type', ':') try execute type . command catch /E486/ " Ignore search pattern error. endtry endfunction " kind ã« action ã追å ãã " ä»å㯠kind-command ã«å¯¾ã㦠action ã追å ãã " ãã㧠kind-command ãè¨å®ããã¦ããåè£ã«å¯¾ã㦠" ãã® action ã使ç¨ã§ããããã«ãªã call unite#custom#action('command', 'non_history_execute', s:action) unlet s:action " kind-command ã® default action ãä»åå®ç¾©ãã action ã«è¨å®ãã " ããã§åè£ã決å®ï¼åè£ãé¸æãã¦<CR>ï¼ããæã« " ãã® action ãå¼ã³åºããã call unite#custom#default_action('command', 'non_history_execute')
ãã®ããã«ã㦠unite.vim ã® action ãå®ç¾©ãããã¨ãã§ãã¾ãã
æ¢åã® action ãå¤æ´ãããå ´åãæ°ãã action ã追å ãããå ´åã«æå¹ãªã®ã§è²ã
ã¨è©¦ãã¦ã¿ãã¨ããã¨æãã¾ãã