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

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

Re: How to get hook var of the current major mode?


From: Dmitry Gutov
Subject: Re: How to get hook var of the current major mode?
Date: Sun, 19 May 2013 00:38:59 +0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (windows-nt)

Emanuel Berg <embe8573@student.uu.se> writes:

> Dmitry Gutov <dgutov@yandex.ru> writes:
>
>>> I want to do somthing like this:
>>> (let ((hook (get--the--current--major--mode--hook)))
>>>   (add-hook hook (lambda ()
>>>                    (setq truncate-lines t))))
>>
>> ...And if the above form is run many times, each time a new lambda
>> will be added to the hook.
>
> When the hook fires, are all those lambda executed (doing the same
> thing)?

Actually, sorry, I take that back. Even in lexical-binding environment,
(lambda () (abc)) is `equal' to another (lambda () (abc)), at least
currently. And `add-hook' checks if the given function is already
present in the list, with `member'. So there won't be duplicates in the
hook value.

Still, like I wrote previously, adding function to the hook of the
current major mode doesn't make much sense.



reply via email to

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