unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Samer Masterson <samer@samertm.com>
To: emacs-devel@gnu.org
Subject: [PATCH] switch to file buffer from command line args regardless of `initial-buffer-choice'
Date: Mon, 02 Mar 2015 00:07:56 -0800	[thread overview]
Message-ID: <1425283676.2563.0@mail.samertm.com> (raw)

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

When `initial-buffer-choice' is set and emacs is called with a file as
a command line argument, the file is opened as a background buffer and
`initial-buffer-choice' is the initial buffer. This reduces the
utility of calling emacs from the command line when
`initial-buffer-choice' is set, and is inconsistent with the behavior
of the startup screen, which is not displayed when emacs is given a
file as a command line argument.

This patch always opens `initial-buffer-choice', but displays the file
buffer if emacs is given a file as a command line argument.

Best,
Samer

Patch below:

diff --git a/etc/NEWS b/etc/NEWS
index d5cb947..f0a0541 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -63,6 +63,9 @@ so if you want to use it, you can always take a copy from an older Emacs.
 \f
 * Startup Changes in Emacs 25.1
 
+** If Emacs is given a file as a command line argument, `initial-buffer-choice'
+is opened but not switched to.
+
 \f
 * Changes in Emacs 25.1
 
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index b9681d3..9df8e84 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,9 @@
+2015-02-27  Samer Masterson  <samer@samertm.com>
+
+	* startup.el (command-line-1): If Emacs is given a file as a
+	command line argument, open initial-buffer-choice but do not
+	switch to it.
+
 2015-02-27  Mark Laws  <mdl@60hz.org>
 
 	Support daemon mode on MS-Windows (bug#19688)
diff --git a/lisp/startup.el b/lisp/startup.el
index 999e53e..34a03ec 100644
--- a/lisp/startup.el
+++ b/lisp/startup.el
@@ -2389,9 +2389,10 @@ A fancy display is used on graphic displays, normal otherwise."
 		    (find-file-noselect initial-buffer-choice))
 		   ((functionp initial-buffer-choice)
 		    (funcall initial-buffer-choice)))))
-	(switch-to-buffer
-	 (if (buffer-live-p buf) buf (get-buffer-create "*scratch*"))
-	 'norecord)))
+        (unless (> file-count 0)
+          (switch-to-buffer
+           (if (buffer-live-p buf) buf (get-buffer-create "*scratch*"))
+           'norecord))))
 
     (if (or inhibit-startup-screen
 	    initial-buffer-choice



[-- Attachment #2: Type: text/html, Size: 3618 bytes --]

             reply	other threads:[~2015-03-02  8:07 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-02  8:07 Samer Masterson [this message]
2015-03-13 22:11 ` [PATCH] switch to file buffer from command line args regardless of `initial-buffer-choice' Stefan Monnier
2015-05-01 14:17   ` Samer Masterson
2015-05-16  3:11     ` Samer Masterson
2015-05-20 18:36       ` Stefan Monnier
2015-05-28 21:34         ` Samer Masterson
2015-05-29  5:48           ` Eli Zaretskii
2015-05-29  8:02             ` Samer Masterson
2015-08-03 14:56     ` Rasmus
     [not found]       ` <CAP6_t8gsmwPj5vkBQ4eegYXYcfmVAtHb+mnrUMYPyZwDXZ8DRw@mail.gmail.com>
     [not found]         ` <CAP6_t8gDr0y_WvwO43nXOFLU5h4hC-nnpjAmC-wDe7dYcTuwyw@mail.gmail.com>
     [not found]           ` <874mkdjwt8.fsf@gmx.us>
2015-08-05 20:46             ` Samer Masterson
2015-08-07 15:33               ` Stefan Monnier
2015-08-07 17:42                 ` Samer Masterson
2015-08-07 17:42                   ` Samer Masterson
2015-08-07 21:22                   ` Stefan Monnier
2015-08-10 18:16                     ` Samer Masterson

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=1425283676.2563.0@mail.samertm.com \
    --to=samer@samertm.com \
    --cc=emacs-devel@gnu.org \
    /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 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).