我试图设置,.emacs以便任何以字母开头的文件将其makefile设置为makefile模式.例如,makefile-something应该是makefile模式.
这不起作用:
(setq auto-mode-alist (cons '("^makefile" . makefile-mode) auto-mode-alist))
Run Code Online (Sandbox Code Playgroud)
但这样做:
(setq auto-mode-alist (cons '("makefile" . makefile-mode) auto-mode-alist))
Run Code Online (Sandbox Code Playgroud)
有谁能解释为什么?
小智 7
这是因为文件名前面有一个路径组件,请尝试:
"/makefile[^/]*$"
Run Code Online (Sandbox Code Playgroud)
见http://www.gnu.org/s/emacs/manual/html_node/elisp/Auto-Major-Mode.html(页面底部)
EDI:根据肖恩的评论纠正了正则表达式