How to invoke a function on all files in the git working tree, while opening the ones which have had no opened buffers beforehand?
A potential use case: Check and fix spelling in all project files with flyspell.
This should work for some definition of "all files":
(defun my-mapc-tracked-files (fn) (magit-with-toplevel (mapc (lambda (file) (with-current-buffer (find-file-noselect file) (save-excursion (goto-char (point-min)) (funcall fn)))) (magit-list-files))))
You will have to pass a function to this function, like for