(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)
(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