GNU bug report logs - #75313
31.0.50; ERC 5.6.1-git: M-w cannot copy multiline text when kill-ring-deindent-mode is on

Previous Next

Package: emacs;

Reported by: DU Zaichuan <du <at> zaichuan.net>

Date: Fri, 3 Jan 2025 13:20:02 UTC

Severity: normal

Found in version 31.0.50

To reply to this bug, email your comments to 75313 AT debbugs.gnu.org.

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#75313; Package emacs. (Fri, 03 Jan 2025 13:20:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to DU Zaichuan <du <at> zaichuan.net>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 03 Jan 2025 13:20:03 GMT) Full text and rfc822 format available.

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

From: DU Zaichuan <du <at> zaichuan.net>
To: bug-gnu-emacs <at> gnu.org
Subject: 31.0.50; ERC 5.6.1-git: M-w cannot copy multiline text when
 kill-ring-deindent-mode is on
Date: Fri, 03 Jan 2025 11:43:00 +0100
To reproduce the bug in emacs -Q,

1. (kill-ring-deindent-mode t)

2. open erc and join any channel.

3. try to copy with M-w someone's message or the channel notice.

When using the set-mark-command to highlight the texts, message gives
"kill-ring-deindent-buffer-substring-function: Text is read-only".

In GNU Emacs 31.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version
 3.24.43, cairo version 1.18.2) of 2024-12-28 built on arch
Repository revision: af3bbc83600bec6c8621e1b04437dbfdeb329106
Repository branch: HEAD
System Description: Arch Linux

Configured using:
 'configure --with-native-compilation=aot --with-pgtk'

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
LCMS2 LIBOTF LIBSYSTEMD LIBXML2 MODULES NATIVE_COMP NOTIFY INOTIFY
PDUMPER PGTK PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF
TOOLKIT_SCROLL_BARS TREE_SITTER WEBP XIM GTK3 ZLIB

Important settings:
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

-- 
Best regards,
Zaichuan 在川 (he/him)
https://zaichuan.net




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#75313; Package emacs. (Fri, 03 Jan 2025 20:11:01 GMT) Full text and rfc822 format available.

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

From: "J.P." <jp <at> neverwas.me>
To: DU Zaichuan <du <at> zaichuan.net>
Cc: Po Lu <luangruo <at> yahoo.com>, emacs-erc <at> gnu.org, 75313 <at> debbugs.gnu.org
Subject: Re: bug#75313: 31.0.50; ERC 5.6.1-git: M-w cannot copy multiline
 text when kill-ring-deindent-mode is on
Date: Fri, 03 Jan 2025 12:10:16 -0800
DU Zaichuan via "Bug reports for GNU Emacs, the Swiss army knife of text
editors" <bug-gnu-emacs <at> gnu.org> writes:

> To reproduce the bug in emacs -Q,
>
> 1. (kill-ring-deindent-mode t)
>
> 2. open erc and join any channel.
>
> 3. try to copy with M-w someone's message or the channel notice.

Thanks. A slightly distilled version, sans ERC:

  1. M-x kill-ring-deindent-mode RET
  2. M-: (insert (propertize "(progn\n  1\n  2\n  3)" 'read-only t)) RET
  3. C-SPC
  4. C-P ; error: Text is read-only
  5. M-w ; error: Text is read-only

>
> When using the set-mark-command to highlight the texts, message gives
> "kill-ring-deindent-buffer-substring-function: Text is read-only".

Indeed. It seems all `filter-buffer-substring-function' advice members,
like `kill-ring-deindent-buffer-substring-function', run after every
command when the region is active because `region-extract-function'
needs to supply `gui-set-selection' with the region's text. I see two
ways of dealing with this:

1. Local advice around `filter-buffer-substring-function'.

   (defun erc--filter-buffer-substring (orig &rest args)
     (if (eq this-command #'kill-ring-save)
         (with-silent-modifications (apply orig args))
       (apply orig args)))
  
   So, somewhere in ERC's major-mode setup, we'd do:

   (add-function :around (local 'filter-buffer-substring-function)
                 #'erc--filter-buffer-substring)

   However, this won't do anything for "Text is read only" spam related
   to other commands, like `previous-line' or `move-end-of-line' (when
   the region is active). But it should at least restore the ability to
   copy with M-w.

2. Address this somewhere in lisp/indent-aux.el.

   Binding `inhibit-read-only' to t around the call to `indent-rigidly'
   in `kill-ring-deindent-buffer-substring-function' seems to help in
   cursory experiments. Not sure if that's the right move, though.
   Perhaps Po Lu (Cc'd) has some insights.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#75313; Package emacs. (Fri, 24 Jan 2025 00:33:02 GMT) Full text and rfc822 format available.

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

From: "J.P." <jp <at> neverwas.me>
To: Po Lu <luangruo <at> yahoo.com>
Cc: DU Zaichuan <du <at> zaichuan.net>, emacs-erc <at> gnu.org, 75313 <at> debbugs.gnu.org
Subject: Re: bug#75313: 31.0.50; ERC 5.6.1-git: M-w cannot copy multiline
 text when kill-ring-deindent-mode is on
Date: Thu, 23 Jan 2025 16:32:08 -0800
Po Lu,

Hi. Just wondering if you might look at this when you get a chance. No
rush, of course, and TIA.

"J.P." <jp <at> neverwas.me> writes:

> DU Zaichuan <du <at> zaichuan.net> writes:
>
>> To reproduce the bug in emacs -Q,
>> 1. (kill-ring-deindent-mode t)
>> 2. open erc and join any channel.
>> 3. try to copy with M-w someone's message or the channel notice.
>
> Thanks. A slightly distilled version, sans ERC:
>
>   1. M-x kill-ring-deindent-mode RET
>   2. M-: (insert (propertize "(progn\n  1\n  2\n  3)" 'read-only t)) RET
>   3. C-SPC
>   4. C-P ; error: Text is read-only
>   5. M-w ; error: Text is read-only
>
>> When using the set-mark-command to highlight the texts, message gives
>> "kill-ring-deindent-buffer-substring-function: Text is read-only".
>
> Indeed. It seems all `filter-buffer-substring-function' advice members,
> like `kill-ring-deindent-buffer-substring-function', run after every
> command when the region is active because `region-extract-function'
> needs to supply `gui-set-selection' with the region's text. I see two
> ways of dealing with this:
>
> 1. Local advice around `filter-buffer-substring-function'.
>
>    (defun erc--filter-buffer-substring (orig &rest args)
>      (if (eq this-command #'kill-ring-save)
>          (with-silent-modifications (apply orig args))
>        (apply orig args)))
>   
>    So, somewhere in ERC's major-mode setup, we'd do:
>
>    (add-function :around (local 'filter-buffer-substring-function)
>                  #'erc--filter-buffer-substring)
>
>    However, this won't do anything for "Text is read only" spam related
>    to other commands, like `previous-line' or `move-end-of-line' (when
>    the region is active). But it should at least restore the ability to
>    copy with M-w.
>
> 2. Address this somewhere in lisp/indent-aux.el.
>
>    Binding `inhibit-read-only' to t around the call to `indent-rigidly'
>    in `kill-ring-deindent-buffer-substring-function' seems to help in
>    cursory experiments. Not sure if that's the right move, though.
>    Perhaps Po Lu (Cc'd) has some insights.




This bug report was last modified 204 days ago.

Previous Next


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