diff options
author | Stefan Kangas <stefankangas@gmail.com> | 2020-08-15 02:53:35 +0200 |
---|---|---|
committer | Stefan Kangas <stefankangas@gmail.com> | 2020-08-16 19:40:43 +0200 |
commit | 1eae0a8784f5c2635f9dda1b78066ecee01dec10 (patch) | |
tree | 8b27de680ee3125c858b4cba9812d2d637ea156a /lisp/textmodes/flyspell.el | |
parent | a0653f809f8b39f5b0a62a1043c3b11dc229054c (diff) | |
download | emacs-1eae0a8784f5c2635f9dda1b78066ecee01dec10.tar.gz emacs-1eae0a8784f5c2635f9dda1b78066ecee01dec10.tar.bz2 emacs-1eae0a8784f5c2635f9dda1b78066ecee01dec10.zip |
Add new option flyspell-correct-on-mouse-3
* lisp/textmodes/flyspell.el
(flyspell-correct-on-mouse-3): New option to bind
'flyspell-correct-word' to 'mouse-3'.
(flyspell--set-correct-on-mouse-3): New function to update option.
(flyspell-mode): Update 'flyspell-mouse-map' if above option is
set.
* doc/emacs/fixit.texi (Spelling): Mention the new option.
* etc/NEWS: Announce the new option.
Diffstat (limited to 'lisp/textmodes/flyspell.el')
-rw-r--r-- | lisp/textmodes/flyspell.el | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/lisp/textmodes/flyspell.el b/lisp/textmodes/flyspell.el index b6ebb9f098c..8608f850888 100644 --- a/lisp/textmodes/flyspell.el +++ b/lisp/textmodes/flyspell.el @@ -445,6 +445,22 @@ like <img alt=\"Some thing.\">." map) "Minor mode keymap for Flyspell mode--for the whole buffer.") +;; correct on mouse 3 +(defun flyspell--set-correct-on-mouse-3 (var value) + (set-default var value) + (if value + (progn (define-key flyspell-mouse-map [mouse-2] nil) + (define-key flyspell-mouse-map [mouse-3] 'flyspell-correct-word)) + (define-key flyspell-mouse-map [mouse-2] 'flyspell-correct-word) + (define-key flyspell-mouse-map [mouse-3] nil))) + +(defcustom flyspell-correct-on-mouse-3 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-correct-on-mouse-3 + :version "28.1") + ;; dash character machinery (defvar flyspell-consider-dash-as-word-delimiter-flag nil "Non-nil means that the `-' char is considered as a word delimiter.") @@ -514,7 +530,10 @@ in your init file. :group 'flyspell (if flyspell-mode (condition-case err - (flyspell-mode-on) + (progn + (when flyspell-correct-on-mouse-3 + (flyspell--set-correct-on-mouse-3 'flyspell-correct-on-mouse-3 t)) + (flyspell-mode-on)) (error (message "Error enabling Flyspell mode:\n%s" (cdr err)) (flyspell-mode -1))) (flyspell-mode-off))) |