开发者

Entering a minor mode with a major mode in Emacs

This question may be a duplicate of this question, but I can't get the following to work properly in my emacs.

I am trying to enter minor mode mlint-mode whenever I enter major mode matlab-mode (both modes available at their SourceForge page). I have the following in my .emacs file:

(add-hook 'matlab-mode-hook
      (functi开发者_运维知识库on (lambda()
                  (mlint-mode))))

which looks like the answer to the question I linked above. When opening a .m file, I get the following error:

File mode specification error: (void-function mlint-mode)

Could someone please assist in helping me write the correct hook to enter mlint-mode when I open a .m file? FWIW, I'm running emacs 23.1.50.1.


I think the correct name is mlint-minor-mode. Also, remember to ensure that all matlab stuff is known by Emacs, this can be done using:

(require 'matlab-load)

As a side note, it is typically a bad idea to use lambda functions in hooks. If you inspect the value of the hook you will see a lot of unrelated things. Also, if you modify your lambda expression and re-add it, both the old and the new version will be on the hook.

Instead, you can do something like:

(defun my-matlab-hook ()
   (mlint-minor-mode 1))
(add-hook 'matlab-mode-hook 'my-matlab-hook)

The "1" is ensures that mlint mode is turned on or stay on if enabled earlier.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜