unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* view-read-only causes read-write
@ 2003-04-17  1:59 Dan Jacobson
  0 siblings, 0 replies; 4+ messages in thread
From: Dan Jacobson @ 2003-04-17  1:59 UTC (permalink / raw)


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?

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.

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?

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.

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.

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.

  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.
-- 
http://jidanni.org/ Taiwan(04)25854780

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: view-read-only causes read-write
       [not found] <mailman.4772.1050547956.21513.bug-gnu-emacs@gnu.org>
@ 2003-04-17 17:10 ` Kevin Rodgers
  2003-04-21  1:17   ` Dan Jacobson
       [not found]   ` <mailman.4998.1050903900.21513.bug-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 4+ messages in thread
From: Kevin Rodgers @ 2003-04-17 17:10 UTC (permalink / raw)


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.

-- 
<a href="mailto:&lt;kevin.rodgers&#64;ihs.com&gt;">Kevin Rodgers</a>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: view-read-only causes read-write
  2003-04-17 17:10 ` Kevin Rodgers
@ 2003-04-21  1:17   ` Dan Jacobson
       [not found]   ` <mailman.4998.1050903900.21513.bug-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 4+ messages in thread
From: Dan Jacobson @ 2003-04-21  1:17 UTC (permalink / raw)


K> No.  You don't understand that the variable is read to indicate to the user
K> that view mode is on, and that the view-mode function is used to invoke the
K> mode.

Ok, whatever.  I thought

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

meant that if we set it to t, then when we visit read-only buffers, we
will visit them in view mode.

No wonder. I thought the English in the docstring sounded a little
funny, but assumed that it was written by one of those developers with
international flair.

Ok, maybe the docstring could be beefed up to reveal its actual pu 

>> OK, but what about read-only buffers not visiting files? Obviously
>> you are over affecting those and at the same time not mentioning them.

K> M-x pick-nit

Well, you seem to say I had a minor point instead of being totally
wrong.  Therefore that minor point should be cleaned up at the same
time, whatever it was.

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

K> Of course.  Symbolic expressions are well-defined: (function arg
K> ...).  In order to evaluate multiple sexps in sequence, use (progn
K> ...) or multiple --eval command line options.

Ok, then can't we sting the user with an error message like that then?
Are we rude to at least inform them that there is crud at the end of
their $ emacs -eval sequence that will not get eval'ed, or will they
snap back "of course, I put that there on purpose!" (what propose?)
-- 
http://jidanni.org/ Taiwan(04)25854780

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: view-read-only causes read-write
       [not found]   ` <mailman.4998.1050903900.21513.bug-gnu-emacs@gnu.org>
@ 2003-04-21 16:39     ` Kevin Rodgers
  0 siblings, 0 replies; 4+ messages in thread
From: Kevin Rodgers @ 2003-04-21 16:39 UTC (permalink / raw)


Dan Jacobson wrote:

>>>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.
> 
> K> Of course.  Symbolic expressions are well-defined: (function arg
> K> ...).  In order to evaluate multiple sexps in sequence, use (progn
> K> ...) or multiple --eval command line options.
> 
> Ok, then can't we sting the user with an error message like that then?
> Are we rude to at least inform them that there is crud at the end of
> their $ emacs -eval sequence that will not get eval'ed, or will they
> snap back "of course, I put that there on purpose!" (what propose?)


Here's a patch.  The error message could easily be improved to include
the entire expression or just the trailing garbage.

2003-04-21  Kevin Rodgers  <ihs_4664@yahoo.com>

	* startup.el (command-line-1): Signal an error if there is trailing
	garbage following the --eval expression.


*** emacs-20.7/lisp/startup.el.orig	Sun Aug  1 19:12:00 1999
--- emacs-20.7/lisp/startup.el	Mon Apr 21 10:30:43 2003
***************
*** 1065,1071 ****
  		     (setq tem argval)
  		   (setq tem (car command-line-args-left))
  		   (setq command-line-args-left (cdr command-line-args-left)))
! 		 (eval (read tem)))
  		;; Set the default directory as specified in -L.
  		((or (string-equal argi "-L")
  		     (string-equal argi "-directory"))
--- 1065,1074 ----
  		     (setq tem argval)
  		   (setq tem (car command-line-args-left))
  		   (setq command-line-args-left (cdr command-line-args-left)))
! 		 (let ((sexp-length (read-from-string tem)))
! 		   (or (= (cdr sexp-lenth) (length tem))
! 		       (error "Trailing garbage following expression"))
! 		   (eval (car sexp-length))))
  		;; Set the default directory as specified in -L.
  		((or (string-equal argi "-L")
  		     (string-equal argi "-directory"))


-- 
<a href="mailto:&lt;kevin.rodgers&#64;ihs.com&gt;">Kevin Rodgers</a>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2003-04-21 16:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-04-17  1:59 view-read-only causes read-write Dan Jacobson
     [not found] <mailman.4772.1050547956.21513.bug-gnu-emacs@gnu.org>
2003-04-17 17:10 ` Kevin Rodgers
2003-04-21  1:17   ` Dan Jacobson
     [not found]   ` <mailman.4998.1050903900.21513.bug-gnu-emacs@gnu.org>
2003-04-21 16:39     ` Kevin Rodgers

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).