]> git.eshelyaron.com Git - emacs.git/commitdiff
Don't display an initial-buffer-choice buffer twice
authorDavid Beswick <dlbeswick@gmail.com>
Tue, 17 Apr 2018 21:53:55 +0000 (23:53 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Tue, 17 Apr 2018 21:54:14 +0000 (23:54 +0200)
* 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

index 1faeabf23b8cd8a2e9af46c37f19c28f7273a59a..f6907a821b99dcd81db455e7e511ce9f05a0736b 100644 (file)
@@ -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