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: Changing of line format and undo Date: Mon, 21 Aug 2006 12:17:40 -0400 Message-ID: <87lkpif4in.fsf-monnier+emacs@gnu.org> References: <44987375.2010000@student.lu.se> <449961F6.6020001@student.lu.se> <85mzc6y204.fsf@lola.goethe.zz> <44996AE1.7020907@student.lu.se> <858xnqxyg9.fsf@lola.goethe.zz> <4499781F.7090802@student.lu.se> <87k66wvx4u.fsf-monnier+emacs@gnu.org> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1156177091 10983 80.91.229.2 (21 Aug 2006 16:18:11 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 21 Aug 2006 16:18:11 +0000 (UTC) Cc: Lennart Borgman , Eli Zaretskii , emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Aug 21 18:18:06 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1GFCTU-0001lo-1V for ged-emacs-devel@m.gmane.org; Mon, 21 Aug 2006 18:18:04 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GFCTT-0000hX-CN for ged-emacs-devel@m.gmane.org; Mon, 21 Aug 2006 12:18:03 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GFCTF-0000ey-M2 for emacs-devel@gnu.org; Mon, 21 Aug 2006 12:17:49 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GFCTF-0000eQ-2j for emacs-devel@gnu.org; Mon, 21 Aug 2006 12:17:49 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GFCTE-0000e8-Tq for emacs-devel@gnu.org; Mon, 21 Aug 2006 12:17:48 -0400 Original-Received: from [12.46.53.131] (helo=alfajor) by monty-python.gnu.org with esmtp (Exim 4.52) id 1GFCad-0000fi-0z; Mon, 21 Aug 2006 12:25:27 -0400 Original-Received: by alfajor (Postfix, from userid 1000) id 484251C159; Mon, 21 Aug 2006 12:17:40 -0400 (EDT) Original-To: storm@cua.dk (Kim F. Storm) In-Reply-To: (Kim F. Storm's message of "Mon, 21 Aug 2006 16:27:56 +0200") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) 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:58648 Archived-At: > RMS agreed to install the following change in Emacs 22. Oh, did he? I must have missed it. If you want to install it, then please go ahead (I'm on the road right now). Otherwise I'll get to it later. Thanks, Stefan > Stefan Monnier writes: >>> Thanks, you are right ;-) Now I see what Eli meant. I still believe that >>> everything that can result in changing an external file should go into the >>> undo history but this is really a corner case of course. >> >> You can change C-x RET f to do what you want by having it add (manually in >> elisp) an `apply' entry to buufer-undo-list. >> >> E.g. I've changed my set-buffer-multibyte to do that (waiting for post-22 >> to commit it). >> >> >> Stefan >> >> >> --- orig/src/buffer.c >> +++ mod/src/buffer.c >> @@ -2112,10 +2100,11 @@ >> { >> struct Lisp_Marker *tail, *markers; >> struct buffer *other; >> - int undo_enabled_p = !EQ (current_buffer->undo_list, Qt); >> int begv, zv; >> int narrowed = (BEG != BEGV || Z != ZV); >> int modified_p = !NILP (Fbuffer_modified_p (Qnil)); >> + Lisp_Object old_undo = current_buffer->undo_list; >> + struct gcpro gcpro1; >> >> if (current_buffer->base_buffer) >> error ("Cannot do `set-buffer-multibyte' on an indirect buffer"); >> @@ -2124,10 +2113,11 @@ >> if (NILP (flag) == NILP (current_buffer->enable_multibyte_characters)) >> return flag; >> >> - /* It would be better to update the list, >> - but this is good enough for now. */ >> - if (undo_enabled_p) >> - current_buffer->undo_list = Qt; >> + GCPRO1 (old_undo); >> + >> + /* Don't record these buffer changes. We will put a special undo entry >> + instead. */ >> + current_buffer->undo_list = Qt; >> >> /* If the cached position is for this buffer, clear it out. */ >> clear_charpos_cache (current_buffer); >> @@ -2327,8 +2317,18 @@ >> set_intervals_multibyte (1); >> } >> >> - if (undo_enabled_p) >> - current_buffer->undo_list = Qnil; >> + if (!EQ (old_undo, Qt)) >> + { >> + /* Represent all the above changes by a special undo entry. */ >> + extern Lisp_Object Qapply; >> + Lisp_Object args[3]; >> + args[0] = Qapply; >> + args[1] = Qset_buffer_multibyte; >> + args[2] = NILP (flag) ? Qt : Qnil; >> + current_buffer->undo_list = Fcons (Flist (3, args), old_undo); >> + } >> + >> + UNGCPRO; >> >> /* Changing the multibyteness of a buffer means that all windows >> showing that buffer must be updated thoroughly. */ > -- > Kim F. Storm http://www.cua.dk