From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Kevin Rodgers Newsgroups: gmane.emacs.bugs Subject: Re: view-read-only causes read-write Date: Thu, 17 Apr 2003 11:10:29 -0600 Sender: bug-gnu-emacs-bounces+gnu-bug-gnu-emacs=m.gmane.org@gnu.org Message-ID: <3E9EE005.1040408@yahoo.com> References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Trace: main.gmane.org 1050599591 2475 80.91.224.249 (17 Apr 2003 17:13:11 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Thu, 17 Apr 2003 17:13:11 +0000 (UTC) Original-X-From: bug-gnu-emacs-bounces+gnu-bug-gnu-emacs=m.gmane.org@gnu.org Thu Apr 17 19:13:08 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 196Cub-0000Ub-00 for ; Thu, 17 Apr 2003 19:11:01 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 196Cv7-0007Bn-01 for gnu-bug-gnu-emacs@m.gmane.org; Thu, 17 Apr 2003 13:11:33 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10.13) id 196Cuv-0006vN-00 for bug-gnu-emacs@prep.ai.mit.edu; Thu, 17 Apr 2003 13:11:21 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10.13) id 196CuI-0005xZ-00 for bug-gnu-emacs@prep.ai.mit.edu; Thu, 17 Apr 2003 13:10:43 -0400 Original-Received: from chx400.switch.ch ([130.59.10.2]) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 196Cu0-0005jz-00 for bug-gnu-emacs@prep.ai.mit.edu; Thu, 17 Apr 2003 13:10:24 -0400 Original-Received: from mail.fu-berlin.de ([160.45.11.165]) by chx400.switch.ch with esmtp (Exim 3.20 #1) id 196Ctz-0006qm-00 for gnu-emacs-bug@moderators.isc.org; Thu, 17 Apr 2003 19:10:23 +0200 Original-Received: by mail.fu-berlin.de (Smail3.2.0.98) from Curry.ZEDAT.FU-Berlin.DE (160.45.10.36) with esmtp id ; Thu, 17 Apr 2003 19:10:22 +0200 (MEST) Original-Received: by Curry.ZEDAT.FU-Berlin.DE (Smail3.2.0.98) from news.fu-berlin.de with bsmtp id ; Thu, 17 Apr 2003 19:10:22 +0200 (MEST) Original-To: gnu-emacs-bug@moderators.isc.org Original-Path: 170.207.51.80!not-for-mail Original-Newsgroups: gnu.emacs.bug Original-Lines: 86 X-Orig-NNTP-Posting-Host: 170.207.51.80 X-Orig-X-Trace: fu-berlin.de 1050599422 2796453 170.207.51.80 (16 [82742]) User-Agent: Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv:0.9.4.1) Gecko/20020406 Netscape6/6.2.2 X-Accept-Language: en-us X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Bug reports for GNU Emacs, the Swiss army knife of text editors List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: bug-gnu-emacs-bounces+gnu-bug-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.bugs:4832 X-Report-Spam: http://spam.gmane.org/gmane.emacs.bugs:4832 Dan Jacobson wrote: > I did > $ emacs --no-site-file -q -nw -eval ' > (and(setq view-read-only t) (describe-variable (quote > view-read-only)))' > > Notes: > 1. Ok, the help buffer says View mode in the modeline, but how about > turning on the -%%- marker in the modeline? Setting that variable is not the right way to turn on View mode. Setting any variable is never the right the right way to turn on a mode. Use the mode's function. > 2. Hey, real view-mode doesn't let me eat text with C-k etc, and then > you can't repair the damage with undo because no undo record is > kept for that buffer. If you want the buffer in View mode, run the view-mode function. > 3. OK, trying again without messing first with view-read-only > gives what one expects. > > Do I smell someone toggling read-only once too much? No. You don't understand that the variable is read to indicate to the user that view mode is on, and that the view-mode function is used to invoke the mode. > 4. view-read-only's docstring: "*Non-nil means buffers visiting files > read-only, do it in view mode." (P.S. I assume the "*" means > "Chef's choice".) > > OK, but what about read-only buffers not visiting files? Obviously > you are over affecting those and at the same time not mentioning them. M-x pick-nit > P.S. I am no lisp pro but above I had to use an "(and ...)" or else > only one sexp was used, without any warning to the user. Of course. Symbolic expressions are well-defined: (function arg ...). In order to evaluate multiple sexps in sequence, use (progn ...) or multiple --eval command line options. > PSS, while we are here, let's examine this docstring: > toggle-read-only is an interactive compiled Lisp function in `files'. > (toggle-read-only &optional ARG) > > Change whether this buffer is visiting its file read-only. > With arg, set read-only iff arg is positive. > > Ok, but it doesn't say what will happen if you give it a non positive > arg. One can't just assume "common sense". E.g. me, any common sense > and I wouldn't be hanging around this pop stand. "iff" means "if and only if", which is a well-defined logical operator. It means that if arg is not positive, unset read-only. > If visiting file read-only and `view-read-only' is non-nil, enter view mode. > > Hold on a second. We came here to toggle-read-only and like wham, we > are sent into view mode. It's like I do "chmod -w file" and wham, "more > file" is invoked as a free bonus. What if I am a batch job? Anyway, > docsting looks bad. Didn't check the code. Then do (setq read-only t) instead of (toggle-read-only 1) to avoid the side effects. -- Kevin Rodgers