[Date Prev][Date Next][Thread Prev][][Date Index][Thread Index]

Re: following .txt link point at eob

In [emacs-w3m : No.11302] Kevin Ryde wrote:
> Incidentally, in that func

I.e. `w3m-create-text-page' that modifies contents of a w3m-mode
buffer which is normally kept read-only.

> is there more virtue in let-binding
> buffer-read-only, as opposed to inhibit-read-only?  I had
> buffer-read-only in some of my own code too and then wondered if it was
> wise to let-bind a buffer-local variable.  The elisp manual doesn't seem
> to have much guidance, and even reads like maybe it doesn't matter.

What `inhibit-read-only' was first introduced in was Emacs 19.13
(by RMS), so to bind `buffer-read-only' may be a trace of
the Emacs 18 era.  In Gnus, Stefan Monnier seems to have changed
`buffer-read-only' to `inhibit-read-only' though it's not been

egrep '\(buffer-read-only( nil|\))' *.el| wc -l
 => 57
grep '(inhibit-read-only t)' *.el| wc -l
 => 106

In emacs-w3m and shimbun, those are 24 and 2 respectively.  Wow!

I guess Emacs sees `inhibit-read-only' first and then
`buffer-read-only' (iff the former is nil) to check if the buffer
is writable.  So, the code that uses `inhibit-read-only' may be
faster than the one using `buffer-read-only'.  I feel the use of
`inhibit-read-only' reasonable if it is used for overriding the
read-only'ness of a buffer temporarily.