summaryrefslogtreecommitdiff
path: root/lisp/textmodes/flyspell.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/textmodes/flyspell.el')
-rw-r--r--lisp/textmodes/flyspell.el56
1 files changed, 31 insertions, 25 deletions
diff --git a/lisp/textmodes/flyspell.el b/lisp/textmodes/flyspell.el
index 83dba7177ab..836d889a1cf 100644
--- a/lisp/textmodes/flyspell.el
+++ b/lisp/textmodes/flyspell.el
@@ -77,7 +77,7 @@ Detection of repeated words is not implemented in
"A list of exceptions for duplicated words.
It should be a list of (LANGUAGE . EXCEPTION-LIST).
-LANGUAGE is nil, which means the exceptions apply regardless of
+LANGUAGE can be nil, which means the exceptions apply regardless of
the current dictionary, or a regular expression matching the
dictionary name (`ispell-local-dictionary' or
`ispell-dictionary') for which the exceptions should apply.
@@ -401,18 +401,12 @@ like <img alt=\"Some thing.\">."
(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))
@@ -1263,14 +1257,27 @@ spell-check."
(t
(setq flyspell-word-cache-result nil)
;; Highlight the location as incorrect,
- ;; including offset specified in POSS.
+ ;; including offset specified in POSS
+ ;; and only for the length of the
+ ;; misspelled word specified by POSS.
(if flyspell-highlight-flag
- (flyspell-highlight-incorrect-region
- (if (and (consp poss)
- (integerp (nth 1 poss)))
- (+ start (nth 1 poss) -1)
- start)
- end poss)
+ (let ((hstart start)
+ (hend end)
+ offset misspelled)
+ (when (consp poss)
+ (setq misspelled (car poss)
+ offset (nth 1 poss))
+ (if (integerp offset)
+ (setq hstart (+ start offset -1)))
+ ;; POSS includes the misspelled
+ ;; word; use that to figure out
+ ;; how many characters to highlight.
+ (if (stringp misspelled)
+ (setq hend
+ (+ hstart
+ (length misspelled)))))
+ (flyspell-highlight-incorrect-region
+ hstart hend poss))
(flyspell-notify-misspell word poss))
nil))))
;; return to original location
@@ -1977,15 +1984,14 @@ spell-check."
(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)
- (let ((pos (point))
- (old-max (point-max)))
+ (let ((pos (point))
+ (old-max (point-max))
+ (next-cmd (and (functionp flyspell-generic-check-word-predicate)
+ (not (funcall flyspell-generic-check-word-predicate))
+ (let ((flyspell-mode nil))
+ (key-binding (this-command-keys))))))
+ (if next-cmd
+ (command-execute next-cmd)
;; Flush a possibly stale cache from previous invocations of
;; flyspell-auto-correct-word/flyspell-auto-correct-previous-word.
(if (not (memq last-command '(flyspell-auto-correct-word
@@ -2293,8 +2299,8 @@ If OPOINT is non-nil, restore point there after adjusting it for replacement."
corrects)
'()))
(affix (car (cdr (cdr (cdr poss)))))
- show-affix-info
- (base-menu (let ((save (if (and (consp affix) show-affix-info)
+ ;; show-affix-info
+ (base-menu (let ((save (if nil ;; (and (consp affix) show-affix-info)
(list
(list (concat "Save affix: " (car affix))
'save)