From stephen.berman@gmx.net Mon Nov 2 06:49:53 2009 Received: (at submit) by emacsbugs.donarmstrong.com; 2 Nov 2009 14:49:53 +0000 X-Spam-Checker-Version: SpamAssassin 3.2.5-bugs.debian.org_2005_01_02 (2008-06-10) on rzlab.ucr.edu X-Spam-Level: X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. X-Spam-Status: No, score=-1.7 required=4.0 tests=AWL,FOURLA autolearn=no version=3.2.5-bugs.debian.org_2005_01_02 Received: from fencepost.gnu.org (fencepost.gnu.org [140.186.70.10]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id nA2EnpHR026835 for ; Mon, 2 Nov 2009 06:49:53 -0800 Received: from mail.gnu.org ([199.232.76.166]:42179 helo=mx10.gnu.org) by fencepost.gnu.org with esmtp (Exim 4.67) (envelope-from ) id 1N4yEB-0006Hx-Gf for emacs-pretest-bug@gnu.org; Mon, 02 Nov 2009 09:49:51 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1N4yE7-00072v-Fk for emacs-pretest-bug@gnu.org; Mon, 02 Nov 2009 09:49:51 -0500 Received: from mail.gmx.net ([213.165.64.20]:60394) by monty-python.gnu.org with smtp (Exim 4.60) (envelope-from ) id 1N4yE6-000723-Te for emacs-pretest-bug@gnu.org; Mon, 02 Nov 2009 09:49:47 -0500 Received: (qmail invoked by alias); 02 Nov 2009 14:49:43 -0000 Received: from i59F56ABD.versanet.de (EHLO escher.local.home) [89.245.106.189] by mail.gmx.net (mp003) with SMTP; 02 Nov 2009 15:49:43 +0100 X-Authenticated: #20778731 X-Provags-ID: V01U2FsdGVkX18/WuorUhA/ipGg11c6W7qEwn7PRQOR8yrT+LAGyP iQWQDdTXhiBDbk Received: by escher.local.home (Postfix, from userid 1000) id 733A41D0B79; Mon, 2 Nov 2009 15:49:37 +0100 (CET) From: Stephen Berman To: emacs-pretest-bug@gnu.org Subject: 23.1.50; narrowing, indirect buffers and set-buffer Sender: steve@escher.local.home Date: Mon, 02 Nov 2009 15:49:37 +0100 Message-ID: <87hbtd0yny.fsf@escher.local.home> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Y-GMX-Trusted: 0 X-FuHaFi: 0.5 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) 1. emacs -Q 2. C-x b bla RET 3. M-: (insert "This is a test.") 4. M-: (narrow-to-region 5 10) => buffer "bla" now displays " is a" 5. M-: (make-indirect-buffer (current-buffer) "blip") 6. M-: (save-restriction (widen) (set-buffer (get-buffer-create "bloop"))) => buffer "bla" now displays "This is a test." Contrast the above with (after killing buffer "bla") the same steps 1-4 and then step 6, i.e., leaving out step 5: then narrowing in "bla" remains in effect. So calling make-indirect-buffer appeared to disable save-restriction when it contains a set-buffer call. There is an apparently relevant passage in (elisp)Current Buffer: *Warning:* Lisp functions that change to a different current buffer should not depend on the command loop to set it back afterwards. Editing commands written in Emacs Lisp can be called from other programs as well as from the command loop; it is convenient for the caller if the subroutine does not change which buffer is current (unless, of course, that is the subroutine's purpose). Therefore, you should normally use `set-buffer' within a `save-current-buffer' or `save-excursion' (*note Excursions::) form that will restore the current buffer when your function is done. And indeed, if step 6 above (i.e., after make-indirect-buffer) is replaced by this: 6.' M-: (save-restriction (save-current-buffer (widen) (set-buffer (get-buffer-create "bloop")))) or by this: 6.'' M-: (save-restriction (save-excursion (widen) (set-buffer (get-buffer-create "bloop")))) then the narrowing in "bla" still remains in effect (also if the call to widen is between save-restriction and save-current-buffer/save-excursion). So perhaps the failure of narrowing to remain in effect above is not a bug but a programming error, which should be correctly written as 6' or 6''. But I'm not sure, since the failure only happens after calling make-indirect-buffer, which is not what I would expect from the passage in the Elisp manual quoted above. If this is not an Emacs bug can someone explain why the failure of narrowing to remain in effect is only triggered by make-indirect-buffer? In GNU Emacs 23.1.50.1 (i686-pc-linux-gnu, GTK+ Version 2.14.4) of 2009-10-27 on escher Windowing system distributor `The X.Org Foundation', version 11.0.10502000 Important settings: value of $LC_ALL: nil value of $LC_COLLATE: nil value of $LC_CTYPE: nil value of $LC_MESSAGES: nil value of $LC_MONETARY: nil value of $LC_NUMERIC: nil value of $LC_TIME: nil value of $LANG: en_US.UTF-8 value of $XMODIFIERS: @im=local locale-coding-system: utf-8-unix default enable-multibyte-characters: t From monnier@IRO.UMontreal.CA Tue Nov 3 13:34:32 2009 Received: (at submit) by emacsbugs.donarmstrong.com; 3 Nov 2009 21:34:32 +0000 X-Spam-Checker-Version: SpamAssassin 3.2.5-bugs.debian.org_2005_01_02 (2008-06-10) on rzlab.ucr.edu X-Spam-Level: X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. X-Spam-Status: No, score=-3.9 required=4.0 tests=AWL,FOURLA,FVGT_m_MULTI_ODD, HAS_BUG_NUMBER,MURPHY_DRUGS_REL8 autolearn=unavailable version=3.2.5-bugs.debian.org_2005_01_02 Received: from fencepost.gnu.org (fencepost.gnu.org [140.186.70.10]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id nA3LYVSa030371 for ; Tue, 3 Nov 2009 13:34:32 -0800 Received: from mail.gnu.org ([199.232.76.166]:60598 helo=mx10.gnu.org) by fencepost.gnu.org with esmtp (Exim 4.67) (envelope-from ) id 1N5R1K-0000ak-55 for emacs-pretest-bug@gnu.org; Tue, 03 Nov 2009 16:34:30 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1N5R1I-0002Kv-SX for emacs-pretest-bug@gnu.org; Tue, 03 Nov 2009 16:34:29 -0500 Received: from chene.dit.umontreal.ca ([132.204.246.20]:54173) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1N5R1H-0002KM-24 for emacs-pretest-bug@gnu.org; Tue, 03 Nov 2009 16:34:27 -0500 Received: from faina.iro.umontreal.ca (faina.iro.umontreal.ca [132.204.26.177]) by chene.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id nA3LYKFQ020024; Tue, 3 Nov 2009 16:34:20 -0500 Received: by faina.iro.umontreal.ca (Postfix, from userid 20848) id B34C13A036; Tue, 3 Nov 2009 16:34:20 -0500 (EST) From: Stefan Monnier To: Stephen Berman Cc: 4851@debbugs.gnu.org, emacs-pretest-bug@gnu.org Subject: Re: bug#4851: 23.1.50; narrowing, indirect buffers and set-buffer Message-ID: References: <87hbtd0yny.fsf@escher.local.home> Date: Tue, 03 Nov 2009 16:34:20 -0500 In-Reply-To: <87hbtd0yny.fsf@escher.local.home> (Stephen Berman's message of "Mon, 02 Nov 2009 15:49:37 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 1 Rules triggered RV3398=0 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) X-CrossAssassin-Score: 2 > 1. emacs -Q > 2. C-x b bla RET > 3. M-: (insert "This is a test.") > 4. M-: (narrow-to-region 5 10) > => buffer "bla" now displays " is a" > 5. M-: (make-indirect-buffer (current-buffer) "blip") > 6. M-: (save-restriction > (widen) > (set-buffer (get-buffer-create "bloop"))) > => buffer "bla" now displays "This is a test." Thanks! I finally tracked this bug down. Sadly, I think this points out a more general problem, so while the patch below fixes it, we probably have several other related bugs. Stefan --- src/editfns.c 19 Oct 2009 04:27:14 -0000 1.473 +++ src/editfns.c 3 Nov 2009 21:32:41 -0000 @@ -3275,12 +3275,26 @@ save_restriction_restore (data) Lisp_Object data; { + struct buffer *cur = NULL; + struct buffer *buf = (CONSP (data) + ? XMARKER (XCAR (data))->buffer + : XBUFFER (data)); + + if (buf && buf != current_buffer && !NILP (buf->pt_marker)) + { /* If `buf' uses markers to keep track of PT, BEGV, and ZV (as + is the case if it is or has an indirect buffer), then make + sure it is current before we update BEGV, so + set_buffer_internal takes care of managing those markers. */ + cur = current_buffer; + set_buffer_internal (buf); + } + if (CONSP (data)) /* A pair of marks bounding a saved restriction. */ { struct Lisp_Marker *beg = XMARKER (XCAR (data)); struct Lisp_Marker *end = XMARKER (XCDR (data)); - struct buffer *buf = beg->buffer; /* END should have the same buffer. */ + eassert (buf == end->buffer); if (buf /* Verify marker still points to a buffer. */ && (beg->charpos != BUF_BEGV (buf) || end->charpos != BUF_ZV (buf))) @@ -3305,8 +3319,6 @@ else /* A buffer, which means that there was no old restriction. */ { - struct buffer *buf = XBUFFER (data); - if (buf /* Verify marker still points to a buffer. */ && (BUF_BEGV (buf) != BUF_BEG (buf) || BUF_ZV (buf) != BUF_Z (buf))) /* The buffer has been narrowed, get rid of the narrowing. */ @@ -3318,6 +3330,9 @@ } } + if (cur) + set_buffer_internal (cur); + return Qnil; } From rgm@gnu.org Mon Nov 9 18:27:36 2009 Received: (at control) by emacsbugs.donarmstrong.com; 10 Nov 2009 02:27:37 +0000 X-Spam-Checker-Version: SpamAssassin 3.2.5-bugs.debian.org_2005_01_02 (2008-06-10) on rzlab.ucr.edu X-Spam-Level: X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. X-Spam-Status: No, score=-2.8 required=4.0 tests=AWL,ONEWORD autolearn=no version=3.2.5-bugs.debian.org_2005_01_02 Received: from fencepost.gnu.org (fencepost.gnu.org [140.186.70.10]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id nAA2RZqr024665 for ; Mon, 9 Nov 2009 18:27:36 -0800 Received: from rgm by fencepost.gnu.org with local (Exim 4.67) (envelope-from ) id 1N7gSE-0001Vw-0Y; Mon, 09 Nov 2009 21:27:34 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <19192.53141.924423.83698@fencepost.gnu.org> Date: Mon, 9 Nov 2009 21:27:33 -0500 From: Glenn Morris To: control Subject: control close 4851 close 4868 tags 4856 moreinfo severity 4869 minor retitle 4887 globalized-minor-modes in new fundamental mode buffers From unknown Sun Aug 17 01:42:34 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Tue, 08 Dec 2009 15:24:12 +0000 User-Agent: Fakemail v42.6.9 # A New Hope # A long time ago, in a galaxy far, far away # something happened. # # Magically this resulted in the following # action being taken, but this fake control # message doesn't tell you why it happened # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator