1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-15 10:30:25 -08:00

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.
This commit is contained in:
Stefan Kangas 2020-08-15 02:53:35 +02:00
parent a0653f809f
commit 1eae0a8784
3 changed files with 36 additions and 5 deletions

View file

@ -445,12 +445,14 @@ use @code{flyspell-region} or @code{flyspell-buffer} for that.
@findex flyspell-correct-word-before-point
When Flyspell mode highlights a word as misspelled, you can click on
it with @kbd{mouse-2} (@code{flyspell-correct-word}) to display a menu
of possible corrections and actions. In addition, @kbd{C-.} or
of possible corrections and actions. If you want this menu on
@kbd{mouse-3} instead, customize the variable
@code{flyspell-correct-on-mouse-3}. In addition, @kbd{C-.} or
@kbd{@key{ESC}-@key{TAB}} (@code{flyspell-auto-correct-word}) will
propose various successive corrections for the word at point, and
@w{@kbd{C-c $}} (@code{flyspell-correct-word-before-point}) will pop up a
menu of possible corrections. Of course, you can always correct the
misspelled word by editing it manually in any way you like.
@w{@kbd{C-c $}} (@code{flyspell-correct-word-before-point}) will pop
up a menu of possible corrections. Of course, you can always correct
the misspelled word by editing it manually in any way you like.
@findex flyspell-prog-mode
Flyspell Prog mode works just like ordinary Flyspell mode, except

View file

@ -875,6 +875,16 @@ height of lines or width of chars.
When non-nil, use a new xwidget webkit session after bookmark jump.
Otherwise, it will use 'xwidget-webkit-last-session'.
** Flyspell mode
+++
*** Corrections and actions menu can be optionally bound to mouse-3.
When Flyspell mode highlights a word as misspelled, you can click on
it to display a menu of possible corrections and actions. You can now
easily bind this menu to mouse-3 (usually the right mouse button)
instead of mouse-2 (the default) by customizing the new option
'flyspell-correct-on-mouse-3'.
* New Modes and Packages in Emacs 28.1

View file

@ -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)))