* Re: highlight-changes-rotate-faces sets buffer modified flag
@ 2007-05-08 6:10 martin rudalics
2007-05-09 9:29 ` Reindert-Jan Ekker
0 siblings, 1 reply; 6+ messages in thread
From: martin rudalics @ 2007-05-08 6:10 UTC (permalink / raw)
To: R.Ekker; +Cc: bug-gnu-emacs
> Running the function highlight-changes-rotate-faces sets the buffer's
> modified flag. It seems to me that this should not happen, since only
> some faces are changed.
Thank you for sending a report on this. In principle a "face change"
may change the buffer-modified state and can be undone as well. In the
present case I agree with you that the buffer-modified state should not
change. I believe that most of theses face changes were obscured by
changes in the buffer text, hence probably people didn't notice.
> As a workaround, I use the following advice:
>
>
> ;; advice for highlight-changes-rotate-faces
> ;; so that it does not change the modified flag for the buffer
> (defadvice highlight-changes-rotate-faces (around around-rotate-faces)
> (let ((was-modified (buffer-modified-p)))
> ad-do-it
> (unless was-modified
> (set-buffer-modified-p nil))))
> (ad-activate 'highlight-changes-rotate-faces)
You proably do not want adding an entry to `buffer-undo-list' either.
>
>
> The version string of my emacs:
> "GNU Emacs 21.3.1 (i386-mingw-nt5.1.2600) of 2004-03-10 on NYAUMO"
AFAICT this problem is still present in Emacs 22. In addition, it seems
to me that turning off `highlight-changes-mode' may set the
buffer-modified state as well. Could you please verify this on your
system?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: highlight-changes-rotate-faces sets buffer modified flag
2007-05-08 6:10 highlight-changes-rotate-faces sets buffer modified flag martin rudalics
@ 2007-05-09 9:29 ` Reindert-Jan Ekker
2007-05-09 12:24 ` martin rudalics
0 siblings, 1 reply; 6+ messages in thread
From: Reindert-Jan Ekker @ 2007-05-09 9:29 UTC (permalink / raw)
To: martin rudalics; +Cc: R.Ekker, bug-gnu-emacs
Hi,
Turning off highlight-changes-mode sets the buffer-modified state as well.
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?
With regards,
Reindert
On Tue, 8 May 2007, martin rudalics wrote:
>> Running the function highlight-changes-rotate-faces sets the buffer's
>> modified flag. It seems to me that this should not happen, since only
>> some faces are changed.
>
> Thank you for sending a report on this. In principle a "face change"
> may change the buffer-modified state and can be undone as well. In the
> present case I agree with you that the buffer-modified state should not
> change. I believe that most of theses face changes were obscured by
> changes in the buffer text, hence probably people didn't notice.
>
>> As a workaround, I use the following advice:
>>
>>
>> ;; advice for highlight-changes-rotate-faces
>> ;; so that it does not change the modified flag for the buffer
>> (defadvice highlight-changes-rotate-faces (around around-rotate-faces)
>> (let ((was-modified (buffer-modified-p)))
>> ad-do-it
>> (unless was-modified
>> (set-buffer-modified-p nil))))
>> (ad-activate 'highlight-changes-rotate-faces)
>
> You proably do not want adding an entry to `buffer-undo-list' either.
>
>>
>>
>> The version string of my emacs:
>> "GNU Emacs 21.3.1 (i386-mingw-nt5.1.2600) of 2004-03-10 on NYAUMO"
>
> AFAICT this problem is still present in Emacs 22. In addition, it seems
> to me that turning off `highlight-changes-mode' may set the
> buffer-modified state as well. Could you please verify this on your
> system?
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: highlight-changes-rotate-faces sets buffer modified flag
2007-05-09 9:29 ` Reindert-Jan Ekker
@ 2007-05-09 12:24 ` martin rudalics
2007-05-09 13:41 ` Reindert-Jan Ekker
0 siblings, 1 reply; 6+ messages in thread
From: martin rudalics @ 2007-05-09 12:24 UTC (permalink / raw)
To: Reindert-Jan Ekker; +Cc: bug-gnu-emacs
> 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.
> 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.
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.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: highlight-changes-rotate-faces sets buffer modified flag
2007-05-09 12:24 ` martin rudalics
@ 2007-05-09 13:41 ` Reindert-Jan Ekker
2007-05-09 16:53 ` martin rudalics
0 siblings, 1 reply; 6+ messages in thread
From: Reindert-Jan Ekker @ 2007-05-09 13:41 UTC (permalink / raw)
To: martin rudalics; +Cc: Reindert-Jan Ekker, bug-gnu-emacs
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: highlight-changes-rotate-faces sets buffer modified flag
2007-05-09 13:41 ` Reindert-Jan Ekker
@ 2007-05-09 16:53 ` martin rudalics
0 siblings, 0 replies; 6+ messages in thread
From: martin rudalics @ 2007-05-09 16:53 UTC (permalink / raw)
To: Reindert-Jan Ekker; +Cc: bug-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 1062 bytes --]
> 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)
The following should be sufficient
(defadvice highlight-changes-rotate-faces (around around-rotate-faces)
(let ((was-modified (buffer-modified-p))
(buffer-undo-list t))
ad-do-it
(unless was-modified
(set-buffer-modified-p nil))))
(ad-activate 'highlight-changes-rotate-faces)
but please check whether undoing / redoing does assign the correct
colors.
Alternatively you could try to replace your version of
`highlight-changes-rotate-faces' with the one I attached. Either you do
that directly in hilit-chg.el (recompiling that file) or you add it to
your .emacs preceded by a
(require 'hilit-chg)
line.
[-- Attachment #2: highlight-changes-rotate-faces.el --]
[-- Type: text/plain, Size: 1409 bytes --]
(defun highlight-changes-rotate-faces ()
"Rotate the faces used by Highlight Changes mode.
Current changes are displayed in the face described by the first element
of `highlight-changes-face-list', one level older changes are shown in
face described by the second element, and so on. Very old changes remain
shown in the last face in the list.
You can automatically rotate colors when the buffer is saved by adding
this function to `write-file-functions' as a buffer-local value. To do
this, eval the following in the buffer to be saved:
\(add-hook 'write-file-functions 'highlight-changes-rotate-faces nil t)"
(interactive)
;; If not in active mode do nothing but don't complain because this
;; may be bound to a hook.
(when (eq highlight-changes-mode 'active)
(let ((modified (buffer-modified-p))
(buffer-undo-list t)
(inhibit-modification-hooks t))
(unwind-protect
(progn
;; ensure hilit-chg-list is made and up to date
(hilit-chg-make-list)
;; remove our existing overlays
(hilit-chg-hide-changes)
;; for each change text property, increment it
(hilit-chg-map-changes 'hilit-chg-bump-change)
;; and display them all if active
(if (eq highlight-changes-mode 'active)
(hilit-chg-display-changes)))
(unless modified (set-buffer-modified-p nil)))))
;; This always returns nil so it is safe to use in write-file-functions
nil)
[-- Attachment #3: Type: text/plain, Size: 149 bytes --]
_______________________________________________
bug-gnu-emacs mailing list
bug-gnu-emacs@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-gnu-emacs
^ permalink raw reply [flat|nested] 6+ messages in thread
* highlight-changes-rotate-faces sets buffer modified flag
@ 2007-05-07 15:30 Reindert-Jan Ekker
0 siblings, 0 replies; 6+ messages in thread
From: Reindert-Jan Ekker @ 2007-05-07 15:30 UTC (permalink / raw)
To: bug-gnu-emacs
L.S.
Running the function highlight-changes-rotate-faces sets the buffer's
modified flag. It seems to me that this should not happen, since only some
faces are changed. As a workaround, I use the following advice:
;; advice for highlight-changes-rotate-faces
;; so that it does not change the modified flag for the buffer
(defadvice highlight-changes-rotate-faces (around around-rotate-faces)
(let ((was-modified (buffer-modified-p)))
ad-do-it
(unless was-modified
(set-buffer-modified-p nil))))
(ad-activate 'highlight-changes-rotate-faces)
The version string of my emacs:
"GNU Emacs 21.3.1 (i386-mingw-nt5.1.2600) of 2004-03-10 on NYAUMO"
With kind regards,
Reindert-Jan Ekker
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2007-05-09 16:53 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-05-08 6:10 highlight-changes-rotate-faces sets buffer modified flag martin rudalics
2007-05-09 9:29 ` Reindert-Jan Ekker
2007-05-09 12:24 ` martin rudalics
2007-05-09 13:41 ` Reindert-Jan Ekker
2007-05-09 16:53 ` martin rudalics
-- strict thread matches above, loose matches on Subject: below --
2007-05-07 15:30 Reindert-Jan Ekker
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.