help-gnu-emacs
[Top][All Lists]
Advanced

[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: Tassilo Horn
Subject: Re: How to set up a minor mode depending on a major mode?
Date: Tue, 12 May 2009 08:43:18 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.93 (gnu/linux)

Lennart Borgman <lennart.borgman@gmail.com> writes:

Hi!

>> 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.

Just a blind guess: Maybe the argument t is not sufficient to turn on
v-l-m.  In general, minor modes are enabled if the function is given a
positive argument, and they're disabled if the argument is negative.

Try

  (add-hook 'am-mode-hook '(lambda () (visual-line-mode 1)))

or even better

  (add-hook 'am-mode-hook 'turn-on-visual-line-mode)

Bye,
Tassilo
-- 
Richard Stallman can touch MC Hammer





reply via email to

[Prev in Thread] Current Thread [Next in Thread]