From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Thorsten Jolitz Newsgroups: gmane.emacs.help Subject: Re: How to determine buffer change Date: Sat, 05 Apr 2014 16:54:28 +0200 Message-ID: <87ioqnddy3.fsf@gmail.com> References: <877g74dmve.fsf@gmail.com> <83d2gw7zsp.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1396709629 9001 80.91.229.3 (5 Apr 2014 14:53:49 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 5 Apr 2014 14:53:49 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Apr 05 16:53:42 2014 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1WWRyY-0000Cx-3T for geh-help-gnu-emacs@m.gmane.org; Sat, 05 Apr 2014 16:53:42 +0200 Original-Received: from localhost ([::1]:54899 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WWRyX-0001qM-OY for geh-help-gnu-emacs@m.gmane.org; Sat, 05 Apr 2014 10:53:41 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58891) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WWRyH-0001qA-85 for help-gnu-emacs@gnu.org; Sat, 05 Apr 2014 10:53:31 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WWRyB-0002Db-B9 for help-gnu-emacs@gnu.org; Sat, 05 Apr 2014 10:53:25 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:49000) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WWRyB-0002DX-4f for help-gnu-emacs@gnu.org; Sat, 05 Apr 2014 10:53:19 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1WWRy8-0008Ix-Qd for help-gnu-emacs@gnu.org; Sat, 05 Apr 2014 16:53:16 +0200 Original-Received: from g231227109.adsl.alicedsl.de ([92.231.227.109]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 05 Apr 2014 16:53:16 +0200 Original-Received: from tjolitz by g231227109.adsl.alicedsl.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 05 Apr 2014 16:53:16 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 33 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: g231227109.adsl.alicedsl.de User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:s+DXl6+yQDByjC1zrwdQUcg0kEI= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:97011 Archived-At: Stefan Monnier writes: >>> 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? > set buffer-undo-list to nil (after all, so you really want the user to > be able to un-insert the initial text?). No, I don't, and the simplest solutions are often the best but don't come to ones mind first. That works like a charm, thanks. -- cheers, Thorsten