bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#52025: flyspell-emacs-popup pops up menu at random positions


From: Juri Linkov
Subject: bug#52025: flyspell-emacs-popup pops up menu at random positions
Date: Sun, 21 Nov 2021 21:25:40 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu)

When typing 'C-c $' (flyspell-correct-word-before-point) near a misspelled word,
or opening the flyspell context menu from keyboard, the menu is displayed at 
random
place on the screen.

It seems the intention was to pop up the menu at the mouse position,
even when no mouse is used, but ad-hoc code in flyspell-emacs-popup
fails to do this correctly.

One variant is to use (popup-menu-normalize-position nil) that
correctly returns the mouse position.  But it has a usability problem:
often the mouse pointer is far away from the misspelled word.

So the best thing to do here is to popup the menu exactly
under the misspelled word:

diff --git a/lisp/textmodes/flyspell.el b/lisp/textmodes/flyspell.el
index 258e5fde67..b9962422ea 100644
--- a/lisp/textmodes/flyspell.el
+++ b/lisp/textmodes/flyspell.el
@@ -2270,17 +2270,8 @@ flyspell-adjust-cursor-point
 ;;*---------------------------------------------------------------------*/
 (defun flyspell-emacs-popup (event poss word)
   "The Emacs popup menu."
-  (if (and (not event)
-           (display-mouse-p))
-      (let* ((mouse-pos  (mouse-position))
-            (mouse-pos  (if (nth 1 mouse-pos)
-                            mouse-pos
-                          (set-mouse-position (car mouse-pos)
-                                              (/ (frame-width) 2) 2)
-                          (mouse-position))))
-       (setq event (list (list (car (cdr mouse-pos))
-                               (1+ (cdr (cdr mouse-pos))))
-                         (car mouse-pos)))))
+  (if (not event)
+      (setq event (popup-menu-normalize-position (point))))
   (let* ((corrects   (flyspell-sort (car (cdr (cdr poss))) word))
         (cor-menu   (if (consp corrects)
                         (mapcar (lambda (correct)

reply via email to

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