[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Confusion about first-change-hook
From: |
David Engster |
Subject: |
Re: Confusion about first-change-hook |
Date: |
Tue, 18 Dec 2012 22:09:08 +0100 |
User-agent: |
Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.2.50 (gnu/linux) |
Jambunathan K. writes:
> David Engster <address@hidden> 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