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: Jun
Subject: Re: How to get hook var of the current major mode?
Date: Sun, 19 May 2013 09:52:53 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130509 Thunderbird/17.0.6

On 05/18/2013 01:38 PM, Dmitry Gutov wrote:
"netjunegg2@gmail.com" <netjunegg2@gmail.com> writes:

I want to do somthing like this:
(let ((hook (get--the--current--major--mode--hook)))
   (add-hook hook (lambda ()
                    (setq truncate-lines t))))
If the major mode is already current, then the hook has already run,
hasn't it? Adding a lambda to it will have to effect on the next buffer
in the same mode. And if the above form is run many times, each time a
new lambda will be added to the hook.

But anyway, try (intern (format "%s-hook" major-mode)).
.

This is what I want. In fact, I have defined a function which turns on yasnippet minor mode, auto complete mode, etc, and a macro which can run some code for all buffers in the same mode as the current. I want to turn on some modes only when editing source code, not when viewing, and not for buffers other than source code, which is not too usefull for chinese.
Thank you.



reply via email to

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