2

In earlier versions of emacs one could use emacs -nw file1 file2 file3 and see three files (and no buffer list) at startup. For recent versions this no longer works. Is it possible to add some code to .emacs to fix this regression? It looks like the limit of 2 is hardcoded in startup.el. One also needs 3, 4...

  • Are you sure those files are not just visited in buffers that are not displayed by default? – Drew Dec 3 '18 at 2:25
  • Yes, of course. But I want to see them, at the same time. – ember Dec 3 '18 at 6:33
  • Then please make that clear in the question. Comments can be deleted at any time. Visiting ("opening") a file is not the same as displaying the buffer that visits it. Your question is about Emacs windows more than it is about files or buffers. – Drew Dec 3 '18 at 15:00
  • See also emacs.stackexchange.com/a/36369/15748 – Basil Jan 3 at 12:33
0

I think this changed in emacs 25. As you noted, the behavior is currently hard-coded in startup.el: if there are more than 2 buffers to be shown, Emacs uses one of the windows to show the buffer list. You could enter a bug report -- maybe that limit could be exposed as a variable.

For now, your best bet might be to use emacs-startup-hook, which runs after the command-line options have been processed. You could have a custom function to look at (buffer-list) and display buffers in separate windows, up to some configurable max number of windows. You'll want to filter out uninteresting buffers -- for example, only display buffers associated with a file.

You may be able to use a package like tile or splitter to split up the frame into a suitable number of windows.

  • Yes, thank you. The proper variable is probably not the number of files (by default we want to see them all) but the minimum number of visible lines from each displayed buffer, something in the range 2-6, say. However, maybe I am not sufficiently familiar with emacs internals to code such a startup hook. – ember Dec 4 '18 at 0:55
-1

Does the following code do what you want?

;; allow more than two windows on initial screen
(add-hook 'window-setup-hook #'foo-show-many-buffers)
(defun foo-show-many-buffers ()
  "Call display-buffer for all file arguments."
  (let ((tmp (buffer-list)))
    (while tmp
      (let ((buf (car tmp)))
            (setq tmp (cdr tmp))
            (if (buffer-file-name buf) (display-buffer buf))))))
  • (dolist (buf (buffer-list)) (if (buffer-file-name buf) (display-buffer buf))) – Fólkvangr Jul 8 at 17:09
  • Nope, the function does not display more than two windows. – Fólkvangr Jul 8 at 18:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.