Skip to main content
added 743 characters in body
Source Link
Gabriele
  • 1.7k
  • 11
  • 22
(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 type C-k, it exits the query-replace and then kills to end of line. In particular, C-g simply exits the query-replace.

However, the UNWIND-FORM is always executed.

(defun mwe-function ()
  "MWE function"
  (interactive)
  (query-replace "foo" "bar" nil (point-min) (point-max)))

(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" mwe-function
             :help "mwe-function"]
            ["mwe-function" mwe-function
             :help "mwe-function"]
            ["mwe-function" mwe-function
             :help "mwe-function"]
            ["mwe-function" mwe-function
             :help "mwe-function"]
            ["mwe-function" mwe-function
             :help "mwe-function"]))
 
    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 License.
For more information about these matters, see the file named COPYING.

I would try to add a dalay between the mouse event on the menu and the function execution.

(defun mwe-function-1 ()
  "MWE 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-1" mwe-function-1
           :help "mwe-function 1"]
          ["mwe-function-2" mwe-function-2
           :help "mwe-function 2"]
          ["mwe-function-3" mwe-function-3
           :help "mwe-function 3"]))
    t))
emacs --version
GNU Emacs 29.1
Development version 28fb02492c24 on master branch; build date 2023-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 type C-k, it exits the query-replace and then kills to end of line. In particular, C-g simply exits the query-replace.

However, the UNWIND-FORM is always executed.

added 1872 characters in body
Source Link
Gabriele
  • 1.7k
  • 11
  • 22

Edit. This is my MWE:

(defun mwe-function ()
  "MWE function"
  (interactive)
  (query-replace "foo" "bar" nil (point-min) (point-max)))

(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" mwe-function
             :help "mwe-function"]
            ["mwe-function" mwe-function
             :help "mwe-function"]
            ["mwe-function" mwe-function
             :help "mwe-function"]
            ["mwe-function" mwe-function
             :help "mwe-function"]
            ["mwe-function" mwe-function
             :help "mwe-function"]))

    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 License.
For more information about these matters, see the file named COPYING.
$ uname -a
Linux ---- 5.4.0-169-generic #187-Ubuntu SMP Thu Nov 23 14:52:28 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
$ echo $XDG_CURRENT_DESKTOP
MATE

When I click on the function mwe-function in the menu, it doesn't get executed because the mouse event interrupts query-replace. The issue doesn't occur consistently and is quite random.

I would try to add a dalay between the mouse event on the menu and the function execution.

Edit. This is my MWE:

(defun mwe-function ()
  "MWE function"
  (interactive)
  (query-replace "foo" "bar" nil (point-min) (point-max)))

(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" mwe-function
             :help "mwe-function"]
            ["mwe-function" mwe-function
             :help "mwe-function"]
            ["mwe-function" mwe-function
             :help "mwe-function"]
            ["mwe-function" mwe-function
             :help "mwe-function"]
            ["mwe-function" mwe-function
             :help "mwe-function"]))

    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 License.
For more information about these matters, see the file named COPYING.
$ uname -a
Linux ---- 5.4.0-169-generic #187-Ubuntu SMP Thu Nov 23 14:52:28 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
$ echo $XDG_CURRENT_DESKTOP
MATE

When I click on the function mwe-function in the menu, it doesn't get executed because the mouse event interrupts query-replace. The issue doesn't occur consistently and is quite random.

I would try to add a dalay between the mouse event on the menu and the function execution.

edited tags
Link
Drew
  • 79.1k
  • 10
  • 123
  • 257
Source Link
Gabriele
  • 1.7k
  • 11
  • 22
Loading