From: PJ Weisberg <pj@irregularexpressions.net>
To: help-gnu-emacs@gnu.org
Subject: Re: Enabling/disabling minor modes based on major mode
Date: Tue, 22 Feb 2011 13:54:52 -0800 [thread overview]
Message-ID: <AANLkTikn_KCjzynYfKvfsCOES9dAyQc4uEht-d7WQD89@mail.gmail.com> (raw)
In-Reply-To: <ik0ebv$j14$1@dough.gmane.org>
On Tue, Feb 22, 2011 at 5:40 AM, Gary <listgj-emacs@yahoo.co.uk> wrote:
> Is there a nice, consistent, way to do this?
>
> From reading around I found
> ,----
> | (add-hook 'term-mode-hook '(lambda() (set (make-local-variable
> | 'global-hl-line-mode) 0)))
> `----
> but that's clearly specific to global-hl-line-mode.
>
> Or is it? Could I do the same with, say, yas/minor-mode for the
> yasnippet modes? Is
> ,----
> | (set (make-local-variable '<minor-mode-name>) 0)
> `----
> guaranteed to work for all minor modes?
>
> Is there a better way of achieving what I want?
There's some function that turns on whatever mode you want, which you
can add to the hook list. For instance, in my .emacs file I have:
(add-hook 'text-mode-hook 'turn-on-visual-line-mode)
If there were no function called turn-on-visual-line-mode, I could have used:
(add-hook 'text-mode-hook (lambda() (visual-line-mode 1)))
...which is actually all turn-on-visual-line-mode is. Most (all?)
minor modes have a function of the same name that turns the mode on
with a numeric argument > 0 and off with a numeric argument <= 0, so
you could always do that. Also, the following:
(add-hook 'text-mode-hook 'visual-line-mode)
...would do what I want, because visual-line-mode with no argument
toggles the mode, and text-mode starts with it OFF.
Hope that helps.
-PJ
next prev parent reply other threads:[~2011-02-22 21:54 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-22 13:40 Enabling/disabling minor modes based on major mode Gary
2011-02-22 21:54 ` PJ Weisberg [this message]
2011-02-23 4:13 ` Kevin Rodgers
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=AANLkTikn_KCjzynYfKvfsCOES9dAyQc4uEht-d7WQD89@mail.gmail.com \
--to=pj@irregularexpressions.net \
--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.