From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Bill Wohler Newsgroups: gmane.emacs.devel Subject: Re: undo weirdness with insert-file-contents Date: Sun, 02 Mar 2008 14:18:31 -0800 Organization: Newt Software Message-ID: <12174.1204496311@olgas.newt.com> References: <47C70CFC.30203@gmx.at> <47C88A51.7020205@gmx.at> <47CAA13E.3040909@gmx.at> NNTP-Posting-Host: lo.gmane.org X-Trace: ger.gmane.org 1204496337 6389 80.91.229.12 (2 Mar 2008 22:18:57 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 2 Mar 2008 22:18:57 +0000 (UTC) Cc: martin rudalics , Miles Bader , emacs-devel@gnu.org, Glenn Morris To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Mar 02 23:19:21 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 1JVwWe-0006wf-Ts for ged-emacs-devel@m.gmane.org; Sun, 02 Mar 2008 23:19:21 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JVwW7-0002bO-RI for ged-emacs-devel@m.gmane.org; Sun, 02 Mar 2008 17:18:47 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JVwW2-0002aV-MD for emacs-devel@gnu.org; Sun, 02 Mar 2008 17:18:42 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JVwW1-0002a2-GC for emacs-devel@gnu.org; Sun, 02 Mar 2008 17:18:41 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JVwW1-0002Zz-BL for emacs-devel@gnu.org; Sun, 02 Mar 2008 17:18:41 -0500 Original-Received: from tassie.newt.com ([70.85.162.231]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JVwVt-0007nR-7B; Sun, 02 Mar 2008 17:18:33 -0500 Original-Received: from olgas.localdomain (h-68-164-242-205.snvacaid.dynamic.covad.net [68.164.242.205]) by tassie.newt.com (Postfix) with ESMTP id 071111D0245; Sun, 2 Mar 2008 14:18:30 -0800 (PST) Original-Received: by olgas.localdomain (Postfix, from userid 1000) id 5437E1FE68; Sun, 2 Mar 2008 14:18:31 -0800 (PST) Original-Received: from olgas.newt.com (localhost [127.0.0.1]) by olgas.localdomain (Postfix) with ESMTP id 4B61D1FE62; Sun, 2 Mar 2008 14:18:31 -0800 (PST) In-reply-to: Comments: In-reply-to Stefan Monnier message dated "Sun, 02 Mar 2008 14:07:20 -0500." X-Mailer: MH-E 8.0.3+cvs; nmh 1.2; GNU Emacs 22.1.1 X-Image-URL: http://www.newt.com/wohler/images/bill-diving.png Mail-Followup-To: emacs-devel@gnu.org X-detected-kernel: by monty-python.gnu.org: Linux 2.4-2.6 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:91112 Archived-At: Stefan Monnier wrote: > 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. I agree. The semantics of insert-file-contents seems to be identical to insert--only the text comes from a file rather than an argument. I'd therefore be against Martin's suggestion of inserting an undo boundary since that should be the caller's responsibility (typically, the command loop). Consider the following: (defun bw-foo () (insert "abc") (insert "def")) (defun bw-bar () (insert-file-contents "/etc/motd") (insert-file-contents "/etc/motd")) A single undo in either case will remove both insertions and reset buffer-modified-p to nil if that's what it was beforehand. There is, regrettably, a large difference between these two. Point is left where insert-file-contents was run rather than at the end of the inserted string as is the case with insert. Maybe we should consider fixing this at this time as well. Maybe this is the way it used to work, or maybe this is the way people expect it to work: I took a quick look at the MH-E code and many invocations of insert-file-contents are immediately followed by (goto-char (point-min)) before the inserted file is processed. -- Bill Wohler http://www.newt.com/wohler/ GnuPG ID:610BD9AD