From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: rotlas Newsgroups: gmane.emacs.help Subject: Re: opening a buffer as read-only as default Date: Fri, 20 Nov 2009 00:08:34 -0800 (PST) Message-ID: <26429688.post@talk.nabble.com> References: <26282458.post@talk.nabble.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1258816317 17218 80.91.229.12 (21 Nov 2009 15:11:57 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 21 Nov 2009 15:11:57 +0000 (UTC) To: Help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Nov 21 16:11:50 2009 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1NBrcq-0002Jt-DR for geh-help-gnu-emacs@m.gmane.org; Sat, 21 Nov 2009 16:11:48 +0100 Original-Received: from localhost ([127.0.0.1]:36106 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NBrcp-0000hd-Vp for geh-help-gnu-emacs@m.gmane.org; Sat, 21 Nov 2009 10:11:48 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NBOXx-000085-9x for help-gnu-emacs@gnu.org; Fri, 20 Nov 2009 03:08:49 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NBOXt-00006O-2V for Help-gnu-emacs@gnu.org; Fri, 20 Nov 2009 03:08:49 -0500 Original-Received: from [199.232.76.173] (port=59418 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NBOXs-00006G-IT for Help-gnu-emacs@gnu.org; Fri, 20 Nov 2009 03:08:44 -0500 Original-Received: from mx20.gnu.org ([199.232.41.8]:42215) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NBOXs-0006HA-3U for Help-gnu-emacs@gnu.org; Fri, 20 Nov 2009 03:08:44 -0500 Original-Received: from kuber.nabble.com ([216.139.236.158]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NBOXr-00008d-7m for Help-gnu-emacs@gnu.org; Fri, 20 Nov 2009 03:08:43 -0500 Original-Received: from isper.nabble.com ([192.168.236.156]) by kuber.nabble.com with esmtp (Exim 4.63) (envelope-from ) id 1NBOXi-00033P-Vu for Help-gnu-emacs@gnu.org; Fri, 20 Nov 2009 00:08:34 -0800 In-Reply-To: X-Nabble-From: katofa@gmail.com X-detected-operating-system: by mx20.gnu.org: GNU/Linux 2.6 (newer, 3) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Mailman-Approved-At: Sat, 21 Nov 2009 10:04:05 -0500 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:69997 Archived-At: Thanks, Peter and Kevin for great answers. Now I don't have to undo all unintentional modifications of files everytime I compile... Kevin Rodgers-2 wrote: > > rotlas wrote: >> Which is the simplest way to have Emacs opening all files as read-only? >> That >> is not only by using C-x C-r but also when selecting a file in a >> directory >> buffer. > > ,----[ C-h k v ] > | v runs the command dired-view-file > | which is an interactive compiled Lisp function in `dired.el'. > | It is bound to v, . > | (dired-view-file) > | > | In Dired, examine a file in view mode, returning to Dired when done. > | When file is a directory, show it in this buffer if it is inserted. > | Otherwise, display it in another buffer. > | > | [back] > `---- > >> And also preventing C-x C-f from opening a file as writable. > > (add-hook 'find-file-hook (lambda () (setq buffer-read-only t))) > >> I would like it to be possible to toggle the read-only state, though. > > ,----[ C-h k C-x C-q ] > | C-x C-q runs the command toggle-read-only > | which is an interactive compiled Lisp function in `files.el'. > | It is bound to C-x C-q. > | (toggle-read-only &optional arg) > | > | Change whether this buffer is visiting its file read-only. > | With prefix argument arg, make the buffer read-only if arg is > | positive, otherwise make it writable. If visiting file read-only > | and `view-read-only' is non-nil, enter view mode. > | > | [back] > `---- > > -- > Kevin Rodgers > Denver, Colorado, USA > > > > > -- View this message in context: http://old.nabble.com/opening-a-buffer-as-read-only-as-default-tp26282458p26429688.html Sent from the Emacs - Help mailing list archive at Nabble.com.