[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to set up a minor mode depending on a major mode?
From: |
Lennart Borgman |
Subject: |
Re: How to set up a minor mode depending on a major mode? |
Date: |
Tue, 12 May 2009 00:13:54 +0200 |
On Mon, May 11, 2009 at 1:43 PM, <tomas@tuxteam.de> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi, Emacs-folks
>
> I'd like to set up some minor mode whenever a major mode is switched on.
> I gather that the recommended method seems to be to hook into the major
> mode hook like so:
>
> (add-hook 'am-mode-hook '(lambda () (visual-line-mode t)))
>
> (i.e. switch visual-line-mode on whenever am-mode-hook is swiitched on).
>
> However, this doesn't work, and I have tracked it back to the standard
> major-mode machinery doing a (kill-all-local-variables) sweeping away
> whatever tidbits the minor mode needs to survive.
Running the major mode hook should be the very last thing a major mode
does. From your description it sounds like am-mode runs the hook
earlier. That would be a bug.