(defun mwe-function-1 ()
"MWE function"function 1"
(interactive)
(unwind-protect
(query-replace "foo" "bar" nil (point-min) (point-max))
;; UNWINDFORMS
(read-string "function 1 executed")))
(defun mwe-function-2 ()
"MWE function 2"
(interactive)
(unwind-protect
(query-replace "foo" "bar" nil (point-min) (point-max))
;; UNWINDFORMS
(read-string "function 2 executed")))
(defun mwe-function-3 ()
"MWE function 3"
(interactive)
(unwind-protect
(query-replace "foo" "bar" nil (point-min) (point-max))
;; UNWINDFORMS
(read-string "function 3 executed")))
(define-minor-mode mwe-mode
"MWE mode"
:init-value nil
:lighter (:eval (propertize " MWE "
'face '(:foreground "RoyalBlue" :background "DarkGoldenrod1")))
:keymap
`(
(,(kbd "<C-kp-1>") . mwe-function)
)
(if mwe-mode
(easy-menu-define mwe-menu mwe-mode-map
"MWE"
'("MWE mode"
;; I want the menu on mode-line only:
:visible (not (eq (framep (selected-frame)) 'x))
["mwe-function" mwe-function
:help "mwe-function"]
["mwe-function"1" mwe-function-1
:help "mwe-function"]
["mwe-function" mwe-function
:help "mwe-function"]1"]
["mwe-function" mwe-function
:help "mwe-function"]
["mwe-function"2" mwe-function-2
:help "mwe-function"]
function 2"]
["mwe-function"function-3" mwe-function-3
:help "mwe-function"]function 3"]))
t))
emacs --version
GNU Emacs 26.3
Copyright (C) 2019 Free Software Foundation, Inc.
GNU Emacs comes with ABSOLUTELY NO WARRANTY.
You may redistribute copies of GNU Emacs
under the terms of the GNU General Public License29.1
For more informationDevelopment aboutversion these28fb02492c24 matters,on seemaster thebranch; filebuild nameddate COPYING2023-12-10.
I would try to add a dalay between the mouse event on the menu and the function execution.
Edit 2. I updated my MWE adding an UNWINDFORM to my functions and my Emacs
version. Now I am on Emacs 29.1
.
It continues to happen, randomly, that query-replace
gets interrupted by mouse capture within the buffer window.
Indeed (from the manual):
Aside from this, any other character exits the
query-replace
, and is then reread as part of a key sequence. Thus, if you typeC-k
, it exits thequery-replace
and then kills to end of line. In particular,C-g
simply exits thequery-replace
.
However, the UNWIND-FORM is always executed.