emacs-31 b6412271e13: Fix copy-by-mouse in *Backtrace* buffers

Eli Zaretskii <[email protected]> Mon, 13 Jul 2026 08:14:44 -0400 (EDT)
Newsgroups gmane.emacs.diffs
Message-ID <[email protected]>
branch: emacs-31
commit b6412271e133fcb04fd3cebcfc1b9226f387b941
Author: Eli Zaretskii <[email protected]>
Commit: Eli Zaretskii <[email protected]>

    Fix copy-by-mouse in *Backtrace* buffers
    
    * lisp/emacs-lisp/backtrace.el (backtrace--filter-visible):
    Support BEG and END in reverse order.  Patch by Jakub
    T. Jankiewicz <[email protected]>.  (Bug#81365)
---
 lisp/emacs-lisp/backtrace.el | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lisp/emacs-lisp/backtrace.el b/lisp/emacs-lisp/backtrace.el
index 440061e6e29..dfdd026dd4f 100644
--- a/lisp/emacs-lisp/backtrace.el
+++ b/lisp/emacs-lisp/backtrace.el
@@ -813,7 +813,11 @@ Fall back to `prin1' if there is an error."
 
 (defun backtrace--filter-visible (beg end &optional _delete)
   "Return the visible text between BEG and END."
-  (let ((result ""))
+  (let ((result "")
+        (b (min beg end))
+        (e (max beg end)))
+    ;; Make sure BEG and END are in the correct order.
+    (setq beg b end e)
     (while (< beg end)
       (let ((next (next-single-char-property-change beg 'invisible)))
         (unless (get-char-property beg 'invisible)