bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#50067: Context menus


From: Tak Kunihiro
Subject: bug#50067: Context menus
Date: Wed, 25 Aug 2021 08:43:29 +0900 (JST)

* flyspell menu

It is handy to show 'flyspell-correct-word when click on typo word.
However, menu is embedded inside of pre existing
'flyspell-correct-word and it is hard to collect menu.  Since
popup-menu interface can accept both menu and function with `e', it's
good to utilize 'flyspell-correct-word.

How about something like below to interrupt evaluation of
context-menu-functions in the middle when one of
context-menu-functions returns symbol instead of menu?

diff --git a/lisp/mouse.el b/lisp/mouse.el
index 6332d9fcec..23f0dda3e8 100644
--- a/lisp/mouse.el
+++ b/lisp/mouse.el
@@ -308,7 +308,7 @@ context-menu-map
     (run-hook-wrapped 'context-menu-functions
                       (lambda (fun)
                         (setq menu (funcall fun menu))
-                        nil))
+                        (not (keymapp menu))))
     (when (functionp context-menu-filter-function)
       (setq menu (funcall context-menu-filter-function menu)))
     menu))

Then function something below will pop word choices.

(defun context-menu-spell (menu)
  "Return 'flyspell-correct-word when word under mouse click is incorrect."
  (let ((faces-at-point (mapcar (lambda (xxx) (overlay-get xxx 'face))
                                (overlays-at (posn-point (event-start 
last-input-event))))))
    (if (or (member 'flyspell-incorrect faces-at-point)
            (member 'flyspell-duplicate faces-at-point))
        #'flyspell-correct-word
      menu)))

(setq context-menu-functions '(context-menu-spell ;; flyspell
                               context-menu-undo
                               context-menu-region
                               context-menu-local
                               context-menu-minor))





reply via email to

[Prev in Thread] Current Thread [Next in Thread]