From 165ce95288a0b2652f009bf8571b01d491b229c6 Mon Sep 17 00:00:00 2001 From: CToID Date: Sat, 13 Jul 2024 03:04:26 +0800 Subject: [PATCH] Option to control Emacs' behaviour when invoked with file args. --- lisp/startup.el | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lisp/startup.el b/lisp/startup.el index f18795a..ef135ed 100644 --- a/lisp/startup.el +++ b/lisp/startup.el @@ -62,6 +62,14 @@ initial-buffer-choice (const :tag "Lisp scratch buffer" t)) :version "23.1") +(defcustom show-initial-buffer-choice nil + "Controls the behaviour of Emacs when started with one file argument given. + +Non-nil means also display the buffer specified in +`initial-buffer-choice' in other window when Emacs is started with one +file argument." + :type 'boolean) + (defvaralias 'inhibit-splash-screen 'inhibit-startup-screen) (defvaralias 'inhibit-startup-message 'inhibit-startup-screen) @@ -2837,7 +2845,10 @@ command-line-1 (error "`initial-buffer-choice' must be a string, a function, or t"))))) (unless (buffer-live-p buf) (error "Value returned by `initial-buffer-choice' is not a live buffer: %S" buf)) - (setq displayable-buffers (cons buf (delq buf displayable-buffers))))) + + (when (or (zerop (length displayable-buffers)) + show-initial-buffer-choice) + (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.43.0