aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2021-06-27 15:06:25 -0400
committerStefan Monnier2021-06-27 15:06:25 -0400
commitfe81c044892693ebd2dbeebffdcdf7e0c4bb7875 (patch)
tree0c7319a61f51cfbd2df54d61ac943af78950a37c
parentb8f9e58ef72402e69a1f0960816184d52e5d2d29 (diff)
downloademacs-fe81c044892693ebd2dbeebffdcdf7e0c4bb7875.tar.gz
emacs-fe81c044892693ebd2dbeebffdcdf7e0c4bb7875.zip
* lisp/textmodes/flyspell.el: Fix bug#49104
(flyspell--prev-meta-tab-binding): Delete var. (flyspell-prog-mode): Don't set it. (flyspell-auto-correct-word): Lookup the "next" command dynamically.
-rw-r--r--lisp/textmodes/flyspell.el23
1 files changed, 8 insertions, 15 deletions
diff --git a/lisp/textmodes/flyspell.el b/lisp/textmodes/flyspell.el
index ba48e5de21a..836d889a1cf 100644
--- a/lisp/textmodes/flyspell.el
+++ b/lisp/textmodes/flyspell.el
@@ -401,18 +401,12 @@ like <img alt=\"Some thing.\">."
401 (let ((f (get-text-property (1- (point)) 'face))) 401 (let ((f (get-text-property (1- (point)) 'face)))
402 (memq f flyspell-prog-text-faces)))) 402 (memq f flyspell-prog-text-faces))))
403 403
404(defvar flyspell--prev-meta-tab-binding nil
405 "Records the binding of M-TAB in effect before flyspell was activated.")
406
407;;;###autoload 404;;;###autoload
408(defun flyspell-prog-mode () 405(defun flyspell-prog-mode ()
409 "Turn on `flyspell-mode' for comments and strings." 406 "Turn on `flyspell-mode' for comments and strings."
410 (interactive) 407 (interactive)
411 (setq flyspell-generic-check-word-predicate 408 (setq flyspell-generic-check-word-predicate
412 #'flyspell-generic-progmode-verify) 409 #'flyspell-generic-progmode-verify)
413 (setq-local flyspell--prev-meta-tab-binding
414 (or (local-key-binding "\M-\t" t)
415 (global-key-binding "\M-\t" t)))
416 (flyspell-mode 1) 410 (flyspell-mode 1)
417 (run-hooks 'flyspell-prog-mode-hook)) 411 (run-hooks 'flyspell-prog-mode-hook))
418 412
@@ -1990,15 +1984,14 @@ spell-check."
1990 (interactive) 1984 (interactive)
1991 ;; If we are not in the construct where flyspell should be active, 1985 ;; If we are not in the construct where flyspell should be active,
1992 ;; invoke the original binding of M-TAB, if that was recorded. 1986 ;; invoke the original binding of M-TAB, if that was recorded.
1993 (if (and (local-variable-p 'flyspell--prev-meta-tab-binding) 1987 (let ((pos (point))
1994 (commandp flyspell--prev-meta-tab-binding t) 1988 (old-max (point-max))
1995 (functionp flyspell-generic-check-word-predicate) 1989 (next-cmd (and (functionp flyspell-generic-check-word-predicate)
1996 (not (funcall flyspell-generic-check-word-predicate)) 1990 (not (funcall flyspell-generic-check-word-predicate))
1997 (equal (where-is-internal 'flyspell-auto-correct-word nil t) 1991 (let ((flyspell-mode nil))
1998 [?\M-\t])) 1992 (key-binding (this-command-keys))))))
1999 (call-interactively flyspell--prev-meta-tab-binding) 1993 (if next-cmd
2000 (let ((pos (point)) 1994 (command-execute next-cmd)
2001 (old-max (point-max)))
2002 ;; Flush a possibly stale cache from previous invocations of 1995 ;; Flush a possibly stale cache from previous invocations of
2003 ;; flyspell-auto-correct-word/flyspell-auto-correct-previous-word. 1996 ;; flyspell-auto-correct-word/flyspell-auto-correct-previous-word.
2004 (if (not (memq last-command '(flyspell-auto-correct-word 1997 (if (not (memq last-command '(flyspell-auto-correct-word