From: Jun <netjunegg2@gmail.com>
To: Dmitry Gutov <dgutov@yandex.ru>
Cc: help-gnu-emacs@gnu.org
Subject: Re: How to get hook var of the current major mode?
Date: Sun, 19 May 2013 09:52:53 +0000 [thread overview]
Message-ID: <5198A0F5.8030704@gmail.com> (raw)
In-Reply-To: <87r4h45rxz.fsf@yandex.ru>
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.
next prev parent reply other threads:[~2013-05-19 9:52 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-18 9:48 How to get hook var of the current major mode? netjunegg2
2013-05-18 13:38 ` Dmitry Gutov
2013-05-19 9:52 ` Jun [this message]
[not found] ` <mailman.32.1368884325.22516.help-gnu-emacs@gnu.org>
2013-05-18 19:45 ` Emanuel Berg
2013-05-18 20:38 ` Dmitry Gutov
[not found] <mailman.17.1368841736.22516.help-gnu-emacs@gnu.org>
2013-05-18 2:52 ` Emanuel Berg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5198A0F5.8030704@gmail.com \
--to=netjunegg2@gmail.com \
--cc=dgutov@yandex.ru \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.