Emacs auto-minor-mode based on extension

前端 未结 2 1758
悲哀的现实
悲哀的现实 2021-02-07 05:13

I found this question somewhat on the topic, but is there a way [in emacs] to set a minor mode (or a list thereof) based on extension? For example, it\'s pretty easy to

2条回答
  •  走了就别回头了
    2021-02-07 05:26

    The answer by Trey Jackson seems to be a very robust and extensible solution, but I was looking for something simpler. The following code will enable the fictional hmmm-mode when editing .hmmm files:

    (add-hook 'find-file-hook
              (lambda ()
                (when (string= (file-name-extension buffer-file-name) "hmmm")
                  (hmmm-mode +1))))
    

提交回复
热议问题