I want to be able to tell emacs to open files in read-only mode or in auto-revert mode by providing a command line argument, for example:
emacs -A file1 file2 file3 ...
should open files in auto-revert mode
emacs -R file1 file2 file3 ...
should open files in read-only mode
I have found the following:
(defun open-read-only (switch)
(let ((file1 (expand-file-name (pop command-line-args-left))))
(find-file-read-only file1)))
(add-to-list 'command-switch-alist '("-R" . open-read-only))
(defun open-tail-revert (switch)
(let ((file1 (expand-file-name (pop command-line-args-left))))
(find-file-read-only file1)
(auto-revert-tail-mode t)))
(add-to-list 'command-switch-alist '("-A" . open-tail-revert))
the problem with this is that it only works for a single file at a time.
i.e.
emacs -R file1
works, but
emacs -R file1 file2
does not work.
How to change the functions above so that they could open several files simultaneously in the specified modes? Could someone suggest a simple and elegant solution?