From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#52025: flyspell-emacs-popup pops up menu at random positions Date: Sun, 21 Nov 2021 21:25:40 +0200 Organization: LINKOV.NET Message-ID: <86ilwlmjd3.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="4025"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu) To: 52025@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Nov 21 20:39:11 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mosgB-0000uY-5d for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 21 Nov 2021 20:39:11 +0100 Original-Received: from localhost ([::1]:33938 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mosgA-0005xS-7r for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 21 Nov 2021 14:39:10 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:57102) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mosg2-0005sH-Fb for bug-gnu-emacs@gnu.org; Sun, 21 Nov 2021 14:39:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:34521) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mosg2-00063J-6m for bug-gnu-emacs@gnu.org; Sun, 21 Nov 2021 14:39:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mosg2-0004sI-4a for bug-gnu-emacs@gnu.org; Sun, 21 Nov 2021 14:39:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 21 Nov 2021 19:39:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 52025 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.163752348218649 (code B ref -1); Sun, 21 Nov 2021 19:39:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 21 Nov 2021 19:38:02 +0000 Original-Received: from localhost ([127.0.0.1]:46065 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mosf4-0004qg-8c for submit@debbugs.gnu.org; Sun, 21 Nov 2021 14:38:02 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:34010) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mosez-0004q7-Tu for submit@debbugs.gnu.org; Sun, 21 Nov 2021 14:37:58 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:56818) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mosev-0004q9-QZ for bug-gnu-emacs@gnu.org; Sun, 21 Nov 2021 14:37:54 -0500 Original-Received: from relay7-d.mail.gandi.net ([217.70.183.200]:56137) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1moses-0005qG-MN for bug-gnu-emacs@gnu.org; Sun, 21 Nov 2021 14:37:52 -0500 Original-Received: (Authenticated sender: juri@linkov.net) by relay7-d.mail.gandi.net (Postfix) with ESMTPSA id 0EE2E20005 for ; Sun, 21 Nov 2021 19:37:45 +0000 (UTC) Received-SPF: pass client-ip=217.70.183.200; envelope-from=juri@linkov.net; helo=relay7-d.mail.gandi.net X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:220587 Archived-At: --=-=-= Content-Type: text/plain 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: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=flyspell-emacs-popup.patch 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) --=-=-=--