]> git.eshelyaron.com Git - emacs.git/commitdiff
(perform-replace): Make it work with F-keys in TTYs (bug#78113)
authorStefan Monnier <monnier@iro.umontreal.ca>
Thu, 22 May 2025 13:32:33 +0000 (09:32 -0400)
committerEshel Yaron <me@eshelyaron.com>
Tue, 27 May 2025 14:30:59 +0000 (16:30 +0200)
* lisp/replace.el (perform-replace): Use `read-key`.
* test/lisp/replace-tests.el (replace-tests-with-undo): Adjust accordingly.

(cherry picked from commit 772c4f036c38efd2a81d3643ad0bd718033d3b7f)

lisp/replace.el
test/lisp/replace-tests.el

index 2d60dcae9391fadf20ac3a1e39f703573ecc2360..f88c181f33b07b9ed4a226b951c98ccc39c86d6f 100644 (file)
@@ -3068,20 +3068,21 @@ characters."
                            (set-match-data real-match-data)
                            (match-substitute-replacement
                             next-replacement nocasify literal))))
-                 ;; Bind message-log-max so we don't fill up the
-                 ;; message log with a bunch of identical messages.
-                 (let ((message-log-max nil)
-                       (replacement-presentation
-                        (if query-replace-show-replacement
-                            (save-match-data
-                              (set-match-data real-match-data)
-                              (match-substitute-replacement next-replacement
-                                                            nocasify literal))
-                          next-replacement)))
-                   (message message
-                             (query-replace-descr from-string)
-                             (query-replace-descr replacement-presentation)))
-                 (setq key (read-event))
+                 (let* ((replacement-presentation
+                         (if query-replace-show-replacement
+                             (save-match-data
+                               (set-match-data real-match-data)
+                               (match-substitute-replacement next-replacement
+                                                             nocasify literal))
+                           next-replacement))
+                        (prompt
+                         (format message
+                                  (query-replace-descr from-string)
+                                  (query-replace-descr
+                                   replacement-presentation))))
+                    ;; Use `read-key' so that escape sequences on TTYs
+                    ;; are properly mapped back to the intended key.
+                   (setq key (read-key prompt)))
                  ;; Necessary in case something happens during
                  ;; read-event that clobbers the match data.
                  (set-match-data real-match-data)
index 288e8865dc5566a882f52c6527e787e9e562c428..be849185f6921eafd4b3d6d5ad5257c81a2d1f42 100644 (file)
@@ -538,7 +538,7 @@ Return the last evalled form in BODY."
          ;; Bind `read-event' to simulate user input.
          ;; If `replace-tests-bind-read-string' is non-nil, then
          ;; bind `read-string' as well.
-         (cl-letf (((symbol-function 'read-event)
+         (cl-letf (((symbol-function 'read-key)
                     (lambda (&rest _args)
                       (incf ,count)
                       (pcase ,count ; Build the clauses from CHAR-NUMS