unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: "J.P." <jp@neverwas.me>
To: DU Zaichuan <du@zaichuan.net>
Cc: Po Lu <luangruo@yahoo.com>, emacs-erc@gnu.org, 75313@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: Fri, 03 Jan 2025 12:10:16 -0800	[thread overview]
Message-ID: <878qrrzmjb.fsf__30595.1627482258$1735935093$gmane$org@neverwas.me> (raw)
In-Reply-To: <871pxkuqiz.fsf@zaichuan.net> (DU Zaichuan via's message of "Fri,  03 Jan 2025 11:43:00 +0100")

DU Zaichuan via "Bug reports for GNU Emacs, the Swiss army knife of text
editors" <bug-gnu-emacs@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.





      reply	other threads:[~2025-01-03 20:10 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-03 10:43 bug#75313: 31.0.50; ERC 5.6.1-git: M-w cannot copy multiline text when kill-ring-deindent-mode is on DU Zaichuan via Bug reports for GNU Emacs, the Swiss army knife of text editors
2025-01-03 20:10 ` J.P. [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='878qrrzmjb.fsf__30595.1627482258$1735935093$gmane$org@neverwas.me' \
    --to=jp@neverwas.me \
    --cc=75313@debbugs.gnu.org \
    --cc=du@zaichuan.net \
    --cc=emacs-erc@gnu.org \
    --cc=luangruo@yahoo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).