From 2e54ffebb8555d23f72c7b450b481f0335562b0d Mon Sep 17 00:00:00 2001 From: David Beswick Date: Tue, 17 Apr 2018 23:53:55 +0200 Subject: [PATCH] Don't display an initial-buffer-choice buffer twice * lisp/startup.el (command-line-1): Don't display an initial-buffer-choice buffer twice if the user is also explicitly specifying it on the mode line, but shift it to the initial place (bug#29999). Copyright-paperwork-exempt: yes --- lisp/startup.el | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lisp/startup.el b/lisp/startup.el index 1faeabf23b8..f6907a821b9 100644 --- a/lisp/startup.el +++ b/lisp/startup.el @@ -2504,7 +2504,12 @@ nil default-directory" name) (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) @@ -2517,7 +2522,7 @@ nil default-directory" name) (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.39.5