Andrew B. Young wrote:
Is there an emacs switch similar to vi's -R, or view equivalent?
I use emacs regularly but find "view this_file" very comforting,
e.g., sudo view /etc/aliases. This forces me to ! the write as
an extra measure of safety.
My guess is that I need a special init file that gets loaded via an
alias, i.e., "ev this_file".
Here's a gem from 1997
(http://groups.google.com/group/gnu.emacs.help/msg/46410ee284d11cc0):
(setq command-switch-alist
(cons '("--read-only" . find-file-read-only-command-line-arg) ;
"-R"
command-switch-alist))
(defun find-file-read-only-command-line-arg (switch)
"Visit next command line argument (after SWITCH) as a read-only file."
;; (prog1 (car x) (setq x (cdr x))) == (pop x):
(find-file-read-only (prog1 (car command-line-args-left)
(setq command-line-args-left
(cdr command-line-args-left)))))