unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#72089: [PATCH] Option to control Emacs' behaviour when invoked with file args.
       [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
  2024-07-13  6:19   ` Eli Zaretskii
  0 siblings, 1 reply; 8+ messages in thread
From: CToID via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-07-12 19:18 UTC (permalink / raw)
  To: 72089

[-- 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


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* bug#72089: [PATCH] Option to control Emacs' behaviour when invoked with file args.
  2024-07-12 19:18 ` bug#72089: [PATCH] Option to control Emacs' behaviour when invoked with file args CToID via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2024-07-13  6:19   ` Eli Zaretskii
  2024-07-13  7:59     ` Andrea Corallo
                       ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Eli Zaretskii @ 2024-07-13  6:19 UTC (permalink / raw)
  To: CToID, Stefan Kangas, Andrea Corallo; +Cc: 72089

severity 72089 wishlist
thanks

> Date: Sat, 13 Jul 2024 03:18:04 +0800
> From:  CToID via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
> 
> 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.

Thanks.  Such changes should be accompanied by a suitable NEWS entry
and changes for the manual(s) which describe initial-buffer-choice.
But please wait with these additions until we decide whether we want
such a feature.

Andrea and Stefan, any opinions?





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#72089: [PATCH] Option to control Emacs' behaviour when invoked with file args.
  2024-07-13  6:19   ` 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@>
  2 siblings, 0 replies; 8+ messages in thread
From: Andrea Corallo @ 2024-07-13  7:59 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 72089, CToID, Stefan Kangas

Eli Zaretskii <eliz@gnu.org> writes:

> severity 72089 wishlist
> thanks
>
>> Date: Sat, 13 Jul 2024 03:18:04 +0800
>> From:  CToID via "Bug reports for GNU Emacs,
>>  the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
>> 
>> 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.
>
> Thanks.  Such changes should be accompanied by a suitable NEWS entry
> and changes for the manual(s) which describe initial-buffer-choice.
> But please wait with these additions until we decide whether we want
> such a feature.
>
> Andrea and Stefan, any opinions?

I'm okay with this, sounds it might be useful.

  Andrea





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#72089: [PATCH] Option to control Emacs' behaviour when invoked with file args.
  2024-07-13  6:19   ` 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@>
  2 siblings, 0 replies; 8+ messages in thread
From: Björn Bidar via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-07-16 22:24 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Andrea Corallo, CToID, 72089, Stefan Kangas

Eli Zaretskii <eliz@gnu.org> writes:

> severity 72089 wishlist
> thanks
>
>> Date: Sat, 13 Jul 2024 03:18:04 +0800
>> From:  CToID via "Bug reports for GNU Emacs,
>>  the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
>> 
>> 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.
>
> Thanks.  Such changes should be accompanied by a suitable NEWS entry
> and changes for the manual(s) which describe initial-buffer-choice.
> But please wait with these additions until we decide whether we want
> such a feature.
>
> Andrea and Stefan, any opinions?

I wonder if it would make more sense that this should be command line
flag or a default rather that an option.

An option would require the user to set the option while a command line
flag would make the option redundant and more flexible.
The option would also allow the user to call a mode like e.g. Magit
use the mode and then close the frame without the initial buffer.

A default would be more intuitive as Emacs would behave pretty much like
any other editor out there.





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#72089: [PATCH] Option to control Emacs' behaviour when invoked with file args.
       [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
  1 sibling, 0 replies; 8+ messages in thread
From: CToID via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-07-17  6:29 UTC (permalink / raw)
  To: 72089

On 2024-07-17 06:24 GMT+08:00, Björn Bidar:
> I wonder if it would make more sense that this should be command line
> flag or a default rather that an option.
> 
> An option would require the user to set the option while a command line
> flag would make the option redundant and more flexible.
> The option would also allow the user to call a mode like e.g. Magit
> use the mode and then close the frame without the initial buffer.
> 
> A default would be more intuitive as Emacs would behave pretty much like
> any other editor out there.

The default value I gave to the customization option is to not show 
`initial-buffer-choice` if invoked with a file argument.  Maybe we can 
add another choice for controlling with command line flag?

-- 
Best,
ID





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#72089: [PATCH] Option to control Emacs' behaviour when invoked with file args.
       [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@>
  1 sibling, 2 replies; 8+ messages in thread
From: Eli Zaretskii @ 2024-07-17 11:24 UTC (permalink / raw)
  To: Björn Bidar; +Cc: acorallo, funk443, 72089, stefankangas

> From: Björn Bidar <bjorn.bidar@thaodan.de>
> Cc: CToID <funk443@yahoo.com.tw>,  Stefan Kangas <stefankangas@gmail.com>,
>   Andrea Corallo <acorallo@gnu.org>,  72089@debbugs.gnu.org
> Date: Wed, 17 Jul 2024 01:24:58 +0300
> 
> I wonder if it would make more sense that this should be command line
> flag or a default rather that an option.
> 
> An option would require the user to set the option while a command line
> flag would make the option redundant and more flexible.
> The option would also allow the user to call a mode like e.g. Magit
> use the mode and then close the frame without the initial buffer.
> 
> A default would be more intuitive as Emacs would behave pretty much like
> any other editor out there.

I don't really see a big difference, since we have --eval.





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#72089: [PATCH] Option to control Emacs' behaviour when invoked with file args.
  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@>
  1 sibling, 0 replies; 8+ messages in thread
From: Björn Bidar via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-07-17 16:30 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: acorallo, funk443, 72089, stefankangas

Eli Zaretskii <eliz@gnu.org> writes:

> I don't really see a big difference, since we have --eval.

Passing elisp to commands in a shell script is pain and command line flags
are visible in --help.





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#72089: [PATCH] Option to control Emacs' behaviour when invoked with file args.
       [not found]         ` <87h6coasly.fsf@>
@ 2024-07-17 17:53           ` Eli Zaretskii
  0 siblings, 0 replies; 8+ messages in thread
From: Eli Zaretskii @ 2024-07-17 17:53 UTC (permalink / raw)
  To: Björn Bidar; +Cc: acorallo, funk443, 72089, stefankangas

> From: Björn Bidar <bjorn.bidar@thaodan.de>
> Cc: funk443@yahoo.com.tw,  stefankangas@gmail.com,  acorallo@gnu.org,
>   72089@debbugs.gnu.org
> Date: Wed, 17 Jul 2024 19:30:33 +0300
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> 
> > I don't really see a big difference, since we have --eval.
> 
> Passing elisp to commands in a shell script is pain

Not when all you need to do is a single setq.

> and command line flags are visible in --help.

So is --eval.

Adding a new command-line option also has downsides: it's another
thing to learn and remember.  "emacs --help" already shows more than
60 different options, and I personally sometimes have hard time
finding the option whose exact name I happened to forget in this very
long list.  So adding one more option doesn't come for free.





^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2024-07-17 17:53 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <32450bf6-4672-4357-8632-a536c774b6ab.ref@yahoo.com.tw>
2024-07-12 19:18 ` bug#72089: [PATCH] Option to control Emacs' behaviour when invoked with file args CToID via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-07-13  6:19   ` 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

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).