help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: emacs switch similar to vi's -R, or view equivalent?


From: Andrew B. Young
Subject: Re: emacs switch similar to vi's -R, or view equivalent?
Date: Wed, 23 Aug 2006 08:37:46 -0700
User-agent: Thunderbird 1.5.0.4 (X11/20060614)

EXACTLY what I'm after!  Thanks so much Kevin.

Thanks also to Peter, William, and Edward for their helpful replies.
I am aware of their suggestions and that's what I have been doing for years.
But it's the command line switch I really wanted--saves keystrokes.

Cheers,
Andrew

Kevin Rodgers wrote:
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)))))






reply via email to

[Prev in Thread] Current Thread [Next in Thread]