* Hooks and c/c++-mode
@ 2011-05-10 23:42 daniele.g
2011-05-11 0:09 ` Drew Adams
2011-05-11 0:23 ` Edward O'Connor
0 siblings, 2 replies; 4+ messages in thread
From: daniele.g @ 2011-05-10 23:42 UTC (permalink / raw)
To: help-gnu-emacs
Is there a smart way to set a hook for several modes at once? Maybe
using a regex or similar.
For example:
--8<---------------cut here---------------start------------->8---
(add-hook '{c|c++}-mode-hook
'(lambda ()
'do-something )))
--8<---------------cut here---------------end--------------->8---
Thanks in advance.
--
Posteggiare, v.:
Leggere, scrivere e spedire posta (elettronica).
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: Hooks and c/c++-mode
2011-05-10 23:42 Hooks and c/c++-mode daniele.g
@ 2011-05-11 0:09 ` Drew Adams
2011-05-11 0:23 ` Edward O'Connor
1 sibling, 0 replies; 4+ messages in thread
From: Drew Adams @ 2011-05-11 0:09 UTC (permalink / raw)
To: 'daniele.g', help-gnu-emacs
> Is there a smart way to set a hook for several modes at once?
> Maybe using a regex or similar.
> (add-hook '{c|c++}-mode-hook '(lambda () 'do-something))
Not that I know of. Just use `dolist' or `mapc'.
(dolist (hk '(c-mode-hook c++-mode-hook))
(add-hook hk 'do-something))
(BTW, there is no need to quote the lambda form.)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Hooks and c/c++-mode
2011-05-10 23:42 Hooks and c/c++-mode daniele.g
2011-05-11 0:09 ` Drew Adams
@ 2011-05-11 0:23 ` Edward O'Connor
2011-05-11 7:41 ` daniele.g
1 sibling, 1 reply; 4+ messages in thread
From: Edward O'Connor @ 2011-05-11 0:23 UTC (permalink / raw)
To: daniele.g; +Cc: help-gnu-emacs
> Is there a smart way to set a hook for several modes at once? Maybe
> using a regex or similar.
>
> For example:
>
> --8<---------------cut here---------------start------------->8---
> (add-hook '{c|c++}-mode-hook
> '(lambda ()
> 'do-something )))
> --8<---------------cut here---------------end--------------->8---
`c-mode-common-hook' is your friend. :)
Ted
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Hooks and c/c++-mode
2011-05-11 0:23 ` Edward O'Connor
@ 2011-05-11 7:41 ` daniele.g
0 siblings, 0 replies; 4+ messages in thread
From: daniele.g @ 2011-05-11 7:41 UTC (permalink / raw)
To: help-gnu-emacs
"Edward O'Connor" <hober0@gmail.com> writes:
>> Is there a smart way to set a hook for several modes at once? Maybe
>> using a regex or similar.
>>
>> For example:
>>
>> --8<---------------cut here---------------start------------->8---
>> (add-hook '{c|c++}-mode-hook
>> '(lambda ()
>> 'do-something )))
>> --8<---------------cut here---------------end--------------->8---
>
> `C-mode-common-hook' is your friend. :)
Thanks to both.
--
Oh, noi siamo noi, signore. Anche loro sono noi. Cosi', sia noi
che loro siamo noi.
-- Data a Picard e Riker, "Ricordare Parigi" (TNG)
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-05-11 7:41 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-10 23:42 Hooks and c/c++-mode daniele.g
2011-05-11 0:09 ` Drew Adams
2011-05-11 0:23 ` Edward O'Connor
2011-05-11 7:41 ` daniele.g
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).