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)