[Top][All Lists]

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

Re: How to determine buffer change

From: Stefan Monnier
Subject: Re: How to determine buffer change
Date: Sat, 05 Apr 2014 10:00:26 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux)

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

> Did you try using buffer-modified-tick?

Indeed, I'd either use buffer-chars-modified-tick, or set
buffer-undo-list to nil (after all, so you really want the user to be
able to un-insert the initial text?).


reply via email to

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