all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* How to determine buffer change
@ 2014-04-05 11:41 Thorsten Jolitz
  2014-04-05 11:49 ` Thorsten Jolitz
  2014-04-05 11:59 ` Eli Zaretskii
  0 siblings, 2 replies; 7+ messages in thread
From: Thorsten Jolitz @ 2014-04-05 11:41 UTC (permalink / raw)
  To: help-gnu-emacs


Hi List, 

in a program I insert text in an empty temporary edit-buffer, what of
course modifies the `buffer-undo-list'.
Assume that at this moment (lets call it time T1)

,------------------------------
| M-: (length buffer-undo-list)
`------------------------------

returns 9. 

Now when there are changes to the text in the edit-buffer, these are
copied to the original buffer after quitting. But when nothing has
changed after the insertion of the original text, it would be better to
simply discard the edit-buffer and not touch the original buffer at
all. 

I could remember the length of the buffer-undo-list at time T1 and then
check if it changed when quitting, but this does not seem very robust,
since this length grows and shrinks in both directions.

I would rather store the whole buffer-undo-list in a VAR1 at time T1,
and then again in VAR2 at time T2 (when quitting), and then do

,---------------
| (eq VAR1 VAR2)
`---------------

to figure out if any edits happened. 

Would this be robust enough? Is it highly unlikely or even impossible
for the buffer-undo-list to return to the same state/value after some
do's and undo's in the edit-buffer?

Is there maybe another simple trick to achieve what I want?

-- 
cheers,
Thorsten





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

end of thread, other threads:[~2014-04-05 14:54 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-05 11:41 How to determine buffer change Thorsten Jolitz
2014-04-05 11:49 ` Thorsten Jolitz
2014-04-05 11:59 ` Eli Zaretskii
2014-04-05 12:52   ` Thorsten Jolitz
2014-04-05 13:23     ` Thorsten Jolitz
2014-04-05 14:00   ` Stefan Monnier
2014-04-05 14:54     ` Thorsten Jolitz

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.