* Enabling/disabling minor modes based on major mode
@ 2011-02-22 13:40 Gary
2011-02-22 21:54 ` PJ Weisberg
2011-02-23 4:13 ` Kevin Rodgers
0 siblings, 2 replies; 3+ messages in thread
From: Gary @ 2011-02-22 13:40 UTC (permalink / raw)
To: help-gnu-emacs
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?
--
Gary Please do NOT send me 'courtesy' replies off-list.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Enabling/disabling minor modes based on major mode
2011-02-22 13:40 Enabling/disabling minor modes based on major mode Gary
@ 2011-02-22 21:54 ` PJ Weisberg
2011-02-23 4:13 ` Kevin Rodgers
1 sibling, 0 replies; 3+ messages in thread
From: PJ Weisberg @ 2011-02-22 21:54 UTC (permalink / raw)
To: help-gnu-emacs
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Enabling/disabling minor modes based on major mode
2011-02-22 13:40 Enabling/disabling minor modes based on major mode Gary
2011-02-22 21:54 ` PJ Weisberg
@ 2011-02-23 4:13 ` Kevin Rodgers
1 sibling, 0 replies; 3+ messages in thread
From: Kevin Rodgers @ 2011-02-23 4:13 UTC (permalink / raw)
To: help-gnu-emacs
On 2/22/11 6:40 AM, Gary 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?
No: Some minor modes can only be enabled/disabled by calling the mode's
function with a positive/negative argument -- the mode's variable is
just a read-only indicator of whether it is enabled or disabled.
--
Kevin Rodgers
Denver, Colorado, USA
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-02-23 4:13 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-22 13:40 Enabling/disabling minor modes based on major mode Gary
2011-02-22 21:54 ` PJ Weisberg
2011-02-23 4:13 ` Kevin Rodgers
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).