bug-gnu-emacs
[Top][All Lists]
Advanced

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

Re: highlight-changes-rotate-faces sets buffer modified flag


From: Reindert-Jan Ekker
Subject: Re: highlight-changes-rotate-faces sets buffer modified flag
Date: Wed, 9 May 2007 15:41:14 +0200 (CEST)

On Wed, 9 May 2007, martin rudalics wrote:

Hi,

Turning off highlight-changes-mode sets the buffer-modified state as well.

This could be handled as with `highlight-changes-rotate-faces'.
Unfortunately, switching `highlight-changes-mode' off will leave
`buffer-undo-list' cluttered with all sorts of remnants that make sense
iff the mode is on.  You could try as follows: Switch the mode on, do
some changes, rotate colors, switch it off, undo changes.  Changed text
may get highlighted although the mode is off.

This does not seem to be a problem in my case. Looking at the value of buffer-undo-list after turning of highlight-changes-mode does show some face changes, but undo-ing these does not cause any text to become highlighted again.


By the way, I do not have a lot of experience with emacs lisp. Regarding
buffer-undo-list: would it be correct to just remove the front element
of the list in the advice I wrote?

Better not record the change in the first place by temporarily binding
`buffer-undo-list' to t during the buffer change.

So this is an improved version of my advice:

(defadvice highlight-changes-rotate-faces (around around-rotate-faces)
  (let ((was-modified (buffer-modified-p))
        (saved-undo-list buffer-undo-list)
        (buffer-undo-list t))
    ad-do-it
    (setq buffer-undo-list saved-undo-list)
    (unless was-modified
      (set-buffer-modified-p nil))))
(ad-activate 'highlight-changes-rotate-faces)


BTW, am I correct that you run `highlight-changes-rotate-faces'
interactively and not in `write-file-functions'?  In the latter case
setting the buffer-modified flag should get shadowed by the saving
primitive.


Actually, I am trying to write a hook that calls highlight-changes-rotate-faces on the right buffers whenever I do a subversion commit with psvn.

Reindert





reply via email to

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