Fix flyspell-correct-word selected from context menu opened with the keyboard

* lisp/mouse.el (context-menu-open): Call interactively a command
returned by `context-menu-map' such as `flyspell-correct-word' (bug#50067).

* lisp/textmodes/flyspell.el (flyspell-correct-word): Handle the
case when it's called by a key bound to `context-menu-open'.
Then it should work the same way as `C-c $' typed on misspelled word
where the arg `event' of `flyspell-correct-word-before-point' is nil.
This commit is contained in:
Juri Linkov 2021-11-18 20:23:58 +02:00
parent bf824843f4
commit 14271d050a
2 changed files with 6 additions and 3 deletions

View file

@ -541,8 +541,11 @@ activates the menu whose contents depends on its surrounding context."
"Start key navigation of the context menu.
This is the keyboard interface to \\[context-menu-map]."
(interactive)
(let ((inhibit-mouse-event-check t))
(popup-menu (context-menu-map) (point))))
(let ((inhibit-mouse-event-check t)
(map (context-menu-map)))
(if (commandp map)
(call-interactively map)
(popup-menu map (point)))))
(global-set-key [S-f10] 'context-menu-open)

View file

@ -2160,7 +2160,7 @@ The word checked is the word at the mouse position."
(interactive "e")
(let ((save (point)))
(mouse-set-point event)
(flyspell-correct-word-before-point event save)))
(flyspell-correct-word-before-point (and (consp event) event) save)))
(defun flyspell-correct-word-before-point (&optional event opoint)
"Pop up a menu of possible corrections for misspelled word before point.