diff options
author | Juri Linkov <juri@linkov.net> | 2021-08-27 09:24:07 +0300 |
---|---|---|
committer | Juri Linkov <juri@linkov.net> | 2021-08-27 09:24:07 +0300 |
commit | a573d6bd88afe9a60728f0b63a45f44a6ff98ce2 (patch) | |
tree | 10241766849ae5270b93794779b72d66c1939ada /lisp/textmodes/flyspell.el | |
parent | 9c1bbad907575987054b8d81ac2d09bfabe6214b (diff) | |
download | emacs-a573d6bd88afe9a60728f0b63a45f44a6ff98ce2.tar.gz emacs-a573d6bd88afe9a60728f0b63a45f44a6ff98ce2.tar.bz2 emacs-a573d6bd88afe9a60728f0b63a45f44a6ff98ce2.zip |
Replace flyspell-use-mouse-3-for-menu with context-menu-mode (bug#50067)
* doc/emacs/fixit.texi (Spelling): Replace mentions of
flyspell-use-mouse-3-for-menu with context-menu-mode.
* lisp/mouse.el (context-menu-map): Use the function from the
text property context-menu-function at mouse click event.
* lisp/textmodes/flyspell.el (flyspell--set-use-mouse-3-for-menu):
Remove function.
(flyspell-use-mouse-3-for-menu): Remove defcustom added recently in 28.1.
(flyspell-context-menu): New function.
(flyspell-mode): Don't call flyspell--set-use-mouse-3-for-menu.
(flyspell-mode-on): Replace flyspell-use-mouse-3-for-menu
with context-menu-mode.
(make-flyspell-overlay): When context-menu-mode is non-nil,
put overlay context-menu-function with flyspell-context-menu
instead of using keymap flyspell-mouse-map.
Diffstat (limited to 'lisp/textmodes/flyspell.el')
-rw-r--r-- | lisp/textmodes/flyspell.el | 47 |
1 files changed, 18 insertions, 29 deletions
diff --git a/lisp/textmodes/flyspell.el b/lisp/textmodes/flyspell.el index 836d889a1cf..975f540936a 100644 --- a/lisp/textmodes/flyspell.el +++ b/lisp/textmodes/flyspell.el @@ -442,22 +442,6 @@ like <img alt=\"Some thing.\">." map) "Minor mode keymap for Flyspell mode--for the whole buffer.") -;; correct on mouse 3 -(defun flyspell--set-use-mouse-3-for-menu (var value) - (set-default var value) - (if value - (progn (define-key flyspell-mouse-map [mouse-2] nil) - (define-key flyspell-mouse-map [down-mouse-3] 'flyspell-correct-word)) - (define-key flyspell-mouse-map [mouse-2] 'flyspell-correct-word) - (define-key flyspell-mouse-map [down-mouse-3] nil))) - -(defcustom flyspell-use-mouse-3-for-menu nil - "Non-nil means to bind `mouse-3' to `flyspell-correct-word'. -If this is set, also unbind `mouse-2'." - :type 'boolean - :set 'flyspell--set-use-mouse-3-for-menu - :version "28.1") - ;; dash character machinery (defvar-local flyspell-consider-dash-as-word-delimiter-flag nil "Non-nil means that the `-' char is considered as a word delimiter.") @@ -486,6 +470,13 @@ See also `flyspell-duplicate-distance'." (defvar flyspell-overlay nil) +(defun flyspell-context-menu (_menu) + "Context menu for `context-menu-mode'." + ;; TODO: refactor `flyspell-correct-word' and related functions to return + ;; a keymap menu where every menu item is bound to a lambda that calls + ;; `flyspell-do-correct' with an argument that is a correct word. + 'flyspell-correct-word) + ;;*---------------------------------------------------------------------*/ ;;* flyspell-mode ... */ ;;*---------------------------------------------------------------------*/ @@ -537,10 +528,7 @@ in your init file. :group 'flyspell (if flyspell-mode (condition-case err - (progn - (when flyspell-use-mouse-3-for-menu - (flyspell--set-use-mouse-3-for-menu 'flyspell-use-mouse-3-for-menu t)) - (flyspell-mode-on (called-interactively-p 'interactive))) + (flyspell-mode-on (called-interactively-p 'interactive)) (error (message "Error enabling Flyspell mode:\n%s" (cdr err)) (flyspell-mode -1))) (flyspell-mode-off))) @@ -656,8 +644,7 @@ are both non-nil." show-msg) (let* ((binding (where-is-internal 'flyspell-auto-correct-word nil 'non-ascii)) - (mouse-button (if flyspell-use-mouse-3-for-menu - "Mouse-3" "Mouse-2"))) + (mouse-button (if context-menu-mode "Mouse-3" "Mouse-2"))) (message (format-message "Welcome to Flyspell. Use %s to correct words." (if binding @@ -1820,13 +1807,15 @@ for the overlay." (overlay-put overlay 'mouse-face mouse-face) (overlay-put overlay 'flyspell-overlay t) (overlay-put overlay 'evaporate t) - (overlay-put overlay 'help-echo (concat (if flyspell-use-mouse-3-for-menu - "mouse-3" - "mouse-2") ": correct word at point")) - ;; If misspelled text has a 'keymap' property, let that remain in - ;; effect for the bindings that flyspell-mouse-map doesn't override. - (set-keymap-parent flyspell-mouse-map (get-char-property beg 'keymap)) - (overlay-put overlay 'keymap flyspell-mouse-map) + (overlay-put overlay 'help-echo + (concat (if context-menu-mode "mouse-3" "mouse-2") + ": correct word at point")) + (if context-menu-mode + (overlay-put overlay 'context-menu-function 'flyspell-context-menu) + ;; If misspelled text has a 'keymap' property, let that remain in + ;; effect for the bindings that flyspell-mouse-map doesn't override. + (set-keymap-parent flyspell-mouse-map (get-char-property beg 'keymap)) + (overlay-put overlay 'keymap flyspell-mouse-map)) (when (eq face 'flyspell-incorrect) (and (stringp flyspell-before-incorrect-word-string) (overlay-put overlay 'before-string |