unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@linkov.net>
To: 52025@debbugs.gnu.org
Subject: bug#52025: flyspell-emacs-popup pops up menu at random positions
Date: Sun, 21 Nov 2021 21:25:40 +0200	[thread overview]
Message-ID: <86ilwlmjd3.fsf@mail.linkov.net> (raw)

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

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:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: flyspell-emacs-popup.patch --]
[-- Type: text/x-diff, Size: 960 bytes --]

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	other threads:[~2021-11-21 19:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-21 19:25 Juri Linkov [this message]
2021-11-22 19:07 ` bug#52025: flyspell-emacs-popup pops up menu at random positions Juri Linkov

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=86ilwlmjd3.fsf@mail.linkov.net \
    --to=juri@linkov.net \
    --cc=52025@debbugs.gnu.org \
    /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).