From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: undo weirdness with insert-file-contents Date: Sun, 02 Mar 2008 14:07:20 -0500 Message-ID: References: <47C70CFC.30203@gmx.at> <47C88A51.7020205@gmx.at> <47CAA13E.3040909@gmx.at> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1204484861 4885 80.91.229.12 (2 Mar 2008 19:07:41 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 2 Mar 2008 19:07:41 +0000 (UTC) Cc: Glenn Morris , emacs-devel@gnu.org, Bill Wohler , Miles Bader To: martin rudalics Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Mar 02 20:08:07 2008 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1JVtXb-0000K8-3N for ged-emacs-devel@m.gmane.org; Sun, 02 Mar 2008 20:08:07 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JVtX4-0005tk-4H for ged-emacs-devel@m.gmane.org; Sun, 02 Mar 2008 14:07:34 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JVtX0-0005tR-0y for emacs-devel@gnu.org; Sun, 02 Mar 2008 14:07:30 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JVtWz-0005t9-BZ for emacs-devel@gnu.org; Sun, 02 Mar 2008 14:07:29 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JVtWz-0005t2-1j for emacs-devel@gnu.org; Sun, 02 Mar 2008 14:07:29 -0500 Original-Received: from ironport2-out.pppoe.ca ([206.248.154.182]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JVtWr-0003WP-Sc; Sun, 02 Mar 2008 14:07:21 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ao8CAGaJykdMCrW2/2dsb2JhbACrH4EA X-IronPort-AV: E=Sophos;i="4.25,435,1199682000"; d="scan'208";a="15462391" Original-Received: from smtp.pppoe.ca ([65.39.196.238]) by ironport2-out.pppoe.ca with ESMTP; 02 Mar 2008 14:07:20 -0500 Original-Received: from pastel.home ([76.10.181.182]) by smtp.pppoe.ca (Internet Mail Server v1.0) with ESMTP id IWJ74720; Sun, 02 Mar 2008 14:07:20 -0500 Original-Received: by pastel.home (Postfix, from userid 20848) id 508D68279; Sun, 2 Mar 2008 14:07:20 -0500 (EST) In-Reply-To: <47CAA13E.3040909@gmx.at> (martin rudalics's message of "Sun, 02 Mar 2008 13:44:46 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) X-detected-kernel: by monty-python.gnu.org: Genre and OS details not recognized. X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:91089 Archived-At: > the empty_undo_list check at all. BTW, what is the semantics of > `insert-file-contents' with VISIT nil and REPLACE non-nil? It seems obvious to me that it's similar to "delete + insert". So I guess I don't understand the question quite right. I use this kind of call to insert-file-contents in smerge-resolve, if you want to see an example. >> Also if the file is empty, is this going to mark the buffer as modified >> even though nothing was changed? > I'm afraid I don't understand the question - do you mean the case where > inserted equals zero? Yes. > I don't handle that. What does that mean? Are you going to mark the buffer as modified? > + /* Else if the present insertion is the very first change of the > + current buffer, undo information is recorded, and we are > + neither visiting a file nor replacing buffer contents, make > + sure we record the insertion as a first change in the > + undo-list. This is needed in order to avoid that undoing the > + insertion leaves the buffer's modified state set. */ > + { > + current_buffer->undo_list = Qnil; > + record_first_change (); > + } Normally record_first_change is called "automatically" elsewhere. So why is it needed here? The handling of the undo-list and modified-p status in insert-file-contents is a real mess. It'd be good to take a step back and think about how it *should* work. E.g. I don't think insert-file-contents should mess with modified-p: it should behave just like a normal `insert' in this respect. Stefan