[Top][All Lists]

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

Re: Confusion about first-change-hook

From: Jambunathan K
Subject: Re: Confusion about first-change-hook
Date: Wed, 19 Dec 2012 02:31:53 +0530
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

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))

> However, I soon saw that whitespace-mode got immediately activated in my
> C++ buffers. The reason is that changing a text property apparently
> already counts as "changing the buffer". Is this really the desired
> behavior? If so, what else is there to achieve the above? Should I file
> a wishlist-bug for something like 'buffer-modified-hook'?
> -David


reply via email to

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