From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Richard Stallman Newsgroups: gmane.emacs.devel Subject: Re: undo in loaddefs.el buffer Date: Sun, 26 Dec 2004 23:09:30 -0500 Message-ID: References: <200412211414.iBLEEZ903426@raven.dms.auburn.edu> <200412211541.iBLFfBc03861@raven.dms.auburn.edu> <87llbonyup.fsf@jurta.org> <87ekhdk9iw.fsf@jurta.org> Reply-To: rms@gnu.org NNTP-Posting-Host: deer.gmane.org X-Trace: sea.gmane.org 1104120944 2395 80.91.229.6 (27 Dec 2004 04:15:44 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 27 Dec 2004 04:15:44 +0000 (UTC) Cc: yamaoka@jpl.org, teirllm@dms.auburn.edu, emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Dec 27 05:15:36 2004 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1CimIC-0006sa-00 for ; Mon, 27 Dec 2004 05:15:36 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CimSy-00046D-FT for ged-emacs-devel@m.gmane.org; Sun, 26 Dec 2004 23:26:44 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1CimSi-00043q-18 for emacs-devel@gnu.org; Sun, 26 Dec 2004 23:26:28 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1CimSg-00043F-Rc for emacs-devel@gnu.org; Sun, 26 Dec 2004 23:26:27 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CimSf-00042b-UK for emacs-devel@gnu.org; Sun, 26 Dec 2004 23:26:26 -0500 Original-Received: from [199.232.76.164] (helo=fencepost.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.34) id 1CimHj-0004Qt-PZ for emacs-devel@gnu.org; Sun, 26 Dec 2004 23:15:07 -0500 Original-Received: from rms by fencepost.gnu.org with local (Exim 4.34) id 1CimCI-0003Du-75; Sun, 26 Dec 2004 23:09:30 -0500 Original-To: Juri Linkov In-reply-to: <87ekhdk9iw.fsf@jurta.org> (message from Juri Linkov on Sun, 26 Dec 2004 04:43:11 +0200) 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: main.gmane.org gmane.emacs.devel:31429 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:31429 The question is asked after `decode-coding-region' is called from `decode-coding-inserted-region' from `jka-compr-insert-file-contents'. Perhaps undo should be disabled temporarily in `jka-compr-insert-file-contents' during visiting a gzipped file, but not permanently because buffers of gzipped files are editable. Does this replacement function make it work right? It is designed to make buffer-undo-list empty in the case of visiting a file, and optimize it in the other case. (defun decode-coding-inserted-region (from to filename &optional visit beg end replace) "Decode the region between FROM and TO as if it is read from file FILENAME. Optional arguments VISIT, BEG, END, and REPLACE are the same as those of the function `insert-file-contents'." (save-excursion (save-restriction (let ((coding coding-system-for-read) undo-list-saved) (if visit ;; Temporarily turn off undo recording, if we're decoding the ;; text of a visited file. (setq buffer-undo-list t) ;; Otherwise, if we can recognize the undo elt for the insertion, ;; remove it and get ready to replace it later. ;; In the mean time, turn off undo recording. (let ((last (car buffer-undo-list))) (if (and (consp last) (eql (car last) from) (eql (cdr last) to)) (setq undo-list-saved (cdr buffer-undo-list) buffer-undo-list t)))) (narrow-to-region from to) (goto-char (point-min)) (or coding (setq coding (funcall set-auto-coding-function filename (- (point-max) (point-min))))) (or coding (setq coding (car (find-operation-coding-system 'insert-file-contents filename visit beg end replace)))) (if (coding-system-p coding) (or enable-multibyte-characters (setq coding (coding-system-change-text-conversion coding 'raw-text))) (setq coding nil)) (if coding (decode-coding-region (point-min) (point-max) coding) (setq last-coding-system-used coding)) ;; If we're decoding the text of a visited file, ;; the undo list should start out empty. (if visit (setq buffer-undo-list nil) ;; If we decided to replace the undo entry for the insertion, ;; do so now. (if undo-list-saved (setq buffer-undo-list (cons (cons from (point-max)) undo-list-saved))))))))