unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Visiting a set of files listed in a file
@ 2022-04-09  9:31 Angelo Graziosi
  2022-04-09  9:59 ` Eli Zaretskii
                   ` (3 more replies)
  0 siblings, 4 replies; 22+ messages in thread
From: Angelo Graziosi @ 2022-04-09  9:31 UTC (permalink / raw)
  To: emacs-devel@gnu.org

Maybe this is obvious but I did not find a solution..

Can Emacs visit a set of files listed in a file?

For example, I have a text file with

/path_to/file1.f90
/path_to/file2.txt
/path_to/file3.c
/path_to/file4.tex
....

How can I visit all those files without doing that manually which could be tedious if the file to be visited are 40-50?

It would be useful doing that both from command line and inside Emacs...

TIA



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Visiting a set of files listed in a file
  2022-04-09  9:31 Visiting a set of files listed in a file Angelo Graziosi
@ 2022-04-09  9:59 ` Eli Zaretskii
  2022-04-09 10:15   ` Angelo Graziosi
  2022-04-09 17:44 ` [External] : " Drew Adams
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 22+ messages in thread
From: Eli Zaretskii @ 2022-04-09  9:59 UTC (permalink / raw)
  To: Angelo Graziosi; +Cc: emacs-devel

> Date: Sat, 9 Apr 2022 11:31:29 +0200 (CEST)
> From: Angelo Graziosi <angelo.g0@libero.it>
> 
> Maybe this is obvious but I did not find a solution..
> 
> Can Emacs visit a set of files listed in a file?
> 
> For example, I have a text file with
> 
> /path_to/file1.f90
> /path_to/file2.txt
> /path_to/file3.c
> /path_to/file4.tex
> ....
> 
> How can I visit all those files without doing that manually which could be tedious if the file to be visited are 40-50?
> 
> It would be useful doing that both from command line and inside Emacs...

Something like

  emacs `cat FILE`

I guess.



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Visiting a set of files listed in a file
  2022-04-09  9:59 ` Eli Zaretskii
@ 2022-04-09 10:15   ` Angelo Graziosi
  2022-04-09 10:40     ` Eli Zaretskii
  0 siblings, 1 reply; 22+ messages in thread
From: Angelo Graziosi @ 2022-04-09 10:15 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

> Il 09/04/2022 11:59 Eli Zaretskii ha scritto:
> 
>  
> > Date: Sat, 9 Apr 2022 11:31:29 +0200 (CEST)
> > From: Angelo Graziosi
> > 
> > Maybe this is obvious but I did not find a solution..
> > 
> > Can Emacs visit a set of files listed in a file?
> > 
> > For example, I have a text file with
> > 
> > /path_to/file1.f90
> > /path_to/file2.txt
> > /path_to/file3.c
> > /path_to/file4.tex
> > ....
> > 
> > How can I visit all those files without doing that manually which could be tedious if the file to be visited are 40-50?
> > 
> > It would be useful doing that both from command line and inside Emacs...
> 
> Something like
> 
>   emacs `cat FILE`
> 
> I guess.

Oh, yes but it works on unix-like systems. And on Windows? I assume to run some command from DOS prompt.. Which command? 

If I run the above from MSYS2 shell there is a mismatch with the HOME directory and consequently where Emacs reads the init file and where it saves the desktop file..

In any case it would be useful doing that from Emacs itself, something like

M-x visit-from foo.text

where foo.text contains the list of file to be visited (with the full path)..



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Visiting a set of files listed in a file
  2022-04-09 10:15   ` Angelo Graziosi
@ 2022-04-09 10:40     ` Eli Zaretskii
  2022-04-09 11:01       ` Angelo Graziosi
  0 siblings, 1 reply; 22+ messages in thread
From: Eli Zaretskii @ 2022-04-09 10:40 UTC (permalink / raw)
  To: Angelo Graziosi; +Cc: emacs-devel

> Date: Sat, 9 Apr 2022 12:15:36 +0200 (CEST)
> From: Angelo Graziosi <angelo.g0@libero.it>
> Cc: emacs-devel@gnu.org
> 
> > > How can I visit all those files without doing that manually which could be tedious if the file to be visited are 40-50?
> > > 
> > > It would be useful doing that both from command line and inside Emacs...
> > 
> > Something like
> > 
> >   emacs `cat FILE`
> > 
> > I guess.
> 
> Oh, yes but it works on unix-like systems. And on Windows? I assume to run some command from DOS prompt.. Which command? 

On Windows, you write a batch file that converts the file's contents
into a list of file names, then invokes Emacs with that list of file
names.

> If I run the above from MSYS2 shell there is a mismatch with the HOME directory and consequently where Emacs reads the init file and where it saves the desktop file..

What do you mean by "mismatch with HOME directory"?



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Visiting a set of files listed in a file
  2022-04-09 10:40     ` Eli Zaretskii
@ 2022-04-09 11:01       ` Angelo Graziosi
  2022-04-09 11:10         ` Eli Zaretskii
  0 siblings, 1 reply; 22+ messages in thread
From: Angelo Graziosi @ 2022-04-09 11:01 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel


> Il 09/04/2022 12:40 Eli Zaretskii ha scritto:
> 
>  
> > Date: Sat, 9 Apr 2022 12:15:36 +0200 (CEST)
> > From: Angelo Graziosi
> > Cc: emacs-devel@gnu.org
> > 
> > > > How can I visit all those files without doing that manually which could be tedious if the file to be visited are 40-50?
> > > > 
> > > > It would be useful doing that both from command line and inside Emacs...
> > > 
> > > Something like
> > > 
> > >   emacs `cat FILE`
> > > 
> > > I guess.
> > 
> > Oh, yes but it works on unix-like systems. And on Windows? I assume to run some command from DOS prompt.. Which command? 
> 
> On Windows, you write a batch file that converts the file's contents
> into a list of file names, then invokes Emacs with that list of file
> names.

It's not very practical...

> 
> > If I run the above from MSYS2 shell there is a mismatch with the HOME directory and consequently where Emacs reads the init file and where it saves the desktop file..
> 
> What do you mean by "mismatch with HOME directory"?

For MSYS2 the HOME is /home/USER (C:\msys2inst\home\USER) for Emacs the HOME is in APPDATA\Roaming, or not?

In any case I found this discussion: https://stackoverflow.com/questions/43225925/windows-cmd-pass-output-of-one-command-as-parameter-to-another

from which I deduced this command:

for /F "usebackq delims=" %A in (`type list-of-buffers`) do C:\\Emacs\bin\emacs.exe %A

With it I have to close Emacs N times (it restarts automatically), where N is the number of file listed. The thing is just _tedious - epsilon_..

I think you should simplify this allowing to do this also inside Emacs wint an "M-x ..." command.



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Visiting a set of files listed in a file
  2022-04-09 11:01       ` Angelo Graziosi
@ 2022-04-09 11:10         ` Eli Zaretskii
  2022-04-09 11:29           ` Angelo Graziosi
  0 siblings, 1 reply; 22+ messages in thread
From: Eli Zaretskii @ 2022-04-09 11:10 UTC (permalink / raw)
  To: Angelo Graziosi; +Cc: emacs-devel

> Date: Sat, 9 Apr 2022 13:01:53 +0200 (CEST)
> From: Angelo Graziosi <angelo.g0@libero.it>
> Cc: emacs-devel@gnu.org
> 
> > On Windows, you write a batch file that converts the file's contents
> > into a list of file names, then invokes Emacs with that list of file
> > names.
> 
> It's not very practical...

Why not? you need to write the batch file only once.

> > > If I run the above from MSYS2 shell there is a mismatch with the HOME directory and consequently where Emacs reads the init file and where it saves the desktop file..
> > 
> > What do you mean by "mismatch with HOME directory"?
> 
> For MSYS2 the HOME is /home/USER (C:\msys2inst\home\USER) for Emacs the HOME is in APPDATA\Roaming, or not?

No, not if you define HOME in the environment.  Then Emacs will follow
it no matter how you invoke it.

> In any case I found this discussion: https://stackoverflow.com/questions/43225925/windows-cmd-pass-output-of-one-command-as-parameter-to-another
> 
> from which I deduced this command:
> 
> for /F "usebackq delims=" %A in (`type list-of-buffers`) do C:\\Emacs\bin\emacs.exe %A
> 
> With it I have to close Emacs N times (it restarts automatically), where N is the number of file listed. The thing is just _tedious - epsilon_..

Yes, there's a lot of garbage advice on the Internet.  Granted, that
is not what I meant.  See "set /?" for one way of doing that.



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Visiting a set of files listed in a file
  2022-04-09 11:10         ` Eli Zaretskii
@ 2022-04-09 11:29           ` Angelo Graziosi
  2022-04-09 14:44             ` Eli Zaretskii
  0 siblings, 1 reply; 22+ messages in thread
From: Angelo Graziosi @ 2022-04-09 11:29 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel


> Il 09/04/2022 13:10 Eli Zaretskii <eliz@gnu.org> ha scritto:
> 
>  
> > Date: Sat, 9 Apr 2022 13:01:53 +0200 (CEST)
> > From: Angelo Graziosi <angelo.g0@libero.it>
> > Cc: emacs-devel@gnu.org
> > 
> > > On Windows, you write a batch file that converts the file's contents
> > > into a list of file names, then invokes Emacs with that list of file
> > > names.
> > 
> > It's not very practical...
> 
> Why not? you need to write the batch file only once.
> 
> > > > If I run the above from MSYS2 shell there is a mismatch with the HOME directory and consequently where Emacs reads the init file and where it saves the desktop file..
> > > 
> > > What do you mean by "mismatch with HOME directory"?
> > 
> > For MSYS2 the HOME is /home/USER (C:\msys2inst\home\USER) for Emacs the HOME is in APPDATA\Roaming, or not?
> 
> No, not if you define HOME in the environment.  Then Emacs will follow
> it no matter how you invoke it.
> 
> > In any case I found this discussion: https://stackoverflow.com/questions/43225925/windows-cmd-pass-output-of-one-command-as-parameter-to-another
> > 
> > from which I deduced this command:
> > 
> > for /F "usebackq delims=" %A in (`type list-of-buffers`) do C:\\Emacs\bin\emacs.exe %A
> > 
> > With it I have to close Emacs N times (it restarts automatically), where N is the number of file listed. The thing is just _tedious - epsilon_..
> 
> Yes, there's a lot of garbage advice on the Internet.  Granted, that
> is not what I meant.  See "set /?" for one way of doing that.

Following this discussion: https://superuser.com/questions/516999/passing-output-from-a-dos-command-as-arguments-to-another-command

the best I was able to do is this:

@echo off
Setlocal EnableDelayedExpansion
set fls=
for /f "delims=" %%A in ('type list-of-buffers') do set fls=!fls! %%A
C:\LocalApps\Emacs\bin\emacs.exe %fls%


Anyway, I think that the best thing is for Emacs to equip itself with this feature...



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Visiting a set of files listed in a file
  2022-04-09 11:29           ` Angelo Graziosi
@ 2022-04-09 14:44             ` Eli Zaretskii
  2022-04-09 20:21               ` Angelo Graziosi
  0 siblings, 1 reply; 22+ messages in thread
From: Eli Zaretskii @ 2022-04-09 14:44 UTC (permalink / raw)
  To: Angelo Graziosi; +Cc: emacs-devel

> Date: Sat, 9 Apr 2022 13:29:51 +0200 (CEST)
> From: Angelo Graziosi <angelo.g0@libero.it>
> Cc: emacs-devel@gnu.org
> 
> the best I was able to do is this:
> 
> @echo off
> Setlocal EnableDelayedExpansion
> set fls=
> for /f "delims=" %%A in ('type list-of-buffers') do set fls=!fls! %%A
> C:\LocalApps\Emacs\bin\emacs.exe %fls%

There's a better way, assuming you have GNU Findutils:

  C:\>type list-of-buffers | xargs C:\LocalApps\Emacs\bin\emacs



^ permalink raw reply	[flat|nested] 22+ messages in thread

* RE: [External] : Visiting a set of files listed in a file
  2022-04-09  9:31 Visiting a set of files listed in a file Angelo Graziosi
  2022-04-09  9:59 ` Eli Zaretskii
@ 2022-04-09 17:44 ` Drew Adams
  2022-04-09 20:29   ` Angelo Graziosi
  2022-04-10  1:07 ` James Thomas
  2022-04-12 21:17 ` Mathias Dahl
  3 siblings, 1 reply; 22+ messages in thread
From: Drew Adams @ 2022-04-09 17:44 UTC (permalink / raw)
  To: Angelo Graziosi, emacs-devel@gnu.org

> Can Emacs visit a set of files listed in a file?
> 
> For example, I have a text file with
> 
> /path_to/file1.f90
> /path_to/file2.txt
> /path_to/file3.c
> /path_to/file4.tex
> ....
> 
> How can I visit all those files without doing that manually which could
> be tedious if the file to be visited are 40-50?
> It would be useful doing that both from command line and inside
> Emacs...

This should do what you want.  You'll need to (require 'dired-x),
if you don't already do that (or you'll need to replace the call
to `dired-simultaneous-find-file' by code that does its job.

Try: `M-x visit-files-listed-in-file'.

(defun visit-files-listed-in-file (listing-file &optional noselect default-dir)
  "Visit each of the files in LISTING-FILE in a buffer.
With a prefix arg, visit the files but don't display them.
When called from lisp:
 Non-nil NOSELECT acts like a prefix arg.
 Non-nil DEFAULT-DIR is used as the `default-directory' for expanding
  relative file names."
  (interactive "fFile with file list: \nP")
  (let ((files  (file-names-from-listing-file listing-file)))
    (dired-simultaneous-find-file files noselect)))
    
(defun file-names-from-listing-file (listing-file &optional default-dir)
  "Return file names in LISTING-FILE as a list of file-name strings.
The file names returned are absolute.
File names in LISTING-FILE can be strings (double-quoted) or not, and
 they can be absolute or relative. 
Optional arg DEFAULT-DIR is used as `default-directory' to expand any
 relative file names."
  (let ((files  ())
        file)
    (with-current-buffer (find-file-noselect listing-file)
      (goto-char (point-min))
      (while (not (eobp))
        (setq file  (read (current-buffer)))
        (unless (stringp file) (setq file  (format "%s" file)))
        (when (setq file  (expand-file-name file default-dir))
          (push file files))
        (forward-line 1)))
    (nreverse files)))

This just leverages what you get with Dired by marking the files
you want to visit and then using `F', which is bound to command
`dired-do-find-marked-files'.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Visiting a set of files listed in a file
  2022-04-09 14:44             ` Eli Zaretskii
@ 2022-04-09 20:21               ` Angelo Graziosi
  0 siblings, 0 replies; 22+ messages in thread
From: Angelo Graziosi @ 2022-04-09 20:21 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel


> Il 09/04/2022 16:44 Eli Zaretskii ha scritto:
> 
>  
> > Date: Sat, 9 Apr 2022 13:29:51 +0200 (CEST)
> > From: Angelo Graziosi 
> > 
> > 
> > the best I was able to do is this:
> > 
> > @echo off
> > Setlocal EnableDelayedExpansion
> > set fls=
> > for /f "delims=" %%A in ('type list-of-buffers') do set fls=!fls! %%A
> > C:\LocalApps\Emacs\bin\emacs.exe %fls%
> 
> There's a better way, assuming you have GNU Findutils:
> 
>   C:\>type list-of-buffers | xargs C:\LocalApps\Emacs\bin\emacs

Thanks for suggestions..



^ permalink raw reply	[flat|nested] 22+ messages in thread

* RE: [External] : Visiting a set of files listed in a file
  2022-04-09 17:44 ` [External] : " Drew Adams
@ 2022-04-09 20:29   ` Angelo Graziosi
  2022-04-09 20:35     ` Angelo Graziosi
  2022-04-09 20:56     ` Drew Adams
  0 siblings, 2 replies; 22+ messages in thread
From: Angelo Graziosi @ 2022-04-09 20:29 UTC (permalink / raw)
  To: Drew Adams, emacs-devel@gnu.org


> Il 09/04/2022 19:44 Drew Adams ha scritto:
> 
>  
> > Can Emacs visit a set of files listed in a file?
> > 
> > For example, I have a text file with
> > 
> > /path_to/file1.f90
> > /path_to/file2.txt
> > /path_to/file3.c
> > /path_to/file4.tex
> > ....
> > 
> > How can I visit all those files without doing that manually which could
> > be tedious if the file to be visited are 40-50?
> > It would be useful doing that both from command line and inside
> > Emacs...
> 
> This should do what you want.  You'll need to (require 'dired-x),
> if you don't already do that (or you'll need to replace the call
> to `dired-simultaneous-find-file' by code that does its job.
> 
> Try: `M-x visit-files-listed-in-file'.
> 
> (defun visit-files-listed-in-file (listing-file &optional noselect default-dir)
>   "Visit each of the files in LISTING-FILE in a buffer.
> With a prefix arg, visit the files but don't display them.
> When called from lisp:
>  Non-nil NOSELECT acts like a prefix arg.
>  Non-nil DEFAULT-DIR is used as the `default-directory' for expanding
>   relative file names."
>   (interactive "fFile with file list: \nP")
>   (let ((files  (file-names-from-listing-file listing-file)))
>     (dired-simultaneous-find-file files noselect)))
>     
> (defun file-names-from-listing-file (listing-file &optional default-dir)
>   "Return file names in LISTING-FILE as a list of file-name strings.
> The file names returned are absolute.
> File names in LISTING-FILE can be strings (double-quoted) or not, and
>  they can be absolute or relative. 
> Optional arg DEFAULT-DIR is used as `default-directory' to expand any
>  relative file names."
>   (let ((files  ())
>         file)
>     (with-current-buffer (find-file-noselect listing-file)
>       (goto-char (point-min))
>       (while (not (eobp))
>         (setq file  (read (current-buffer)))
>         (unless (stringp file) (setq file  (format "%s" file)))
>         (when (setq file  (expand-file-name file default-dir))
>           (push file files))
>         (forward-line 1)))
>     (nreverse files)))
> 
> This just leverages what you get with Dired by marking the files
> you want to visit and then using `F', which is bound to command
> `dired-do-find-marked-files'.

I added your code to my init.el and tried to test it.. but it says:

-------------------
M-x visit-files-listed-in-file
foo-list.log

let: Symbol’s function definition is void: dired-simultaneous-find-file
-------------------

Maybe I have misinterpreted your suggestions.. did not understand them...



^ permalink raw reply	[flat|nested] 22+ messages in thread

* RE: [External] : Visiting a set of files listed in a file
  2022-04-09 20:29   ` Angelo Graziosi
@ 2022-04-09 20:35     ` Angelo Graziosi
  2022-04-09 20:46       ` Angelo Graziosi
  2022-04-09 20:56     ` Drew Adams
  1 sibling, 1 reply; 22+ messages in thread
From: Angelo Graziosi @ 2022-04-09 20:35 UTC (permalink / raw)
  To: Drew Adams, emacs-devel@gnu.org


> Il 09/04/2022 22:29 Angelo Graziosi ha scritto:
> 
>  
> I added your code to my init.el and tried to test it.. but it says:
> 
> -------------------
> M-x visit-files-listed-in-file
> foo-list.log
> 
> let: Symbol’s function definition is void: dired-simultaneous-find-file
> -------------------
> 
> Maybe I have misinterpreted your suggestions.. did not understand them...

Oops, I forgot to add

(require 'dired-x)


Now it almost works in the sense it fails in this way:

dired-simultaneous-find-file: Too many files to visit simultaneously.  Try C-u prefix

the file I tried contains 52 files listed...



^ permalink raw reply	[flat|nested] 22+ messages in thread

* RE: [External] : Visiting a set of files listed in a file
  2022-04-09 20:35     ` Angelo Graziosi
@ 2022-04-09 20:46       ` Angelo Graziosi
  2022-04-09 21:06         ` Drew Adams
  0 siblings, 1 reply; 22+ messages in thread
From: Angelo Graziosi @ 2022-04-09 20:46 UTC (permalink / raw)
  To: Drew Adams, emacs-devel@gnu.org

> Il 09/04/2022 22:35 Angelo Graziosi ha scritto:
> 
>  
> Now it almost works in the sense it fails in this way:
> 
> 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...)



^ permalink raw reply	[flat|nested] 22+ messages in thread

* RE: [External] : Visiting a set of files listed in a file
  2022-04-09 20:29   ` Angelo Graziosi
  2022-04-09 20:35     ` Angelo Graziosi
@ 2022-04-09 20:56     ` Drew Adams
  1 sibling, 0 replies; 22+ messages in thread
From: Drew Adams @ 2022-04-09 20:56 UTC (permalink / raw)
  To: Angelo Graziosi, emacs-devel@gnu.org

> > You'll need to (require 'dired-x),
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> > if you don't already do that (or you'll need to replace the call
> > to `dired-simultaneous-find-file' by code that does its job.
> > ...
> > This just leverages what you get with Dired by marking the files
> > you want to visit and then using `F', which is bound to command
> > `dired-do-find-marked-files'.
> 
> I added your code to my init.el and tried to test it.. but it says:
> 
> M-x visit-files-listed-in-file
> foo-list.log
> let: Symbol’s function definition is void: dired-simultaneous-find-file

You forgot (require 'dired-x).
That function is defined in file dired-x.el.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* RE: [External] : Visiting a set of files listed in a file
  2022-04-09 20:46       ` Angelo Graziosi
@ 2022-04-09 21:06         ` Drew Adams
  2022-04-09 21:45           ` Angelo Graziosi
  0 siblings, 1 reply; 22+ messages in thread
From: Drew Adams @ 2022-04-09 21:06 UTC (permalink / raw)
  To: Angelo Graziosi, emacs-devel@gnu.org

> > 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.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* RE: [External] : Visiting a set of files listed in a file
  2022-04-09 21:06         ` Drew Adams
@ 2022-04-09 21:45           ` Angelo Graziosi
  0 siblings, 0 replies; 22+ messages in thread
From: Angelo Graziosi @ 2022-04-09 21:45 UTC (permalink / raw)
  To: Drew Adams, emacs-devel@gnu.org

> Il 09/04/2022 23:06 Drew Adams ha scritto:
> 
> 
> In your case, you really do want to visit zillions of files.

No, but I need this to rebuild my desktop file in a quick way.. Recently (https://lists.gnu.org/archive/html/emacs-devel/2022-04/msg00017.html) I had an issue cause by the desktop file which, in some manner, I had to recreate.

The feature of visiting multiple files has, in any case, value in itself.

Thanks for all clarifications and suggestions.



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Visiting a set of files listed in a file
  2022-04-09  9:31 Visiting a set of files listed in a file Angelo Graziosi
  2022-04-09  9:59 ` Eli Zaretskii
  2022-04-09 17:44 ` [External] : " Drew Adams
@ 2022-04-10  1:07 ` James Thomas
  2022-04-11 15:18   ` João Pedro
                     ` (2 more replies)
  2022-04-12 21:17 ` Mathias Dahl
  3 siblings, 3 replies; 22+ messages in thread
From: James Thomas @ 2022-04-10  1:07 UTC (permalink / raw)
  To: Angelo Graziosi; +Cc: emacs-devel@gnu.org

Angelo Graziosi wrote:

> Can Emacs visit a set of files listed in a file?
>
> For example, I have a text file with
>
> /path_to/file1.f90
> /path_to/file2.txt
> /path_to/file3.c
> /path_to/file4.tex
> ....
>
> How can I visit all those files without doing that manually which
> could be tedious if the file to be visited are 40-50?
>
> It would be useful doing that both from command line and inside Emacs...

For from inside Emacs:
What I've found is that putting the buffer in dired-virtual-mode (from
dired-x) and then setting

(setq directory-listing-before-filename-regexp "^\*? *")

...means that you can use it just like a dired buffer. So type t and F
to visit all the files.

--



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Visiting a set of files listed in a file
  2022-04-10  1:07 ` James Thomas
@ 2022-04-11 15:18   ` João Pedro
  2022-04-11 15:31   ` chad
  2022-04-12  6:59   ` James Thomas
  2 siblings, 0 replies; 22+ messages in thread
From: João Pedro @ 2022-04-11 15:18 UTC (permalink / raw)
  To: James Thomas, Angelo Graziosi; +Cc: emacs-devel@gnu.org

On 10 April 2022 06:37, James Thomas <jimjoe@gmx.net> wrote:

> For from inside Emacs:
> What I've found is that putting the buffer in dired-virtual-mode (from
> dired-x) and then setting
>
> (setq directory-listing-before-filename-regexp "^\*? *")
>
> ...means that you can use it just like a dired buffer. So type t and F
> to visit all the files.

First time hearing of dired-virtual-mode! That's why I love Emacs and
the community around it!!

Thankfully,

-- 
João Pedro de Amorim Paula
IT undergraduate at Universidade Federal do Rio Grande do Norte (UFRN)

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Visiting a set of files listed in a file
  2022-04-10  1:07 ` James Thomas
  2022-04-11 15:18   ` João Pedro
@ 2022-04-11 15:31   ` chad
  2022-04-11 20:34     ` Angelo Graziosi
  2022-04-12  6:59   ` James Thomas
  2 siblings, 1 reply; 22+ messages in thread
From: chad @ 2022-04-11 15:31 UTC (permalink / raw)
  To: James Thomas; +Cc: Angelo Graziosi, emacs-devel@gnu.org

[-- Attachment #1: Type: text/plain, Size: 949 bytes --]

It looks like you have received several viable suggestions, but since the
topic is still somewhat open, let me ask you: are you familiar with emacs'
keyboard macro system?


https://www.gnu.org/software/emacs/manual/html_node/emacs/Keyboard-Macros.html

Once your list of files is in a buffer, ideally one per line, getting emacs
to open the file named by each line is pretty simple, and if you build a
keyboard macro to do it, you have total control over the various options,
(reuse window or not? reuse frame or not? absolute paths or relative?
Relative to home, current, or specified in the buffer? process the entire
list at once, once per keypress, or otherwise throttled? etc).
Additionally, since they can be named and saved for later, you can refine
it over time. This also makes it simple to incorporate whatever method you
use to generate the filelist, and you can craft the unusual/error cases to
suit your needs.

Hope that helps,
~Chad

[-- Attachment #2: Type: text/html, Size: 1169 bytes --]

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Visiting a set of files listed in a file
  2022-04-11 15:31   ` chad
@ 2022-04-11 20:34     ` Angelo Graziosi
  0 siblings, 0 replies; 22+ messages in thread
From: Angelo Graziosi @ 2022-04-11 20:34 UTC (permalink / raw)
  To: chad, James Thomas; +Cc: emacs-devel@gnu.org


> Il 11/04/2022 17:31 chad ha scritto:
> 
> 
> It looks like you have received several viable suggestions, but

Indeed...

> since the topic is still somewhat open, let me ask you: are you familiar with emacs' keyboard macro system?
> 
> https://www.gnu.org/software/emacs/manual/html_node/emacs/Keyboard-Macros.html
> 
> Once your list of files is in a buffer, ideally one per line, getting emacs to open the file named by each line is pretty simple, and if you build a keyboard macro to do it, you have total control over the various options, (reuse window or not? reuse frame or not? absolute paths or relative? Relative to home, current, or specified in the buffer? process the entire list at once, once per keypress, or otherwise throttled? etc). Additionally, since they can be named and saved for later, you can refine it over time. This also makes it simple to incorporate whatever method you use to generate the filelist, and you can craft the unusual/error cases to suit your needs.


This is another interesting solution! Thank you!



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Visiting a set of files listed in a file
  2022-04-10  1:07 ` James Thomas
  2022-04-11 15:18   ` João Pedro
  2022-04-11 15:31   ` chad
@ 2022-04-12  6:59   ` James Thomas
  2 siblings, 0 replies; 22+ messages in thread
From: James Thomas @ 2022-04-12  6:59 UTC (permalink / raw)
  To: Angelo Graziosi; +Cc: emacs-devel@gnu.org

James Thomas wrote:

> (setq directory-listing-before-filename-regexp "^\*? *")

Here's an improvement on that, just for the record:

(setq-local directory-listing-before-filename-regexp " +")

--



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Visiting a set of files listed in a file
  2022-04-09  9:31 Visiting a set of files listed in a file Angelo Graziosi
                   ` (2 preceding siblings ...)
  2022-04-10  1:07 ` James Thomas
@ 2022-04-12 21:17 ` Mathias Dahl
  3 siblings, 0 replies; 22+ messages in thread
From: Mathias Dahl @ 2022-04-12 21:17 UTC (permalink / raw)
  To: Angelo Graziosi; +Cc: emacs-devel@gnu.org

[-- Attachment #1: Type: text/plain, Size: 902 bytes --]

I would either record a keyboard macro, as others here suggested, or define
a simple command like this:

(defun find-files-region ()
  (interactive)
  (dolist (file (split-string
                 (buffer-substring
                  (region-beginning)
                  (region-end))
                 "\n" t ))
    (find-file file)))


Den lör 9 apr. 2022 kl 11:33 skrev Angelo Graziosi <angelo.g0@libero.it>:

> Maybe this is obvious but I did not find a solution..
>
> Can Emacs visit a set of files listed in a file?
>
> For example, I have a text file with
>
> /path_to/file1.f90
> /path_to/file2.txt
> /path_to/file3.c
> /path_to/file4.tex
> ....
>
> How can I visit all those files without doing that manually which could be
> tedious if the file to be visited are 40-50?
>
> It would be useful doing that both from command line and inside Emacs...
>
> TIA
>
>

[-- Attachment #2: Type: text/html, Size: 1316 bytes --]

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2022-04-12 21:17 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-09  9:31 Visiting a set of files listed in a file Angelo Graziosi
2022-04-09  9:59 ` Eli Zaretskii
2022-04-09 10:15   ` Angelo Graziosi
2022-04-09 10:40     ` Eli Zaretskii
2022-04-09 11:01       ` Angelo Graziosi
2022-04-09 11:10         ` Eli Zaretskii
2022-04-09 11:29           ` Angelo Graziosi
2022-04-09 14:44             ` Eli Zaretskii
2022-04-09 20:21               ` Angelo Graziosi
2022-04-09 17:44 ` [External] : " Drew Adams
2022-04-09 20:29   ` Angelo Graziosi
2022-04-09 20:35     ` Angelo Graziosi
2022-04-09 20:46       ` Angelo Graziosi
2022-04-09 21:06         ` Drew Adams
2022-04-09 21:45           ` Angelo Graziosi
2022-04-09 20:56     ` Drew Adams
2022-04-10  1:07 ` James Thomas
2022-04-11 15:18   ` João Pedro
2022-04-11 15:31   ` chad
2022-04-11 20:34     ` Angelo Graziosi
2022-04-12  6:59   ` James Thomas
2022-04-12 21:17 ` Mathias Dahl

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).