Emacs Asked on February 7, 2021
Any time I open multiple files I’d like emacs to only show me one buffer. I do not want any split windows. This would save me a keystroke every time.
I learned I could do away with the buffer list from this post with (setq-default inhibit-startup-buffer-menu t)
. But, now another buffer just replaces what would have been the buffer list. Any way to force only one window when opening multiple files?
I don't quite understand your last comment, but try the following in your init file:
(setq command-line-functions (list #'handle-files))
(defun handle-files ()
(let ((lfile (car (last command-line-args-left)))
(files (butlast command-line-args-left)))
(while files
(find-file-noselect (car files))
(setq files (cdr files)))
(find-file lfile)
(setq command-line-args-left nil)
t))
The assumption is that all the options are already processed and you just have a list of files at the end of your command line. Each function in the list command-line-functions
is called with no args (see the Elisp manual for details). There is only one function in this case and it consumes all of the left-over arguments: it does a find-file-noselect
on all of them except the last one, on which it does a find-file
.
Doing emacs -Q -l /path/to/init/file.el a b c d
does what you want (I think).
Answered by NickD on February 7, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP