我想为特定的文件扩展名(即不是模式)运行一个钩子.我对elisp没有任何经验,所以我用货物编码这个:
(defun set_tab_mode ()
(when (looking-at-p "\\.cat")
(insert "OK")
(orgtbl-mode)))
(add-hook 'find-file-hook 'set_tab_mode)
Run Code Online (Sandbox Code Playgroud)
(应该为带有后缀.cat的文件设置orgtbl次要模式并插入文本"OK",即它不仅是模式设置问题).不幸的是它不起作用.
Vic*_*gin 23
你可以在lambda中使用auto-mode-alist:
(add-to-list 'auto-mode-alist
'("\\.cat\\'" . (lambda ()
;; add major mode setting here, if needed, for example:
;; (text-mode)
(insert "OK")
(turn-on-orgtbl))))
Run Code Online (Sandbox Code Playgroud)
yib*_*ibe 21
试试这个:
(defun my-set-tab-mode ()
(when (and (stringp buffer-file-name)
(string-match "\\.cat\\'" buffer-file-name))
(insert "OK")
(orgtbl-mode)))
(add-hook 'find-file-hook 'my-set-tab-mode)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5021 次 |
| 最近记录: |