unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Problem with undo and text properties.
@ 2015-04-09 11:10 Alan Mackenzie
  2015-04-09 11:19 ` João Távora
  2015-04-09 13:17 ` Stefan Monnier
  0 siblings, 2 replies; 5+ messages in thread
From: Alan Mackenzie @ 2015-04-09 11:10 UTC (permalink / raw)
  To: emacs-devel

Hello, Emacs.

I noticed the following problem whilst solving bug #20266.  In that bug,
in a ~1500 line file.h, mark the entire buffer and yank it to the end of
itself, doubling its size, with C-x h, M-w, M->, C-y.  This went slowly,
and will soon go at a reasonable speed.

However, if you then undo this with C-x u, it takes almost forever to
complete.  The reason is that in the undo list there are lots (~6500) of
text property entries like

    (nil fontified nil 92222 . 92237)

which get individually undone.  Each such undoing is a buffer change, and
so triggers \(before\|after\)-change-functions.  This makes the operation
SLOW.

Perhaps it would be better to amend undo such that the removal (?and
re-application?) of text properties doesn't trigger the change hooks.  Or
perhaps a means could be devised of informing the change hooks that such
a change is what is being done.

What do you think?

-- 
Alan Mackenzie (Nuremberg, Germany).



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Problem with undo and text properties.
  2015-04-09 11:10 Problem with undo and text properties Alan Mackenzie
@ 2015-04-09 11:19 ` João Távora
  2015-04-09 13:17 ` Stefan Monnier
  1 sibling, 0 replies; 5+ messages in thread
From: João Távora @ 2015-04-09 11:19 UTC (permalink / raw)
  To: Alan Mackenzie; +Cc: emacs-devel

Alan Mackenzie <acm@muc.de> writes:

> perhaps a means could be devised of informing the change hooks that
> such a change is what is being done.

There is `undo-in-progress' apparently for this purpose.

    Non-nil while performing an undo.
    Some change-hooks test this variable to do something different.

João



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Problem with undo and text properties.
  2015-04-09 11:10 Problem with undo and text properties Alan Mackenzie
  2015-04-09 11:19 ` João Távora
@ 2015-04-09 13:17 ` Stefan Monnier
  2015-04-13 19:10   ` Alan Mackenzie
  1 sibling, 1 reply; 5+ messages in thread
From: Stefan Monnier @ 2015-04-09 13:17 UTC (permalink / raw)
  To: Alan Mackenzie; +Cc: emacs-devel

> However, if you then undo this with C-x u, it takes almost forever to
> complete.  The reason is that in the undo list there are lots (~6500) of
> text property entries like

>     (nil fontified nil 92222 . 92237)

The problem is that those entries shouldn't be there in the first place.
Whoever puts them there needs a with-silent-modification.


        Stefan



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Problem with undo and text properties.
  2015-04-09 13:17 ` Stefan Monnier
@ 2015-04-13 19:10   ` Alan Mackenzie
  2015-04-13 21:23     ` Stefan Monnier
  0 siblings, 1 reply; 5+ messages in thread
From: Alan Mackenzie @ 2015-04-13 19:10 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

Hello, Stefan.

Sorry for the delay in responding.  My network connection went down on
Thursday afternoon, and I had to wait until this morning to get it back.
You've got to love Deutsche Telekom.  :-(

[Context: load medium sized file.h.  C-x h, M-w, M->, C-y, C-x u.  The
C-x u goes slowly.]

On Thu, Apr 09, 2015 at 09:17:04AM -0400, Stefan Monnier wrote:
> > However, if you then undo this with C-x u, it takes almost forever to
> > complete.  The reason is that in the undo list there are lots (~6500) of
> > text property entries like

> >     (nil fontified nil 92222 . 92237)

> The problem is that those entries shouldn't be there in the first place.
> Whoever puts them there needs a with-silent-modification.

1. M-w puts the string-version-of-the-entire-file (including text
properties) into the kill ring.
2. C-y first appends that string to the buffer, ...
3. ... then separately removes the yank-excluded-properties from the
buffer, creating (nil fontified nil 92222. 92237) in buffer-undo-list in
so doing.

The part of C-y that does 3 is remove-yank-excluded-properties.  I think
you're suggesting we put a with-silent-modification around the critical
bits in remove-yank-excluded-properties.  Maybe I'll try that.

>         Stefan

-- 
Alan Mackenzie (Nuremberg, Germany).



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Problem with undo and text properties.
  2015-04-13 19:10   ` Alan Mackenzie
@ 2015-04-13 21:23     ` Stefan Monnier
  0 siblings, 0 replies; 5+ messages in thread
From: Stefan Monnier @ 2015-04-13 21:23 UTC (permalink / raw)
  To: Alan Mackenzie; +Cc: emacs-devel

>> The problem is that those entries shouldn't be there in the first place.
>> Whoever puts them there needs a with-silent-modification.

> 1. M-w puts the string-version-of-the-entire-file (including text
> properties) into the kill ring.
> 2. C-y first appends that string to the buffer, ...
> 3. ... then separately removes the yank-excluded-properties from the
> buffer, creating (nil fontified nil 92222. 92237) in buffer-undo-list in
> so doing.

> The part of C-y that does 3 is remove-yank-excluded-properties.

Hmm... I don't quite understand why removing properties would add
entries like (nil fontified nil 92222 . 92237) which state that the
`fonfified' property was changed *from* nil to something else.
Tho I guess maybe removing a nil property still is considered as
"changing" it.

> I think you're suggesting we put a with-silent-modification around the
> critical bits in remove-yank-excluded-properties.  Maybe I'll
> try that.

Hmm... yes, I think with-silent-modification around the last three lines
of remove-yank-excluded-properties would be fine.


        Stefan



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-04-13 21:23 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-09 11:10 Problem with undo and text properties Alan Mackenzie
2015-04-09 11:19 ` João Távora
2015-04-09 13:17 ` Stefan Monnier
2015-04-13 19:10   ` Alan Mackenzie
2015-04-13 21:23     ` Stefan Monnier

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).