Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Help in Emacs

55 views
Skip to first unread message

Rupam Jaiswal

unread,
Oct 17, 2008, 5:57:59 AM10/17/08
to jo...@gnu.org, help-gn...@gnu.org, c...@stupidchicken.com, mon...@iro.umontreal.ca

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

 

Chong Yidong

unread,
Oct 17, 2008, 4:03:49 PM10/17/08
to Rupam Jaiswal, help-gn...@gnu.org, jo...@gnu.org, mon...@iro.umontreal.ca
"Rupam Jaiswal" <rup...@rediff.co.in> writes:

> 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.


Kevin Rodgers

unread,
Oct 18, 2008, 12:47:28 AM10/18/08
to help-gn...@gnu.org

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

Michael Ekstrand

unread,
Oct 18, 2008, 10:32:01 AM10/18/08
to

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>.

0 new messages