From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#49104: [PATCH] 28.0.50; Handle remapped commands for M-TAB in `flyspell-prog-mode' Date: Sat, 19 Jun 2021 13:24:35 -0400 Message-ID: References: <83a6nmxu95.fsf@gnu.org> <83pmwivyf7.fsf@gnu.org> Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="19634"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: jporterbugs@gmail.com, 49104@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jun 19 19:25:09 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 1lueiT-0004uc-Eq for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 19 Jun 2021 19:25:09 +0200 Original-Received: from localhost ([::1]:60784 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lueiS-0002tX-GJ for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 19 Jun 2021 13:25:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:54976) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lueiN-0002tK-2D for bug-gnu-emacs@gnu.org; Sat, 19 Jun 2021 13:25:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:49132) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lueiM-0002Yu-O0 for bug-gnu-emacs@gnu.org; Sat, 19 Jun 2021 13:25:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lueiM-0002wb-F1 for bug-gnu-emacs@gnu.org; Sat, 19 Jun 2021 13:25:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 19 Jun 2021 17:25:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 49104 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 49104-submit@debbugs.gnu.org id=B49104.162412348811295 (code B ref 49104); Sat, 19 Jun 2021 17:25:02 +0000 Original-Received: (at 49104) by debbugs.gnu.org; 19 Jun 2021 17:24:48 +0000 Original-Received: from localhost ([127.0.0.1]:60678 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1luei8-0002w6-1x for submit@debbugs.gnu.org; Sat, 19 Jun 2021 13:24:48 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:12445) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1luei3-0002vr-OT for 49104@debbugs.gnu.org; Sat, 19 Jun 2021 13:24:47 -0400 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id BE9A08065C; Sat, 19 Jun 2021 13:24:37 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 7A66B804DE; Sat, 19 Jun 2021 13:24:36 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1624123476; bh=aXRrrI99I0Ez0nlmrWrHjAOM9nUydYgKxa8DqzBoe0o=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=C/RgIoSNwWeYGf3EiSDZ3+huFcdclrxCd7N8ve+e1AWG4+HVZ13phrOI7cIAwPBtu Xk4ZOy17XjLmKgHIrOcDmuveU6BO5ocCRgDIWDoDWXoUP5kxK/ivrvapBPbUeH2Dj+ RfBO0ta0pb2YzjDLXYZsUG5hNBPJg38m9Ggns4SyYkfu0m84p7oKExH6OfK8eCJkaO xfwCxWqHUtPVv5e/GdgIHTz+z0BmaecH4MlU0LazLq5tQgXdgNald0njAwb/oFeKZc DbPRzQoZmtBv7zq1jOBRE+8yxMMX7YsfQkcMeH0oR9Md58W6V1MCJyqphS6YI/k9cW HVSt9HLmK0Ddw== Original-Received: from alfajor (69-196-163-239.dsl.teksavvy.com [69.196.163.239]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 28540120273; Sat, 19 Jun 2021 13:24:36 -0400 (EDT) In-Reply-To: <83pmwivyf7.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 19 Jun 2021 15:20:12 +0300") 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:208758 Archived-At: >> > Isn't it a bug that global/local-key-binding don't return such >> > remapped bindings, at least optionally? >> I don't > Why not? Good question. I think I meant to write "I don't know" instead of just "I don't". >> but I wonder why flyspell-prog-mode uses those functions >> instead of using just `key-binding` > Because the latter is not described in the ELisp manual where > global/local-key-binding are, and isn't referenced from there? In that case, `key-binding` might be a good replacement. I see that using `key-binding` could find flyspell's own binding, tho, so we should probably use the (first) patch below instead. Tho I also wonder why we do the lookup when flyspell is enabled instead of doing directly in flyspell-auto-correct-word as in the second patch below. Stefan diff --git a/lisp/textmodes/flyspell.el b/lisp/textmodes/flyspell.el index ba48e5de21..11ff0f426f 100644 --- a/lisp/textmodes/flyspell.el +++ b/lisp/textmodes/flyspell.el @@ -411,8 +411,8 @@ flyspell-prog-mode (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 ((flyspell-mode nil)) + (key-binding "\M-\t"))) (flyspell-mode 1) (run-hooks 'flyspell-prog-mode-hook)) diff --git a/lisp/textmodes/flyspell.el b/lisp/textmodes/flyspell.el index ba48e5de21..649057270e 100644 --- a/lisp/textmodes/flyspell.el +++ b/lisp/textmodes/flyspell.el @@ -401,18 +401,12 @@ flyspell-generic-progmode-verify (let ((f (get-text-property (1- (point)) 'face))) (memq f flyspell-prog-text-faces)))) -(defvar flyspell--prev-meta-tab-binding nil - "Records the binding of M-TAB in effect before flyspell was activated.") - ;;;###autoload (defun flyspell-prog-mode () "Turn on `flyspell-mode' for comments and strings." (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))) (flyspell-mode 1) (run-hooks 'flyspell-prog-mode-hook)) @@ -1990,13 +1984,10 @@ flyspell-auto-correct-word (interactive) ;; If we are not in the construct where flyspell should be active, ;; invoke the original binding of M-TAB, if that was recorded. - (if (and (local-variable-p 'flyspell--prev-meta-tab-binding) - (commandp flyspell--prev-meta-tab-binding t) - (functionp flyspell-generic-check-word-predicate) - (not (funcall flyspell-generic-check-word-predicate)) - (equal (where-is-internal 'flyspell-auto-correct-word nil t) - [?\M-\t])) - (call-interactively flyspell--prev-meta-tab-binding) + (if (and (functionp flyspell-generic-check-word-predicate) + (not (funcall flyspell-generic-check-word-predicate))) + (let ((flyspell-mode nil)) + (execut-command (key-binding (this-command-keys)))) (let ((pos (point)) (old-max (point-max))) ;; Flush a possibly stale cache from previous invocations of