[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [External] : Visiting a set of files listed in a file
From: |
Angelo Graziosi |
Subject: |
RE: [External] : Visiting a set of files listed in a file |
Date: |
Sat, 9 Apr 2022 22:29:15 +0200 (CEST) |
> 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...
- Visiting a set of files listed in a file, Angelo Graziosi, 2022/04/09
- Re: Visiting a set of files listed in a file, Eli Zaretskii, 2022/04/09
- Re: Visiting a set of files listed in a file, Angelo Graziosi, 2022/04/09
- Re: Visiting a set of files listed in a file, Eli Zaretskii, 2022/04/09
- Re: Visiting a set of files listed in a file, Angelo Graziosi, 2022/04/09
- Re: Visiting a set of files listed in a file, Eli Zaretskii, 2022/04/09
- Re: Visiting a set of files listed in a file, Angelo Graziosi, 2022/04/09
- Re: Visiting a set of files listed in a file, Eli Zaretskii, 2022/04/09
- Re: Visiting a set of files listed in a file, Angelo Graziosi, 2022/04/09
RE: [External] : Visiting a set of files listed in a file, Drew Adams, 2022/04/09
- RE: [External] : Visiting a set of files listed in a file,
Angelo Graziosi <=
RE: [External] : Visiting a set of files listed in a file, Drew Adams, 2022/04/09
Re: Visiting a set of files listed in a file, James Thomas, 2022/04/09