From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#18533: 24.4.50; flyspell-prog-mode and lisp interaction Date: Sun, 27 Dec 2015 19:35:13 +0200 Message-ID: <831ta7hk1a.fsf@gnu.org> References: <877g0vtlqs.fsf@tromey.com> <87si3deesp.fsf@tromey.com> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1451237722 17090 80.91.229.3 (27 Dec 2015 17:35:22 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 27 Dec 2015 17:35:22 +0000 (UTC) Cc: 18533@debbugs.gnu.org To: Tom Tromey Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Dec 27 18:35:11 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1aDFDr-00024t-5C for geb-bug-gnu-emacs@m.gmane.org; Sun, 27 Dec 2015 18:35:11 +0100 Original-Received: from localhost ([::1]:42285 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aDFDq-0003Lh-A5 for geb-bug-gnu-emacs@m.gmane.org; Sun, 27 Dec 2015 12:35:10 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:57207) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aDFDn-0003Lc-JB for bug-gnu-emacs@gnu.org; Sun, 27 Dec 2015 12:35:08 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aDFDi-0000SF-OZ for bug-gnu-emacs@gnu.org; Sun, 27 Dec 2015 12:35:07 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:37050) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aDFDi-0000Rw-LH for bug-gnu-emacs@gnu.org; Sun, 27 Dec 2015 12:35:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84) (envelope-from ) id 1aDFDi-00028W-EH for bug-gnu-emacs@gnu.org; Sun, 27 Dec 2015 12:35:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 27 Dec 2015 17:35:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 18533 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 18533-submit@debbugs.gnu.org id=B18533.14512376788177 (code B ref 18533); Sun, 27 Dec 2015 17:35:02 +0000 Original-Received: (at 18533) by debbugs.gnu.org; 27 Dec 2015 17:34:38 +0000 Original-Received: from localhost ([127.0.0.1]:44652 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aDFDK-00027p-8Q for submit@debbugs.gnu.org; Sun, 27 Dec 2015 12:34:38 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:37873) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aDFDH-00027X-Oo for 18533@debbugs.gnu.org; Sun, 27 Dec 2015 12:34:37 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aDFD7-0008U0-Rh for 18533@debbugs.gnu.org; Sun, 27 Dec 2015 12:34:30 -0500 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:43960) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aDFD7-0008Tv-OD; Sun, 27 Dec 2015 12:34:25 -0500 Original-Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:2354 helo=HOME-C4E4A596F7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1aDFD7-0007Ad-2w; Sun, 27 Dec 2015 12:34:25 -0500 In-reply-to: <87si3deesp.fsf@tromey.com> (message from Tom Tromey on Mon, 07 Dec 2015 23:37:42 -0500) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 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.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:110806 Archived-At: [Resending, as my original message didn't make it to the bug tracker.] > From: Tom Tromey > Date: Mon, 07 Dec 2015 23:37:42 -0500 > Cc: 18533@debbugs.gnu.org > > Tom> I ran emacs -Q. > Tom> Then in *scratch*, M-x flyspell-prog-mode > Tom> Then typed `(igno' > > Tom> I expected this to complete to `(ignore', because point it not in a > Tom> comment or string. > Tom> However, flyspell instead changes this to `(Gino'. > > FWIW I solved this to my own satisfaction by setting > flyspell-use-meta-tab to nil. This isn't maybe quite as nice as having > the key binding automatically be aware of flyspell-prog-mode, but it's > good enough for me. Thanks, and sorry for letting this issue fall through the cracks for so long. Looking at the code, it sounds like the behavior you expected was never intended to happen. However, I found that a relatively simple change can do what you want. Does the patch below look reasonable? --- lisp/textmodes/flyspell.el~4 2015-11-11 07:57:35.000000000 +0200 +++ lisp/textmodes/flyspell.el 2015-12-08 19:01:54.033105000 +0200 @@ -399,6 +399,9 @@ (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)) @@ -1904,6 +1907,15 @@ "Correct the current word. This command proposes various successive corrections for the current 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) + (fboundp 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) (let ((pos (point)) (old-max (point-max))) ;; Use the correct dictionary. @@ -2002,7 +2014,7 @@ (point) old-max)))))))))) (setq flyspell-auto-correct-pos (point)) - (ispell-pdict-save t))))))) + (ispell-pdict-save t)))))))) ;;*---------------------------------------------------------------------*/ ;;* flyspell-auto-correct-previous-pos ... */