emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [External] : Visiting a set of files listed in a file


From: Drew Adams
Subject: RE: [External] : Visiting a set of files listed in a file
Date: Sat, 9 Apr 2022 21:06:42 +0000

> > dired-simultaneous-find-file: Too many files to visit simultaneously.
> Try C-u prefix
> >
> > the file I tried contains 52 files listed...
> 
> With 10 files listed it works but it opens also 10 window!
> 
> I would only visit them with one window for the last file (I would also
> increase the number of files...)

As the doc of what I wrote says, and as the doc of
`dired-simultaneous-find-file' says, you can use
optional arg NOSELECT (prefix arg) to not try to
show 52 windows in your frame.

And as I said, if you don't want to leverage
`dired-simultaneous-find-file' then just use some
of its code to define your own function.  This is
its definition in Emacs 27.2.  It's probably the
same in Emacs 28:

(defun dired-simultaneous-find-file (file-list noselect)
  "Visit all files in FILE-LIST and display them simultaneously.
The current window is split across all files in FILE-LIST, as evenly as
possible.  Remaining lines go to the bottom-most window.  The number of
files that can be displayed this way is restricted by the height of the
current window and the variable `window-min-height'.  With non-nil
NOSELECT the files are merely found but not selected."
  ;; We don't make this function interactive because it is usually too clumsy
  ;; to specify FILE-LIST interactively unless via dired.
  (let (size)
    (if noselect
        ;; Do not select the buffer.
        (find-file-noselect (car file-list))
      ;; We will have to select the buffer.  Calculate and check window size.
      (setq size (/ (window-height) (length file-list)))
      (or (<= window-min-height size)
          (error "Too many files to visit simultaneously.  Try C-u prefix"))
      (find-file (car file-list)))
    ;; Decrement.
    (dolist (file (cdr file-list))
      (if noselect
          ;; Do not select the buffer.
          (find-file-noselect file)
        ;; Vertically split off a window of desired size.  Upper window will
        ;; have SIZE lines.  Select lower (larger) window.  We split it again.
        (select-window (split-window nil size))
        (find-file file)))))

You might also be interested in the first comment there:

 ;; We don't make this function interactive because it is usually
 ;; too clumsy to specify FILE-LIST interactively unless via dired.

In your case, you really do want to visit zillions of files.

(Why?  Are you sure you want to do that - visit all of them
at the same time?  Maybe you instead want to visit them one
at a time, doing something to each in turn, then killing it.
I'd suggest you think more about what you really need/want.)

Clearly you don't want to visit each of them in a window
(at the same time), do you?  So just do what you want.  Maybe
use NOSELECT to visit all of them (if you really need that),
and display only whichever of the buffers you want to show.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]