help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: add-hook


From: Dmitry Gutov
Subject: Re: add-hook
Date: Sat, 26 Jan 2013 10:21:48 +0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (windows-nt)

Barry Margolin <address@hidden> writes:

> In article <address@hidden>,
>  Dmitry Gutov <address@hidden> wrote:
>
>> "Drew Adams" <address@hidden> writes:
>> > If HOOK is void then it is initialized to nil.
>> >
>> > (add-hook 'ruby-mode-hook (lambda () (ruby-electric-mode t)))
>> 
>> Or, even shorter:
>> 
>> (add-hook 'ruby-mode-hook 'ruby-electric-mode)
>
> Not the same. With no argument it toggles, with an argument it turns the 
> mode on or off as specified by the argument.

Not really. It toggles only when the mode function is called
interactively. Otherwise, a no-argument call always means "turn on".

Try to eval this a few times, for example: (linum-mode)

In the context of ruby-electric this is irrelevant anyway, though, since
it doesn't have a concept of turning off. Whenever called, it just
modifies ruby-mode-map to use its electric commands.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]