unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#26947: Preserve read-only when debugger with let-bound inhibit-read-only t.
@ 2017-05-16  0:00 Keith David Bershatsky
  2017-05-17 13:34 ` Stefan Monnier
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Keith David Bershatsky @ 2017-05-16  0:00 UTC (permalink / raw)
  To: 26947

Entering the debugger when inhibit-read-only is let-bound to `t` causes all buffers to be read/write even though they may have `buffer-read-only` set to `t`.

Step #1:  Launch with emacs -q.

Step #2:  Navigate to the `*scratch*` buffer and set to read-only with C-x C-q.

Step #3:  Evaluate:  (let ((inhibit-read-only t)) (error "stop"))

Step #4:  Select the window display the `*scratch*` buffer and type something.  All open buffers are read/write.

Expected Behavior:  Protect buffers that have previously been set to `buffer-read-only` with `t`.

Workaround:  Add the following to the outset of the function `debug`:

(when inhibit-read-only
  (setq inhibit-read-only nil))

The workaround can be perfected to test for whether inhibit-read-only is let-bound to `t` and if it is then ...  I say that just in case someone wants `inhibit-read-only` to always be `t` and in that case the debugger shouldn't turn it off.

Here is the new thread on emacs.stackexchange.com:

https://emacs.stackexchange.com/questions/32829/inhibit-read-only-affects-all-buffers-when-backtrace-buffer-is-open

Thanks,

Keith





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

* bug#26947: Preserve read-only when debugger with let-bound inhibit-read-only t.
  2017-05-16  0:00 bug#26947: Preserve read-only when debugger with let-bound inhibit-read-only t Keith David Bershatsky
@ 2017-05-17 13:34 ` Stefan Monnier
  2017-05-17 18:05 ` Keith David Bershatsky
  2021-08-13 13:49 ` Lars Ingebrigtsen
  2 siblings, 0 replies; 4+ messages in thread
From: Stefan Monnier @ 2017-05-17 13:34 UTC (permalink / raw)
  To: Keith David Bershatsky; +Cc: 26947

> Entering the debugger when inhibit-read-only is let-bound to `t` causes all
> buffers to be read/write even though they may have `buffer-read-only` set to
> `t`.
[...]
> (when inhibit-read-only
>   (setq inhibit-read-only nil))

Actually, the better option is probably to

    (let ((inhibit-read-only nil))

around debug, like we already do with various other variables.

Of course, this is a general problem with dynamic scoping.

Maybe a better solution would be for `debug` to use another thread, so
it's not affected by those dynamic bindings of the debugged code.


        Stefan





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

* bug#26947: Preserve read-only when debugger with let-bound inhibit-read-only t.
  2017-05-16  0:00 bug#26947: Preserve read-only when debugger with let-bound inhibit-read-only t Keith David Bershatsky
  2017-05-17 13:34 ` Stefan Monnier
@ 2017-05-17 18:05 ` Keith David Bershatsky
  2021-08-13 13:49 ` Lars Ingebrigtsen
  2 siblings, 0 replies; 4+ messages in thread
From: Keith David Bershatsky @ 2017-05-17 18:05 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 26947

Yes, let-binding is indeed better than using `setq`.  Thank you.

Keith

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

DATE:  [05-17-2017 06:34:15] <17 May 2017 09:34:15 -0400>
FROM:  Stefan Monnier <monnier@iro.umontreal.ca>
> 
> ***
> 
> Actually, the better option is probably to
> 
>     (let ((inhibit-read-only nil))
> 
> around debug, like we already do with various other variables.
> 
> ***





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

* bug#26947: Preserve read-only when debugger with let-bound inhibit-read-only t.
  2017-05-16  0:00 bug#26947: Preserve read-only when debugger with let-bound inhibit-read-only t Keith David Bershatsky
  2017-05-17 13:34 ` Stefan Monnier
  2017-05-17 18:05 ` Keith David Bershatsky
@ 2021-08-13 13:49 ` Lars Ingebrigtsen
  2 siblings, 0 replies; 4+ messages in thread
From: Lars Ingebrigtsen @ 2021-08-13 13:49 UTC (permalink / raw)
  To: Keith David Bershatsky; +Cc: 26947

Keith David Bershatsky <esq@lawlist.com> writes:

> Entering the debugger when inhibit-read-only is let-bound to `t`
> causes all buffers to be read/write even though they may have
> `buffer-read-only` set to `t`.
>
> Step #1:  Launch with emacs -q.
>
> Step #2:  Navigate to the `*scratch*` buffer and set to read-only with C-x C-q.
>
> Step #3:  Evaluate:  (let ((inhibit-read-only t)) (error "stop"))
>
> Step #4: Select the window display the `*scratch*` buffer and type
> something.  All open buffers are read/write.

Full test case:

(progn
  (setq debug-on-error t
	buffer-read-only t)
  (let ((inhibit-read-only t)) (error "stop")))

This should now be fixed in Emacs 28.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





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

end of thread, other threads:[~2021-08-13 13:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-16  0:00 bug#26947: Preserve read-only when debugger with let-bound inhibit-read-only t Keith David Bershatsky
2017-05-17 13:34 ` Stefan Monnier
2017-05-17 18:05 ` Keith David Bershatsky
2021-08-13 13:49 ` Lars Ingebrigtsen

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