* a mode-specific hack-local-variables-hook ?
@ 2015-06-17 19:54 Sam Halliday
2015-06-17 20:19 ` Sam Halliday
0 siblings, 1 reply; 4+ messages in thread
From: Sam Halliday @ 2015-06-17 19:54 UTC (permalink / raw)
To: help-gnu-emacs
Hi all,
I recently added this to my init.el
(add-hook 'hack-local-variables-hook 'whitespace-mode)
so that whitespace-mode would see my local variables before applying its rules.
I did this in my major mode hook, thinking that it would just add it to the current mode's hooks, but it seems to be a global hook. Other than putting in an "(if (eq major-mode 'scala-mode) ... )" type test in a lambda?
Best regards,
Sam
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: a mode-specific hack-local-variables-hook ?
2015-06-17 19:54 a mode-specific hack-local-variables-hook ? Sam Halliday
@ 2015-06-17 20:19 ` Sam Halliday
2015-06-17 21:06 ` John Mastro
[not found] ` <mailman.5204.1434575192.904.help-gnu-emacs@gnu.org>
0 siblings, 2 replies; 4+ messages in thread
From: Sam Halliday @ 2015-06-17 20:19 UTC (permalink / raw)
To: help-gnu-emacs
On Wednesday, 17 June 2015 20:54:43 UTC+1, Sam Halliday wrote:
> Hi all,
>
> I recently added this to my init.el
>
> (add-hook 'hack-local-variables-hook 'whitespace-mode)
>
> so that whitespace-mode would see my local variables before applying its rules.
>
> I did this in my major mode hook, thinking that it would just add it to the current mode's hooks, but it seems to be a global hook. Other than putting in an "(if (eq major-mode 'scala-mode) ... )" type test in a lambda?
Apologies, I appear to have completely failed to write a complete sentence here!
What I meant to say was:
I did this in my major mode hook, thinking that it would just add it to the current mode's hooks, but it seems to be a global hook. Other than putting in an "(if (eq major-mode 'scala-mode) ... )" type test in a lambda (outside of my major mode hook), is there any other way to set a buffer-local hack-local-variables-hook?
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: a mode-specific hack-local-variables-hook ?
2015-06-17 20:19 ` Sam Halliday
@ 2015-06-17 21:06 ` John Mastro
[not found] ` <mailman.5204.1434575192.904.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 4+ messages in thread
From: John Mastro @ 2015-06-17 21:06 UTC (permalink / raw)
To: Sam Halliday, help-gnu-emacs@gnu.org
> I did this in my major mode hook, thinking that it would just add it
> to the current mode's hooks, but it seems to be a global hook. Other
> than putting in an "(if (eq major-mode 'scala-mode) ... )" type test
> in a lambda (outside of my major mode hook), is there any other way to
> set a buffer-local hack-local-variables-hook?
The function `add-hook' has an optional fourth argument, LOCAL, about
which the `add-hook' docstring says:
The optional fourth argument, LOCAL, if non-nil, says to modify
the hook's buffer-local value rather than its global value.
This makes the hook buffer-local, and it makes t a member of the
buffer-local value. That acts as a flag to run the hook
functions of the global value as well as in the local value.
Does this do what you need?
(add-hook 'hack-local-variables-hook 'whitespace-mode nil t)
--
john
^ permalink raw reply [flat|nested] 4+ messages in thread
[parent not found: <mailman.5204.1434575192.904.help-gnu-emacs@gnu.org>]
* Re: a mode-specific hack-local-variables-hook ?
[not found] ` <mailman.5204.1434575192.904.help-gnu-emacs@gnu.org>
@ 2015-06-17 21:19 ` Sam Halliday
0 siblings, 0 replies; 4+ messages in thread
From: Sam Halliday @ 2015-06-17 21:19 UTC (permalink / raw)
To: help-gnu-emacs
Fantastic! Perfect for my needs. I was looking at the docs for all the wrong things.
On Wednesday, 17 June 2015 22:06:34 UTC+1, John Mastro wrote:
> > I did this in my major mode hook, thinking that it would just add it
> > to the current mode's hooks, but it seems to be a global hook. Other
> > than putting in an "(if (eq major-mode 'scala-mode) ... )" type test
> > in a lambda (outside of my major mode hook), is there any other way to
> > set a buffer-local hack-local-variables-hook?
>
> The function `add-hook' has an optional fourth argument, LOCAL, about
> which the `add-hook' docstring says:
>
> The optional fourth argument, LOCAL, if non-nil, says to modify
> the hook's buffer-local value rather than its global value.
> This makes the hook buffer-local, and it makes t a member of the
> buffer-local value. That acts as a flag to run the hook
> functions of the global value as well as in the local value.
>
> Does this do what you need?
>
> (add-hook 'hack-local-variables-hook 'whitespace-mode nil t)
>
> --
> john
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-06-17 21:19 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-17 19:54 a mode-specific hack-local-variables-hook ? Sam Halliday
2015-06-17 20:19 ` Sam Halliday
2015-06-17 21:06 ` John Mastro
[not found] ` <mailman.5204.1434575192.904.help-gnu-emacs@gnu.org>
2015-06-17 21:19 ` Sam Halliday
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.