unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#49104: [PATCH] 28.0.50; Handle remapped commands for M-TAB in `flyspell-prog-mode'
@ 2021-06-18 23:09 Jim Porter
  2021-06-19  6:07 ` Eli Zaretskii
  0 siblings, 1 reply; 9+ messages in thread
From: Jim Porter @ 2021-06-18 23:09 UTC (permalink / raw)
  To: 49104

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

`flyspell-prog-mode' uses the original M-TAB binding outside of
comments, which is nice (see bug#18533). However, it doesn't account
for remapped commands. For example, I remap `completion-at-point' to
`company-complete' when `company-mode' is active. If I hit M-TAB while
`company-mode' and `flyspell-prog-mode' are active, I get
`completion-at-point', which isn't what I want.

To reproduce this issue, you can do the following:

  emacs -Q
  (global-set-key [remap completion-at-point]
                  (lambda () (interactive) (message "remapped")))
  M-x flyspell-prog-mode
  M-TAB ;; Or C-M-i

I've attached a patch that fixes the issue (hopefully it works in all
cases; it works for me).

[-- Attachment #2: 0001-Handle-remapped-commands-for-original-M-TAB-binding-.patch --]
[-- Type: application/octet-stream, Size: 1299 bytes --]

From 734890adff84cf8fbec9cff0a5bb6ad620877216 Mon Sep 17 00:00:00 2001
From: Jim Porter <jporterbugs@gmail.com>
Date: Fri, 18 Jun 2021 16:02:07 -0700
Subject: [PATCH] Handle remapped commands for original M-TAB binding in
 'flyspell-prog-mode'

* lisp/textmodes/flyspell.el (flyspell-prog-mode): Get the remapped
command for the original M-TAB binding if necessary.
---
 lisp/textmodes/flyspell.el | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/lisp/textmodes/flyspell.el b/lisp/textmodes/flyspell.el
index ba48e5de21..eb4c5cde28 100644
--- a/lisp/textmodes/flyspell.el
+++ b/lisp/textmodes/flyspell.el
@@ -410,9 +410,11 @@ flyspell-prog-mode
   (interactive)
   (setq flyspell-generic-check-word-predicate
         #'flyspell-generic-progmode-verify)
-  (setq-local flyspell--prev-meta-tab-binding
-              (or (local-key-binding "\M-\t" t)
-                  (global-key-binding "\M-\t" t)))
+  (let ((prev-meta-tab-binding (or (local-key-binding "\M-\t" t)
+                                   (global-key-binding "\M-\t" t))))
+    (setq-local flyspell--prev-meta-tab-binding
+                (or (command-remapping prev-meta-tab-binding)
+                    prev-meta-tab-binding)))
   (flyspell-mode 1)
   (run-hooks 'flyspell-prog-mode-hook))
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2021-07-20 12:13 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-18 23:09 bug#49104: [PATCH] 28.0.50; Handle remapped commands for M-TAB in `flyspell-prog-mode' Jim Porter
2021-06-19  6:07 ` Eli Zaretskii
2021-06-19 11:51   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-06-19 12:20     ` Eli Zaretskii
2021-06-19 17:24       ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-06-19 17:31         ` Jim Porter
2021-06-27 19:07           ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-06-28  4:44             ` Jim Porter
2021-07-20 12:13               ` Lars Ingebrigtsen

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).