From: David Engster <deng@randomsample.de>
To: Jambunathan K <kjambunathan@gmail.com>
Cc: emacs-devel@gnu.org
Subject: Re: Confusion about first-change-hook
Date: Tue, 18 Dec 2012 22:09:08 +0100 [thread overview]
Message-ID: <87zk1bgj9n.fsf@engster.org> (raw)
In-Reply-To: <874njjgjlq.fsf@gmail.com> (Jambunathan K.'s message of "Wed, 19 Dec 2012 02:31:53 +0530")
Jambunathan K. writes:
> David Engster <deng@randomsample.de> writes:
>
>> I wanted to do something very simple: Activate whitespace-mode only when
>> I start editing a buffer. So I looked into the manual and found
>> `first-change-hook', which seemed exactly what I wanted.
>
> This seems to work:
>
> (add-hook 'c++-mode-hook
> (lambda nil
> (add-hook 'before-change-functions 'activate-whitespace-mode
> nil 'local)))
>
> (defun activate-whitespace-mode (beg end)
> (whitespace-mode 1)
> (remove-hook 'before-change-functions
> 'activate-whitespace-mode 'local))
Thank you. This works nicely.
-David
prev parent reply other threads:[~2012-12-18 21:09 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-18 19:59 Confusion about first-change-hook David Engster
2012-12-18 20:43 ` Stefan Monnier
2012-12-18 21:00 ` David Engster
2012-12-19 1:01 ` Stefan Monnier
2012-12-18 21:01 ` Jambunathan K
2012-12-18 21:09 ` David Engster [this message]
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=87zk1bgj9n.fsf@engster.org \
--to=deng@randomsample.de \
--cc=emacs-devel@gnu.org \
--cc=kjambunathan@gmail.com \
/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.