emacs-diffs
[Top][All Lists]
Advanced

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

master 1eae0a8 2/2: Add new option flyspell-correct-on-mouse-3


From: Stefan Kangas
Subject: master 1eae0a8 2/2: Add new option flyspell-correct-on-mouse-3
Date: Sun, 16 Aug 2020 13:43:10 -0400 (EDT)

branch: master
commit 1eae0a8784f5c2635f9dda1b78066ecee01dec10
Author: Stefan Kangas <stefankangas@gmail.com>
Commit: Stefan Kangas <stefankangas@gmail.com>

    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.
---
 doc/emacs/fixit.texi       | 10 ++++++----
 etc/NEWS                   | 10 ++++++++++
 lisp/textmodes/flyspell.el | 21 ++++++++++++++++++++-
 3 files changed, 36 insertions(+), 5 deletions(-)

diff --git a/doc/emacs/fixit.texi b/doc/emacs/fixit.texi
index 5046146..507e780 100644
--- a/doc/emacs/fixit.texi
+++ b/doc/emacs/fixit.texi
@@ -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
diff --git a/etc/NEWS b/etc/NEWS
index 1a7f18d..3f52d26 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -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
 
diff --git a/lisp/textmodes/flyspell.el b/lisp/textmodes/flyspell.el
index b6ebb9f..8608f85 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)))



reply via email to

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