From debbugs-submit-bounces@debbugs.gnu.org Fri Jan 05 19:37:01 2018 Received: (at submit) by debbugs.gnu.org; 6 Jan 2018 00:37:01 +0000 Received: from localhost ([127.0.0.1]:37436 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eXcTt-0004Xt-Ck for submit@debbugs.gnu.org; Fri, 05 Jan 2018 19:37:01 -0500 Received: from eggs.gnu.org ([208.118.235.92]:50770) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eXcTr-0004Xg-Hg for submit@debbugs.gnu.org; Fri, 05 Jan 2018 19:36:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eXcTk-0000nm-Ve for submit@debbugs.gnu.org; Fri, 05 Jan 2018 19:36:54 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=BAYES_40,FREEMAIL_FROM, T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:44818) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eXcTk-0000nB-Ob for submit@debbugs.gnu.org; Fri, 05 Jan 2018 19:36:52 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41734) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eXcTj-0005vd-9S for bug-gnu-emacs@gnu.org; Fri, 05 Jan 2018 19:36:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eXcTf-0000f3-1E for bug-gnu-emacs@gnu.org; Fri, 05 Jan 2018 19:36:51 -0500 Received: from mail-pl0-x244.google.com ([2607:f8b0:400e:c01::244]:41324) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eXcTe-0000dU-Jp for bug-gnu-emacs@gnu.org; Fri, 05 Jan 2018 19:36:46 -0500 Received: by mail-pl0-x244.google.com with SMTP id g2so4031970pli.8 for ; Fri, 05 Jan 2018 16:36:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:subject:to:message-id:date:user-agent:mime-version :content-transfer-encoding:content-language; bh=GXgO9ZQlE1S8ouMcDOV+zWaV3WwhD2Y3HE9+nBmJduY=; b=gE98z4kDVc8KtnqjRNVEYcR1IXFNZz6EL3UpOSxuZdslUpZykDCFdJz58lXYZ//Fp2 nhRgKFIe6FqoExKKL4XqJiM4tgOQY/ccyYfibMIvAqhnEBq2GbVXawgTcSnwP1i31Ym1 7FuFrV66KiWktzueT5+TerRrFQuCA93Nwk1I9WIqkwv90lI/2AJ6O7nAP+jTx4C7ZPFX 19C+l6iaIVI3l8UEdNVHIRUfHTU0EiwPKKPAinAb1wI56XOQSbwxTHDrGWoAHwFk0Avz VznAsWyWO6yc95f0xP1eAhhiZjzZg9PmMzM9ROczUFdDtMCWwyEPge6bzuJqo07yLYIq s9xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:message-id:date:user-agent :mime-version:content-transfer-encoding:content-language; bh=GXgO9ZQlE1S8ouMcDOV+zWaV3WwhD2Y3HE9+nBmJduY=; b=iooKtCUATzLzKKOD4cmi4gd5K7Gg+ObwYge7bpSOsoWYkZMhAcB7JHg1bpTeoa6o3y sOg2GtmfZDIQFTJwAu33EjNGngsP/0avrqeqHMIXrs4OYEt+qlnmgwui34h9aIJjHHkr R7sjIINdvBQWqLdGCYszGDRn04YQ7giMo/h3DIpZnhVuBQvPBGddlT85hOll5UDssyjm C0OG0O5c8cFjFPc4/fG+Upw1v3JNCiyP8Ff/JiYBifPINvQuWahmXC/ZwhZEDq9zRckq 6qsvR0TNibr6QTlLDSnIXozA/TBDxsBuep/Z7SzHLGwUR5KfWcu3WyHt8JhV/vbF5Int XlkQ== X-Gm-Message-State: AKGB3mLHeAPBqKRTJaXFRvl9/yVJG161fv5e0KEWCAg3Ixhyo+hk+mZJ xVQrDB+mfauOg/CVeGxN7oKEdg== X-Google-Smtp-Source: ACJfBosNgx5sYgXRkWxzkrJ1dkolSFRWJPWkxr/ofCtIBht9AZQMqx8ljZMLwmUPV1Qf2H1Vp3FVyQ== X-Received: by 10.84.252.10 with SMTP id x10mr4601187pll.289.1515199004655; Fri, 05 Jan 2018 16:36:44 -0800 (PST) Received: from [192.168.178.61] (210-84-53-66.dyn.iinet.net.au. [210.84.53.66]) by smtp.googlemail.com with ESMTPSA id l80sm13989564pfk.67.2018.01.05.16.36.43 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 Jan 2018 16:36:43 -0800 (PST) From: David Beswick Subject: `initial-buffer-choice' function can result in duplicate buffer display To: bug-gnu-emacs@gnu.org Message-ID: <5594011c-2604-8cc1-036e-8f828aaf73c8@gmail.com> Date: Sat, 6 Jan 2018 11:36:40 +1100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-AU X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.0 (----) Hello, just a minor bug relating to the behaviour of startup.el's `command-line-1' and the `initial-buffer-choice' variable. When an `initial-buffer-choice' function returns the head of the `displayable-buffers' list in `command-line-1' then Emacs starts with that same buffer visited in two windows. I would expect it should only be shown in a single window. To be concrete, I ran into this behavior as on startup I wanted to display a particular buffer that I create except when a file is given on the command line. In that case I want to visit the given file instead. The behavior can be reproduced by creating a file `bug-init.el': (require 'seq) (setq initial-buffer-choice       (lambda () (seq-some (lambda (b)                              (with-current-buffer b                                (and buffer-file-name b)))                            (buffer-list)))) And then running this command: $ emacs -Q -l bug-init.el bug-init.el On startup, bug-init.el will be visited in two different windows. My fix: ---  lisp/startup.el | 9 +++++++--  1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lisp/startup.el b/lisp/startup.el index 2855e7c31c..cef9108cdf 100644 --- a/lisp/startup.el +++ b/lisp/startup.el @@ -2486,7 +2486,12 @@ command-line-1           (insert (substitute-command-keys initial-scratch-message))           (set-buffer-modified-p nil)))) -    ;; Prepend `initial-buffer-choice' to `displayable-buffers'. +    ;; Prepend `initial-buffer-choice' to `displayable-buffers'. If +    ;; the buffer is already a member of that list then shift the +    ;; buffer to the head of the list. The shift behavior is intended +    ;; to prevent the same buffer being displayed in two windows when +    ;; an `initial-buffer-choice' function happens to return the head +    ;; of `displayable-buffers'.      (when initial-buffer-choice        (let ((buf               (cond ((stringp initial-buffer-choice) @@ -2499,7 +2504,7 @@ command-line-1                      (error "initial-buffer-choice must be a string, a function, or t.")))))          (unless (buffer-live-p buf)            (error "initial-buffer-choice is not a live buffer.")) -        (setq displayable-buffers (cons buf displayable-buffers)))) +        (setq displayable-buffers (cons buf (delq buf displayable-buffers)))))      ;; Display the first two buffers in `displayable-buffers'. If      ;; `initial-buffer-choice' is non-nil, its buffer will be the -- 2.14.1 From debbugs-submit-bounces@debbugs.gnu.org Tue Apr 17 17:56:00 2018 Received: (at 29999) by debbugs.gnu.org; 17 Apr 2018 21:56:00 +0000 Received: from localhost ([127.0.0.1]:58113 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1f8YZz-0002ML-RH for submit@debbugs.gnu.org; Tue, 17 Apr 2018 17:55:59 -0400 Received: from hermes.netfonds.no ([80.91.224.195]:39461) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1f8YZx-0002M6-Sb for 29999@debbugs.gnu.org; Tue, 17 Apr 2018 17:55:58 -0400 Received: from 46.67.12.60.tmi.telenormobil.no ([46.67.12.60] helo=corrigan) by hermes.netfonds.no with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1f8YZt-0005Kl-S0; Tue, 17 Apr 2018 23:55:55 +0200 Received: from larsi by corrigan with local (Exim 4.89) (envelope-from ) id 1f8YZn-00035H-Qh; Tue, 17 Apr 2018 23:55:47 +0200 From: Lars Ingebrigtsen To: David Beswick Subject: Re: bug#29999: `initial-buffer-choice' function can result in duplicate buffer display References: <5594011c-2604-8cc1-036e-8f828aaf73c8@gmail.com> Date: Tue, 17 Apr 2018 23:55:47 +0200 In-Reply-To: <5594011c-2604-8cc1-036e-8f828aaf73c8@gmail.com> (David Beswick's message of "Sat, 6 Jan 2018 11:36:40 +1100") Message-ID: <878t9lfqfw.fsf@mouse.gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 29999 Cc: 29999@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) David Beswick writes: > Hello, just a minor bug relating to the behaviour of startup.el's > `command-line-1' and the `initial-buffer-choice' variable. When an > `initial-buffer-choice' function returns the head of the > `displayable-buffers' list in `command-line-1' then Emacs starts with > that same buffer visited in two windows. I would expect it should only > be shown in a single window. > > To be concrete, I ran into this behavior as on startup I wanted to > display a particular buffer that I create except when a file is given > on the command line. In that case I want to visit the given file > instead. > > The behavior can be reproduced by creating a file `bug-init.el': Thanks; I've applied your patch to Emacs 27.1. But a note about the patch: It had been mangled by your mailer (all the spaces had been turned into non-breaking space), so I had to do it by hand, but hopefully I got it right. -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no From debbugs-submit-bounces@debbugs.gnu.org Tue Apr 17 17:56:00 2018 Received: (at control) by debbugs.gnu.org; 17 Apr 2018 21:56:00 +0000 Received: from localhost ([127.0.0.1]:58115 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1f8Ya0-0002MN-20 for submit@debbugs.gnu.org; Tue, 17 Apr 2018 17:56:00 -0400 Received: from hermes.netfonds.no ([80.91.224.195]:39466) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1f8YZy-0002M8-Cs for control@debbugs.gnu.org; Tue, 17 Apr 2018 17:55:58 -0400 Received: from 46.67.12.60.tmi.telenormobil.no ([46.67.12.60] helo=corrigan) by hermes.netfonds.no with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1f8YZw-0005LM-4T for control@debbugs.gnu.org; Tue, 17 Apr 2018 23:55:57 +0200 Received: from larsi by corrigan with local (Exim 4.89) (envelope-from ) id 1f8YZq-00035K-3G for control@debbugs.gnu.org; Tue, 17 Apr 2018 23:55:50 +0200 To: control@debbugs.gnu.org From: Lars Ingebrigtsen Subject: control message for bug #29999 Message-Id: Date: Tue, 17 Apr 2018 23:55:50 +0200 X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) tags 29999 fixed close 29999 From unknown Sun Sep 07 16:50:09 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Wed, 16 May 2018 11:24:12 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator