all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: CToID via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: 72089@debbugs.gnu.org
Subject: bug#72089: [PATCH] Option to control Emacs' behaviour when invoked with file args.
Date: Sat, 13 Jul 2024 03:18:04 +0800	[thread overview]
Message-ID: <32450bf6-4672-4357-8632-a536c774b6ab@yahoo.com.tw> (raw)
In-Reply-To: 32450bf6-4672-4357-8632-a536c774b6ab.ref@yahoo.com.tw

[-- Attachment #1: Type: text/plain, Size: 805 bytes --]

Hello folks,

So I have a discussion with Eli on help-gnu-emacs mailing list earlier 
(https://lists.gnu.org/archive/html/help-gnu-emacs/2024-07/msg00124.html) 
about Emacs' initial buffer behaviour when invoked with file arguments.

Overall, I think it's benefitial to have a custom option for users to 
control this behaviour of Emacs, so I made some simple changes to 
accomplish this.

In GNU Emacs 30.0.60 (build 4, x86_64-pc-linux-gnu, GTK+ Version
  3.24.41, cairo version 1.18.0) of 2024-07-13 built on thinkpad-btw
Repository revision: 8b1a0f8695a43e74daa5275559267e96c14aba03
Repository branch: bruh
System Description: Ubuntu 24.04 LTS

Configured using:
  'configure --prefix=/home/id/.local --with-tree-sitter
  --with-native-compilation --with-pgtk 'CFLAGS=-O2 -march=native''

---
Best,
ID

[-- Attachment #2: initial-buffer-choice.patch --]
[-- Type: text/x-patch, Size: 1640 bytes --]

From 165ce95288a0b2652f009bf8571b01d491b229c6 Mon Sep 17 00:00:00 2001
From: CToID <funk443@yahoo.com.tw>
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


       reply	other threads:[~2024-07-12 19:18 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <32450bf6-4672-4357-8632-a536c774b6ab.ref@yahoo.com.tw>
2024-07-12 19:18 ` CToID via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2024-07-13  6:19   ` bug#72089: [PATCH] Option to control Emacs' behaviour when invoked with file args Eli Zaretskii
2024-07-13  7:59     ` Andrea Corallo
2024-07-16 22:24     ` Björn Bidar via Bug reports for GNU Emacs, the Swiss army knife of text editors
     [not found]     ` <87sew9asat.fsf@>
2024-07-17  6:29       ` CToID via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-07-17 11:24       ` Eli Zaretskii
2024-07-17 16:30         ` Björn Bidar via Bug reports for GNU Emacs, the Swiss army knife of text editors
     [not found]         ` <87h6coasly.fsf@>
2024-07-17 17:53           ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=32450bf6-4672-4357-8632-a536c774b6ab@yahoo.com.tw \
    --to=bug-gnu-emacs@gnu.org \
    --cc=72089@debbugs.gnu.org \
    --cc=funk443@yahoo.com.tw \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.