unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#75313: 31.0.50; ERC 5.6.1-git: M-w cannot copy multiline text when kill-ring-deindent-mode is on
@ 2025-01-03 10:43 DU Zaichuan via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2025-01-03 20:10 ` J.P.
  0 siblings, 1 reply; 2+ messages in thread
From: DU Zaichuan via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2025-01-03 10:43 UTC (permalink / raw)
  To: 75313

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





^ permalink raw reply	[flat|nested] 2+ messages in thread

* bug#75313: 31.0.50; ERC 5.6.1-git: M-w cannot copy multiline text when kill-ring-deindent-mode is on
  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.
  0 siblings, 0 replies; 2+ messages in thread
From: J.P. @ 2025-01-03 20:10 UTC (permalink / raw)
  To: DU Zaichuan; +Cc: Po Lu, emacs-erc, 75313

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.





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-01-03 20:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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.

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