From: Tassilo Horn <tassilo@member.fsf.org>
To: help-gnu-emacs@gnu.org
Subject: Re: How to set up a minor mode depending on a major mode?
Date: Tue, 12 May 2009 08:43:18 +0200 [thread overview]
Message-ID: <87skjastx5.fsf@thinkpad.tsdh.de> (raw)
In-Reply-To: e01d8a50905111513w2949766bod8b63b64fa28ffe1@mail.gmail.com
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
next prev parent reply other threads:[~2009-05-12 6:43 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-11 11:43 How to set up a minor mode depending on a major mode? tomas
2009-05-11 22:13 ` Lennart Borgman
2009-05-12 6:43 ` Tassilo Horn [this message]
[not found] ` <791153ba0905111408m6d4b36f4hfbf86b6290b9e75c@mail.gmail.com>
2009-05-12 9:11 ` Pilot error [was: How to set up a minor mode depending on a major mode?] tomas
2009-05-12 10:45 ` [semi-resolved] How to set up a minor mode depending on a major mode? tomas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87skjastx5.fsf@thinkpad.tsdh.de \
--to=tassilo@member.fsf.org \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.