opensubscriber
   Find in this group all groups
 
Unknown more information…

e : emacs-devel@gnu.org 12 July 2012 • 2:22AM -0400

Re: toggle-read-only should not give compilation warnings
by Glenn Morris

REPLY TO AUTHOR
 
REPLY TO GROUP




Chong Yidong wrote:

> There are lots of toggle-read-only warnings in the Emacs Lisp source
> tree.

I count 10 (excluding obsolete/). Some are probably already suppressed
though. Of these:

cedet/ede/util.el seems obviously wrong.
cedet/semantic/debug.el and vc/ediff.el are unclear to me.
gnus/smime.el seems bugged (fails to ensure a pre-existing buffer is
read-write).
vc/vc-cvs.el seems wrong.
vc/vc.el not immediately clear.

> As far as I can tell, the overwhelming majority of these are all
> legitimate use cases. The typical intention is "do whatever the
> `toggle-read-only' command does, then do some other stuff on top of
> that," so the caveat about toggle-read-only not being used in Lisp
> code is bogus.

The obvious intention is to make the buffer read-only. Often it's
unclear to me whether the author also wanted the "extra stuff" that
toggle-read-only does (which is only view-mode, isn't it?), or just
didn't think about it.

IMO, it would be better to factor out the view mode enabling piece to a
separate function to be explicitly called when necessary after setting
buffer-read-only. This would then remove the ambiguity.

Some issues caused by inappropriate use of toggle-read-only are: 7292,
10006.

Maybe on average it's right to use it as often as it is wrong. A warning
at least might make people thunk about whether they do want to use it.


Bookmark with:

Delicious   Digg   reddit   Facebook   StumbleUpon

Related Messages

opensubscriber is not affiliated with the authors of this message nor responsible for its content.