From: Samer Masterson <nosefrog@gmail.com>
To: Rasmus <rasmus@gmx.us>, emacs-devel@gnu.org
Subject: Re: [PATCH] switch to file buffer from command line args regardless of `initial-buffer-choice'
Date: Wed, 5 Aug 2015 13:46:06 -0700 [thread overview]
Message-ID: <CAP6_t8iXSw3wR6t6jfYWYNxZ-m2keBN-miotanpE0B9c67MZ4w@mail.gmail.com> (raw)
In-Reply-To: <874mkdjwt8.fsf@gmx.us>
[-- Attachment #1: Type: text/plain, Size: 3680 bytes --]
The patch below works for me. I think the formatting is off because we're
using spaces instead of tabs for indentation now. Do you want to test and
install it? Otherwise, I can do that later tonight.
Thanks,
Samer
Modified lisp/startup.el
diff --git a/lisp/startup.el b/lisp/startup.el
index cfe2269..40f8be8 100644
--- a/lisp/startup.el
+++ b/lisp/startup.el
@@ -2160,9 +2160,12 @@ A fancy display is used on graphic displays, normal
otherwise."
;; which includes files parsed from the command line arguments and
;; `initial-buffer-choice'. All of the display logic happens at the
;; end of this `let'. As files as processed from the command line
- ;; arguments, their buffers are prepended to `displayable-buffers'
- ;; but they are not displayed until command line parsing has
- ;; finished.
+ ;; arguments, their buffers are prepended to `displayable-buffers'.
+ ;; In order for options like "--eval" to work with the "--file" arg,
+ ;; the file buffers are switched to as they are seen on the command
+ ;; line (so "emacs --file a --file b --eval='(message "%s"
+ ;; (buffer-name))'" will print "b"), but this does not affect the
+ ;; final displayed state of the buffers.
(let ((displayable-buffers nil))
;; This `let' processes the command line arguments.
(let ((command-line-args-left args-left))
@@ -2194,10 +2197,10 @@ A fancy display is used on graphic displays, normal
otherwise."
(line 0)
(column 0)
;; `process-file-arg' opens a file buffer for `name'
- ;; without switching to the buffer, adds the buffer to
- ;; `displayable-buffers', and puts the point at
- ;; `line':`column'. `line' and `column' are both reset
- ;; to zero when `process-file-arg' returns.
+ ;; and adds the buffer to `displayable-buffers', and
+ ;; puts the point at `line':`column'. `line' and
+ ;; `column' are both reset to zero when
+ ;; `process-file-arg' returns.
(process-file-arg
(lambda (name)
;; This can only happen if PWD is deleted.
@@ -2207,7 +2210,9 @@ nil default-directory" name)
(let* ((file (expand-file-name
(command-line-normalize-file-name name)
dir))
- (buf (find-file-noselect file)))
+ ;; Call `find-file' instead of
`find-file-noselect'
+ ;; so that the file buffer can be used with
"--eval".
+ (buf (find-file file)))
(setq displayable-buffers (cons buf displayable-buffers))
(with-current-buffer buf
(unless (zerop line)
On Wed, Aug 5, 2015 at 1:37 PM, Rasmus <rasmus@gmx.us> wrote:
> Samer Masterson <nosefrog@gmail.com> writes:
>
> > The issue here is that my patch uses `find-file-noselect' on the arg for
> > --file and delays switching to the file buffer to the end of the
> function,
> > but all of the other commands, like --eval, execute immediately... My
> first
> > reaction is to use `find-file' instead of `find-file-noselect', so that
> the
> > "found" file is selected immediately, and then have the display logic at
> > the end, which may be redundant if there is only a single displayable
> > buffer. I'll submit a patch later today.
>
> I actually tried to change it to find-file in my local version of the
> file, but it didn't solve the problem. But perhaps I forgot to
> byte-compile it.
>
> Let me know.
>
> Thanks,
> Rasmus
>
> --
> Evidence suggests Snowden used a powerful tool called monospaced fonts
>
[-- Attachment #2: Type: text/html, Size: 4967 bytes --]
next prev parent reply other threads:[~2015-08-05 20:46 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-02 8:07 [PATCH] switch to file buffer from command line args regardless of `initial-buffer-choice' Samer Masterson
2015-03-13 22:11 ` 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 [this message]
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=CAP6_t8iXSw3wR6t6jfYWYNxZ-m2keBN-miotanpE0B9c67MZ4w@mail.gmail.com \
--to=nosefrog@gmail.com \
--cc=emacs-devel@gnu.org \
--cc=rasmus@gmx.us \
/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).