From 976977defa2cf1eb77535fb817c34c631ee4c644 Mon Sep 17 00:00:00 2001 From: Jared Finder Date: Sat, 14 Dec 2024 09:30:43 +0100 Subject: [PATCH] Fix for xt-mouse-tests.el broken in prior commit xt-mouse-tests not turning on xterm-mouse-mode if it was already on did not work with xterm-mouse-mode being set to t by default. It turns out that xt-mouse-tests already does not report proper results when called inside a running Emacs session so the code path is not useful anyways. * test/lisp/xt-mouse-tests.el (with-xterm-mouse-mode): Always turn on xterm-mouse-mode, even if it is already on. (cherry picked from commit 2719dccbe5797dd8fcf1ce013df2ff71161b6f55) --- test/lisp/xt-mouse-tests.el | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/test/lisp/xt-mouse-tests.el b/test/lisp/xt-mouse-tests.el index cfc8042f796..f64b3aed73e 100644 --- a/test/lisp/xt-mouse-tests.el +++ b/test/lisp/xt-mouse-tests.el @@ -25,6 +25,8 @@ (require 'xt-mouse) +;; FIXME: this doesn't work when called inside a non-batch mode Emacs +;; session. (defmacro with-xterm-mouse-mode (&rest body) "Run BODY with `xterm-mouse-mode' temporarily enabled." (declare (indent 0)) @@ -42,18 +44,16 @@ ((terminal-parameter nil 'xterm-mouse-y) nil) ((terminal-parameter nil 'xterm-mouse-last-down) nil) ((terminal-parameter nil 'xterm-mouse-last-click) nil)) - (if xterm-mouse-mode - ,(macroexp-progn body) - (unwind-protect - (progn - ;; `xterm-mouse-mode' doesn't work in the initial - ;; terminal. Since we can't create a second - ;; terminal in batch mode, fake it temporarily. - (cl-letf (((symbol-function 'terminal-name) - (lambda (&optional _terminal) "fake-terminal"))) - (xterm-mouse-mode)) - ,@body) - (xterm-mouse-mode 0))))) + (unwind-protect + (progn + ;; `xterm-mouse-mode' doesn't work in the initial + ;; terminal. Since we can't create a second + ;; terminal in batch mode, fake it temporarily. + (cl-letf (((symbol-function 'terminal-name) + (lambda (&optional _terminal) "fake-terminal"))) + (xterm-mouse-mode 1)) + ,@body) + (xterm-mouse-mode 0)))) (set-frame-width nil width) (set-frame-height nil height)))) -- 2.39.2