GNU bug report logs - #43844
27.1; Mouse-3 avoid "Buffer is read-only" *patch*

Previous Next

Package: emacs;

Reported by: Corwin Brust <corwin <at> bru.st>

Date: Wed, 7 Oct 2020 11:35:02 UTC

Severity: minor

Tags: notabug

Found in version 27.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 43844 in the body.
You can then email your comments to 43844 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#43844; Package emacs. (Wed, 07 Oct 2020 11:35:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Corwin Brust <corwin <at> bru.st>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 07 Oct 2020 11:35:02 GMT) Full text and rfc822 format available.

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

From: Corwin Brust <corwin <at> bru.st>
To: bug-gnu-emacs <at> gnu.org
Subject: 27.1; Mouse-3 avoid "Buffer is read-only" *patch*
Date: Wed, 7 Oct 2020 06:34:08 -0500
[Message part 1 (text/plain, inline)]
In Dired, ERC, and, I assume, any read-only buffer the default behavior of
mouse-3 causes errors (E.g. "kill-region: Buffer is read-only: #<buffer
*Messages*>").

The attached patch attempts to prevent this by detecting a
read-only-buffer.  Unfortunately, it seems that ERC has some other means
of causing its buffers to be rendered read-only that doesn't affect
this var, thus the special-case logic.  I tested with dired, erc, and
(regression tested) while composing this bug report.

Are there other edge cases like erc-mode hanging around, where
read-only-buffer might not be accurate?  Is this oddity with ERC worth a
separate bug report?  Finally, s there a more elegant way to special
case whatever erc-mode is doing?

This is my first attempt at submitting a patch.  I will dig a bit more
into my own questions, above; tia for tips, suggestions, etc.

In GNU Emacs 27.1 (build 1, x86_64-w64-mingw32)
 of 2020-08-21 built on CIRROCUMULUS
Repository revision: 86d8d76aa36037184db0b2897c434cdaab1a9ae8
Repository branch: HEAD
Windowing system distributor 'Microsoft Corp.', version 10.0.18363
System Description: Microsoft Windows 10 Home (v10.0.1909.18363.1082)

Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.

Configured using:
 'configure --without-dbus --host=x86_64-w64-mingw32
 --without-compress-install 'CFLAGS=-O2 -static''

Configured features:
XPM JPEG TIFF GIF PNG RSVG SOUND NOTIFY W32NOTIFY ACL GNUTLS LIBXML2
HARFBUZZ ZLIB TOOLKIT_SCROLL_BARS MODULES THREADS JSON PDUMPER LCMS2 GMP

Important settings:
  value of $LANG: ENU
  locale-coding-system: cp1252

Major mode: Lisp Interaction

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message rmc puny dired dired-loaddefs
format-spec rfc822 mml easymenu mml-sec password-cache epa derived epg
epg-config gnus-util rmail rmail-loaddefs text-property-search time-date
subr-x seq byte-opt gv bytecomp byte-compile cconv mm-decode mm-bodies
mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader cl-loaddefs
cl-lib sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils
tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type
mwheel dos-w32 ls-lisp disp-table term/w32-win w32-win w32-vars
term/common-win tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode elisp-mode lisp-mode
prog-mode register page tab-bar menu-bar rfn-eshadow isearch timer
select scroll-bar mouse jit-lock font-lock syntax facemenu font-core
term/tty-colors frame minibuffer cl-generic cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms
cp51932 hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese composite charscript charprop case-table epa-hook
jka-cmpr-hook help simple abbrev obarray cl-preloaded nadvice loaddefs
button faces cus-face macroexp files text-properties overlay sha1 md5
base64 format env code-pages mule custom widget hashtable-print-readable
backquote threads w32notify w32 lcms2 multi-tty make-network-process
emacs)

Memory information:
((conses 16 46659 8583)
 (symbols 48 6075 1)
 (strings 32 16982 2021)
 (string-bytes 1 519943)
 (vectors 16 9274)
 (vector-slots 8 123598 13156)
 (floats 8 22 312)
 (intervals 56 222 0)
 (buffers 1000 12))


Corwin
[Message part 2 (text/html, inline)]
[mouse-3_no-kill-when-readonly-or-erc-mode.patch (application/octet-stream, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#43844; Package emacs. (Wed, 07 Oct 2020 15:15:02 GMT) Full text and rfc822 format available.

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

From: Noam Postavsky <npostavs <at> gmail.com>
To: Corwin Brust <corwin <at> bru.st>
Cc: 43844 <at> debbugs.gnu.org
Subject: Re: bug#43844: 27.1; Mouse-3 avoid "Buffer is read-only" *patch*
Date: Wed, 07 Oct 2020 11:14:39 -0400
Corwin Brust <corwin <at> bru.st> writes:

> In Dired, ERC, and, I assume, any read-only buffer the default behavior of
> mouse-3 causes errors (E.g. "kill-region: Buffer is read-only: #<buffer
> *Messages*>").

I think you just need to set the kill-read-only-ok option.

    kill-read-only-ok is a variable defined in ‘simple.el’.
    Its value is nil

    Documentation:
    Non-nil means don’t signal an error for killing read-only text.

> Unfortunately, it seems that ERC has some other means of causing its
> buffers to be rendered read-only that doesn't affect this var, thus
> the special-case logic.

I'm guessing ERC marks only some of text as read-only via text
properties.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#43844; Package emacs. (Wed, 27 Jan 2021 05:38:02 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Noam Postavsky <npostavs <at> gmail.com>
Cc: 43844 <at> debbugs.gnu.org, Corwin Brust <corwin <at> bru.st>
Subject: Re: bug#43844: 27.1; Mouse-3 avoid "Buffer is read-only" *patch*
Date: Wed, 27 Jan 2021 06:37:44 +0100
Noam Postavsky <npostavs <at> gmail.com> writes:

> I think you just need to set the kill-read-only-ok option.
>
>     kill-read-only-ok is a variable defined in ‘simple.el’.
>     Its value is nil
>
>     Documentation:
>     Non-nil means don’t signal an error for killing read-only text.

So I think this works as designed, and I'm closing this bug report.

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




Added tag(s) notabug. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Wed, 27 Jan 2021 05:39:01 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 43844 <at> debbugs.gnu.org and Corwin Brust <corwin <at> bru.st> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Wed, 27 Jan 2021 05:39:01 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#43844; Package emacs. (Thu, 28 Jan 2021 20:21:02 GMT) Full text and rfc822 format available.

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

From: Corwin Brust <corwin <at> bru.st>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 43844 <at> debbugs.gnu.org, Noam Postavsky <npostavs <at> gmail.com>
Subject: Re: bug#43844: 27.1; Mouse-3 avoid "Buffer is read-only" *patch*
Date: Thu, 28 Jan 2021 14:20:15 -0600
[Message part 1 (text/plain, inline)]
Hi Lars,

Apologies for not having followed-up on this and thank you for lending it
your attention.

On Tue, Jan 26, 2021 at 11:37 PM Lars Ingebrigtsen <larsi <at> gnus.org> wrote:

> Noam Postavsky <npostavs <at> gmail.com> writes:
>
> > I think you just need to set the kill-read-only-ok option.
> >
> >     kill-read-only-ok is a variable defined in ‘simple.el’.
> >     Its value is nil
> >
> >     Documentation:
> >     Non-nil means don’t signal an error for killing read-only text.
>
> So I think this works as designed, and I'm closing this bug report.
>

I disagree this behavior makes sense.

Should it be the users responsibility to set this variable (in some hook?
which?) for any buffers that default to read-only?

Again, thanks!


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


-- 
*Corwin*
*corwin <at> bru.st <corwin <at> bru.st>*
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#43844; Package emacs. (Fri, 29 Jan 2021 05:03:01 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Corwin Brust <corwin <at> bru.st>
Cc: 43844 <at> debbugs.gnu.org, Noam Postavsky <npostavs <at> gmail.com>
Subject: Re: bug#43844: 27.1; Mouse-3 avoid "Buffer is read-only" *patch*
Date: Fri, 29 Jan 2021 06:02:26 +0100
Corwin Brust <corwin <at> bru.st> writes:

> Should it be the users responsibility to set this variable (in some
> hook? which?) for any buffers that default to read-only?

Yes.  Some buffers have read-only text, and killing that text will
signal an error (by design), whether you kill the text using the mouse
or with `C-w'.  If the user wants to be able to kill the text, then the
user should set that variable.

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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#43844; Package emacs. (Fri, 29 Jan 2021 15:11:01 GMT) Full text and rfc822 format available.

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

From: Corwin Brust <corwin <at> bru.st>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 43844 <at> debbugs.gnu.org, Noam Postavsky <npostavs <at> gmail.com>
Subject: Re: bug#43844: 27.1; Mouse-3 avoid "Buffer is read-only" *patch*
Date: Fri, 29 Jan 2021 09:10:04 -0600
Thanks again Lars.

On Thu, Jan 28, 2021 at 11:02 PM Lars Ingebrigtsen <larsi <at> gnus.org> wrote:
>
> Corwin Brust <corwin <at> bru.st> writes:
>
> > Should it be the users responsibility to set this variable (in some
> > hook? which?) for any buffers that default to read-only?
>
> Yes.  Some buffers have read-only text, and killing that text will
> signal an error (by design), whether you kill the text using the mouse
> or with `C-w'.  If the user wants to be able to kill the text, then the
> user should set that variable.

Would you recommend packages such as ERC (or dired?) that essentially
create only read-only buffers to set this such that unconfigured
defaults don't lead to a user-error?

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


Regards,
Corwin




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#43844; Package emacs. (Sat, 30 Jan 2021 06:15:01 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Corwin Brust <corwin <at> bru.st>
Cc: 43844 <at> debbugs.gnu.org, Noam Postavsky <npostavs <at> gmail.com>
Subject: Re: bug#43844: 27.1; Mouse-3 avoid "Buffer is read-only" *patch*
Date: Sat, 30 Jan 2021 07:14:07 +0100
Corwin Brust <corwin <at> bru.st> writes:

> Would you recommend packages such as ERC (or dired?) that essentially
> create only read-only buffers to set this such that unconfigured
> defaults don't lead to a user-error?

I'm not sure what you mean here?  Buffers that make text read-only do so
because the person who wrote that mode thinks that's a good design
decision.  As usual, Emacs allows users to override anything if they
want to, and `kill-read-only-ok' is the provided user override.

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




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

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

Previous Next


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