From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stephen Berman Newsgroups: gmane.emacs.bugs,gmane.emacs.pretest.bugs Subject: bug#4851: 23.1.50; narrowing, indirect buffers and set-buffer Date: Mon, 02 Nov 2009 15:49:37 +0100 Message-ID: <87hbtd0yny.fsf@escher.local.home> Reply-To: Stephen Berman , 4851@emacsbugs.donarmstrong.com NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1257174458 14271 80.91.229.12 (2 Nov 2009 15:07:38 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 2 Nov 2009 15:07:38 +0000 (UTC) To: emacs-pretest-bug@gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Nov 02 16:07:31 2009 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1N4yVG-0008AQ-PL for geb-bug-gnu-emacs@m.gmane.org; Mon, 02 Nov 2009 16:07:31 +0100 Original-Received: from localhost ([127.0.0.1]:41298 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N4yVG-0006sd-7R for geb-bug-gnu-emacs@m.gmane.org; Mon, 02 Nov 2009 10:07:30 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N4yVA-0006rf-Ao for bug-gnu-emacs@gnu.org; Mon, 02 Nov 2009 10:07:24 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N4yV5-0006oc-9g for bug-gnu-emacs@gnu.org; Mon, 02 Nov 2009 10:07:23 -0500 Original-Received: from [199.232.76.173] (port=42511 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N4yV5-0006oV-3b for bug-gnu-emacs@gnu.org; Mon, 02 Nov 2009 10:07:19 -0500 Original-Received: from rzlab.ucr.edu ([138.23.92.77]:42555) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1N4yV4-0001Sd-FS for bug-gnu-emacs@gnu.org; Mon, 02 Nov 2009 10:07:18 -0500 Original-Received: from rzlab.ucr.edu (rzlab.ucr.edu [127.0.0.1]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id nA2F7FhB029128; Mon, 2 Nov 2009 07:07:16 -0800 Original-Received: (from debbugs@localhost) by rzlab.ucr.edu (8.14.3/8.14.3/Submit) id nA2Et5CI027353; Mon, 2 Nov 2009 06:55:05 -0800 Resent-Date: Mon, 2 Nov 2009 06:55:05 -0800 X-Loop: owner@emacsbugs.donarmstrong.com Resent-From: Stephen Berman Original-Sender: steve@escher.local.home Resent-To: bug-submit-list@donarmstrong.com Resent-CC: Emacs Bugs 2Resent-Date: Mon, 02 Nov 2009 14:55:05 +0000 Resent-Message-ID: Resent-Sender: owner@emacsbugs.donarmstrong.com X-Emacs-PR-Message: report 4851 X-Emacs-PR-Package: emacs X-Emacs-PR-Keywords: Original-Received: via spool by submit@emacsbugs.donarmstrong.com id=B.125717339326838 (code B ref -1); Mon, 02 Nov 2009 14:55:05 +0000 Original-Received: (at submit) by emacsbugs.donarmstrong.com; 2 Nov 2009 14:49:53 +0000 X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. Original-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 Original-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 Original-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 Original-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 Original-Received: (qmail invoked by alias); 02 Nov 2009 14:49:43 -0000 Original-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 Original-Received: by escher.local.home (Postfix, from userid 1000) id 733A41D0B79; Mon, 2 Nov 2009 15:49:37 +0100 (CET) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux) X-Y-GMX-Trusted: 0 X-FuHaFi: 0.5 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Resent-Date: Mon, 02 Nov 2009 10:07:23 -0500 X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:32371 gmane.emacs.pretest.bugs:25158 Archived-At: 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