Disclaimer: I didn't have time to learn all about the Vim arglist feature, so I don't know if this is really in the full spirit of what it does and what you want. But forging ahead anyway:
Based on the assumption that people keep Emacs running (as opposed to frequently starting and exiting it) it would be nice to have an Emacs command that asks you for the pathnames (as opposed to supplying them as command-line arguments to Emacs).
Emacs has a compilation mode that can find pathnames/positions in a buffer, and visit them using next-error
and previous-error
.
Given that, the question is how to get the "arglist" into some buffer, and enable the compilation "machinery" for it.
Below is one way to do it, which is closest to how you would supply command-line arguments, for example as a.txt b.txt *.c ../foo.*
(defun my/vim-arglist ()
"Easily visit a group of files.
Prompts you to enter one or more pathnames, each of which can use
wildcards. Puts the actual, expanded pathnames one per line in a
*files* buffer with `compilation-minor-mode' enabled. Reminds you
to use `next-error' and `previous-error' to visit the files."
(interactive)
(let* ((prompt (format "Files (%s): " default-directory))
(wildcards (split-string (read-from-minibuffer prompt)))
(filess (mapcar (lambda (x) (file-expand-wildcards x t))
wildcards))
(files (apply #'append filess))
(buffer-name "*files*"))
(when (get-buffer buffer-name)
(kill-buffer buffer-name))
(with-current-buffer (get-buffer-create buffer-name)
(compilation-setup t)
(insert "Files:\n")
(dolist (file files) (insert file) (insert ":1:0\n")))
(message "Use next-error and previous-error to move among the files")))
You may also want to check out the rgrep
command. Its *grep*
results buffer also supports the compilation mode style of navigating using next-error
etc. The catch is what to supply as the search pattern -- because you really want just one "match" per file. If all the files have some unique line of boilerplate like a copyright or a language element, you could use that; otherwise I don't know.