unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Kangas <stefan@marxist.se>
To: Eli Zaretskii <eliz@gnu.org>
Cc: l26wang@gmail.com, 11680@debbugs.gnu.org
Subject: bug#11680: flyspell should use mouse-3 instead of mouse-2
Date: Fri, 14 Aug 2020 18:08:59 -0700	[thread overview]
Message-ID: <CADwFkmk9Bp1kpGuqxqXsLN26P34Mr-VD=k-FNs3EcCrdK2_YpQ@mail.gmail.com> (raw)
In-Reply-To: <83o8nen17n.fsf@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 257 bytes --]

Eli Zaretskii <eliz@gnu.org> writes:

> I think it should be an opt-in behavior, conditional on a user
> option.  We can later see if it is popular enough to make that the
> default behavior.

OK.  How about the attached patch?

Best regards,
Stefan Kangas

[-- Attachment #2: 0001-Add-new-option-flyspell-correct-on-mouse-3.patch --]
[-- Type: text/x-diff, Size: 4198 bytes --]

From 3c1ceeff2c8c80914c590f461c6b876c3c5882af Mon Sep 17 00:00:00 2001
From: Stefan Kangas <stefankangas@gmail.com>
Date: Sat, 15 Aug 2020 02:53:35 +0200
Subject: [PATCH] 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       |  9 +++++----
 etc/NEWS                   |  9 +++++++++
 lisp/textmodes/flyspell.el | 20 +++++++++++++++++++-
 3 files changed, 33 insertions(+), 5 deletions(-)

diff --git a/doc/emacs/fixit.texi b/doc/emacs/fixit.texi
index 5046146dda..b6f65848d1 100644
--- a/doc/emacs/fixit.texi
+++ b/doc/emacs/fixit.texi
@@ -445,12 +445,13 @@ Spelling
 @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 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 8cd845a7b9..e6c1c6224a 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -839,6 +839,15 @@ height of lines or width of chars.
 *** New user option 'xwidget-webkit-bookmark-jump-new-session'.
 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 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-2 (usually the right mouse button)
+instead of mouse-3 (the default) by customizing the new option
+'flyspell-correct-on-mouse-3'.
 
 \f
 * New Modes and Packages in Emacs 28.1
diff --git a/lisp/textmodes/flyspell.el b/lisp/textmodes/flyspell.el
index b6ebb9f098..c594e02e98 100644
--- a/lisp/textmodes/flyspell.el
+++ b/lisp/textmodes/flyspell.el
@@ -445,6 +445,21 @@ flyspell-mode-map
     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)
+
 ;; 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 +529,10 @@ flyspell-mode
   :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)))
-- 
2.28.0


  reply	other threads:[~2020-08-15  1:08 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-12 12:23 bug#11680: flyspell should use mouse-3 instead of mouse-2 Le Wang
2019-11-01 18:21 ` Stefan Kangas
2019-11-01 19:07   ` Eli Zaretskii
2019-11-02  0:25     ` Stefan Kangas
2019-11-02  7:51       ` Eli Zaretskii
2020-01-16  1:50         ` Stefan Kangas
2020-01-16 14:46           ` Eli Zaretskii
2020-08-13  6:10             ` Stefan Kangas
2020-08-13 13:07               ` Eli Zaretskii
2020-08-15  1:08                 ` Stefan Kangas [this message]
2020-08-15 17:53                   ` Eli Zaretskii
2020-08-16 17:53                     ` Stefan Kangas
2020-08-17  0:38                   ` Juri Linkov
2020-08-17  2:38                     ` Drew Adams
2020-08-17 14:01                       ` Stefan Kangas
2020-08-17 15:12                         ` Drew Adams
2020-08-19  1:07                   ` Juri Linkov
2020-08-19 10:00                     ` Stefan Kangas
2020-08-27  5:14                       ` Stefan Kangas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CADwFkmk9Bp1kpGuqxqXsLN26P34Mr-VD=k-FNs3EcCrdK2_YpQ@mail.gmail.com' \
    --to=stefan@marxist.se \
    --cc=11680@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=l26wang@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).