emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 69c3ae2969: Make `next-buffer' order reflect command line file or


From: Lars Ingebrigtsen
Subject: master 69c3ae2969: Make `next-buffer' order reflect command line file order
Date: Mon, 21 Feb 2022 09:44:46 -0500 (EST)

branch: master
commit 69c3ae29692e031296ef0ef4f56808dba4c6c27d
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Make `next-buffer' order reflect command line file order
    
    * lisp/startup.el (command-line-1): Make `next-buffer' order
    reflect the command line file order (bug#21505).
---
 lisp/startup.el | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/lisp/startup.el b/lisp/startup.el
index 6b9b8234c7..9f0b23c904 100644
--- a/lisp/startup.el
+++ b/lisp/startup.el
@@ -2798,10 +2798,24 @@ nil default-directory" name)
           (nondisplayed-buffers-p nil))
       (when (> displayable-buffers-len 0)
         (switch-to-buffer (car displayable-buffers)))
-      (when (> displayable-buffers-len 1)
-        (switch-to-buffer-other-window (car (cdr displayable-buffers)))
+      (cond
+       ;; Two buffers; display them both.
+       ((= displayable-buffers-len 2)
+        (switch-to-buffer-other-window (cadr displayable-buffers))
         ;; Focus on the first buffer.
         (other-window -1))
+       ;; More than two buffers: Ensure that the buffer display order
+       ;; reflects the order they were given on the command line.
+       ;; (This will end up with a `next-buffer' order that's in
+       ;; reverse order -- the final file is the focused one, and then
+       ;; the rest are in `next-buffer' in descending order.
+       ((> displayable-buffers-len 2)
+        (let ((bufs (reverse (cdr displayable-buffers))))
+          (switch-to-buffer-other-window (pop bufs))
+          (dolist (buf bufs)
+            (switch-to-buffer buf nil t))
+          ;; Focus on the first buffer.
+          (other-window -1))))
       (when (> displayable-buffers-len 2)
         (setq nondisplayed-buffers-p t))
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]