GNU bug report logs - #26947
Preserve read-only when debugger with let-bound inhibit-read-only t.

Previous Next

Package: emacs;

Reported by: Keith David Bershatsky <esq <at> lawlist.com>

Date: Tue, 16 May 2017 00:01:01 UTC

Severity: minor

Fixed in version 28.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 26947 in the body.
You can then email your comments to 26947 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#26947; Package emacs. (Tue, 16 May 2017 00:01:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Keith David Bershatsky <esq <at> lawlist.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Tue, 16 May 2017 00:01:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Keith David Bershatsky <esq <at> lawlist.com>
To: Emacs Bug Reports <bug-gnu-emacs <at> gnu.org>
Subject: Preserve read-only when debugger with let-bound inhibit-read-only t.
Date: Mon, 15 May 2017 17:00:14 -0700
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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#26947; Package emacs. (Wed, 17 May 2017 13:35:01 GMT) Full text and rfc822 format available.

Message #8 received at 26947 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Keith David Bershatsky <esq <at> lawlist.com>
Cc: 26947 <at> debbugs.gnu.org
Subject: Re: bug#26947: Preserve read-only when debugger with let-bound
 inhibit-read-only t.
Date: Wed, 17 May 2017 09:34:15 -0400
> 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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#26947; Package emacs. (Wed, 17 May 2017 18:07:01 GMT) Full text and rfc822 format available.

Message #11 received at 26947 <at> debbugs.gnu.org (full text, mbox):

From: Keith David Bershatsky <esq <at> lawlist.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 26947 <at> debbugs.gnu.org
Subject: Re: bug#26947: Preserve read-only when debugger with let-bound
 inhibit-read-only t.
Date: Wed, 17 May 2017 11:05:59 -0700
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 <at> 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.
> 
> ***




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#26947; Package emacs. (Fri, 13 Aug 2021 13:50:01 GMT) Full text and rfc822 format available.

Message #14 received at 26947 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Keith David Bershatsky <esq <at> lawlist.com>
Cc: 26947 <at> debbugs.gnu.org
Subject: Re: bug#26947: Preserve read-only when debugger with let-bound
 inhibit-read-only t.
Date: Fri, 13 Aug 2021 15:49:01 +0200
Keith David Bershatsky <esq <at> 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




bug marked as fixed in version 28.1, send any further explanations to 26947 <at> debbugs.gnu.org and Keith David Bershatsky <esq <at> lawlist.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Fri, 13 Aug 2021 13:51:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 11 Sep 2021 11:24:07 GMT) Full text and rfc822 format available.

This bug report was last modified 3 years and 339 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.