Hi,
I am using emacs. Many times, I have to open files just for viewing
and not
for editing.but by mistake some or the other lines get edited.
In order to avoid editing. Is there any way to open emacs in view mode
and not edit mode.(Just like in vi editior,where file can be open in
view mode by command view FileName).
Regards
Rupam
> In order to avoid editing. Is there any way to open emacs in view mode
> and not edit mode.(Just like in vi editior,where file can be open in
> view mode by command view FileName).
C-x C-r visits a file in read-only mode.
Or from the command line:
emacs --eval "(find-file-read-only \"Please Hammer Don't Hurt 'Em.txt\")"
You can also define a new command line option, like this:
;; Usage: emacs --read-only FILE
(defun command-line-find-file-read-only (switch)
(find-file-read-only (pop command-line-args-left)))
(add-to-list 'command-switch-alist
'("--read-only" . command-line-find-file-read-only))
--
Kevin Rodgers
Denver, Colorado, USA
There is the command `view-file' which will open a file read-only; in my
Emacs, it does not seem to be bound to any key, but you could bind it to
some convenient key in your .emacs.
Also, after opening a file, you can type C-x C-q (`toggle-read-only') to
put it in read-only mode. In the default mode line, this will also
result in two % characters in the left end of the mode line, indicating
that the file is read-only.
- Michael
--
mouse, n: A device for pointing at the xterm in which you want to type.
Confused by the strange files? I cryptographically sign my messages.
For more information see <http://www.elehack.net/resources/gpg>.