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

Full log


View this message in rfc822 format

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