From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: martin rudalics Newsgroups: gmane.emacs.devel Subject: Re: insert-file-contents and format-decode Date: Tue, 03 Jul 2007 08:47:05 +0200 Message-ID: <4689F0E9.4070706@gmx.at> References: <4666BF5F.5030301@gmx.at> <46753850.2090708@gmx.at> <46778ACB.1000704@gmx.at> <467E47AF.1080702@gmx.at> <4680B80E.5090709@gmx.at> <468204BF.3000404@gmx.at> <46863A77.4030106@gmx.at> <4688B3F1.2080305@gmx.at> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1183445315 8244 80.91.229.12 (3 Jul 2007 06:48:35 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 3 Jul 2007 06:48:35 +0000 (UTC) Cc: emacs-devel@gnu.org To: rms@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Jul 03 08:48:34 2007 connect(): Connection refused 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 1I5cBb-00026z-Q0 for ged-emacs-devel@m.gmane.org; Tue, 03 Jul 2007 08:48:32 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1I5cBb-0003mH-DJ for ged-emacs-devel@m.gmane.org; Tue, 03 Jul 2007 02:48:31 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1I5cAx-0003EX-Ia for emacs-devel@gnu.org; Tue, 03 Jul 2007 02:47:51 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1I5cAw-0003E9-BP for emacs-devel@gnu.org; Tue, 03 Jul 2007 02:47:50 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1I5cAw-0003E4-6D for emacs-devel@gnu.org; Tue, 03 Jul 2007 02:47:50 -0400 Original-Received: from mail.gmx.net ([213.165.64.20]) by monty-python.gnu.org with smtp (Exim 4.60) (envelope-from ) id 1I5cAv-00067g-9K for emacs-devel@gnu.org; Tue, 03 Jul 2007 02:47:49 -0400 Original-Received: (qmail invoked by alias); 03 Jul 2007 06:47:48 -0000 Original-Received: from N897P008.adsl.highway.telekom.at (EHLO [62.47.56.8]) [62.47.56.8] by mail.gmx.net (mp033) with SMTP; 03 Jul 2007 08:47:48 +0200 X-Authenticated: #14592706 X-Provags-ID: V01U2FsdGVkX19adnAaA0taik5mnTMZxoeIv/18ynO029mN/nMDNX bHePiX/aRXtEcR User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: de-DE, de, en-us, en In-Reply-To: X-Y-GMX-Trusted: 0 X-detected-kernel: Linux 2.6, seldom 2.4 (older, 4) 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:74227 Archived-At: > ! (let (value size old-undo) > ! ;; Record only one undo entry for the insertion. Inhibit point-motion and > ! ;; modification hooks as with `insert-file-contents'. > ! (let ((inhibit-point-motion-hooks t) > ! (inhibit-modification-hooks t)) > ! ;; Don't bind `buffer-undo-list' to t here to assert that > ! ;; `insert-file-contents' may record whether the buffer was unmodified > ! ;; before. > ! (let ((format-alist nil)) > ! (setq value (insert-file-contents filename nil beg end)) > ! (setq size (nth 1 value))) > ! (when (consp buffer-undo-list) > ! (let ((head (car buffer-undo-list))) > ! (when (and (consp head) > ! (equal (car head) (point)) > ! (equal (cdr head) (+ (point) size))) > ! ;; Remove first entry from `buffer-undo-list', we shall insert > ! ;; another one below. > ! (setq old-undo (cdr buffer-undo-list))))) > > That pateh is basically good, but it could be simpler. Instead of > letting insert-file-contents produce an undo entry and taking it off > and taking it apart, it would be better to inhibit undo around > insert-file-contents and generate the undo entry from scratch in all > cases. When no format decoding is done, VALUE has the size you need. It's complicated because I may have to create the (t HIGH . LOW) entry to indicate that the buffer previously had "unmodified" status. With my solution I let `insert-file-contents' take care of that automatically. With your solution I would have to create it manually and care about the modification time myself. Is it worth the trouble?