aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/textmodes
diff options
context:
space:
mode:
authorAgustín Martín2010-11-10 11:54:43 +0100
committerAgustín Martín2010-11-10 11:54:43 +0100
commitbd4532fc5bc95eb69d0cdf88fcbee45cd99231d2 (patch)
treea7efd39af2b4172337d5734a79b0fe452b4a495a /lisp/textmodes
parent01768686d4ad7b38f20170b8f791a1e7e33b791c (diff)
downloademacs-bd4532fc5bc95eb69d0cdf88fcbee45cd99231d2.tar.gz
emacs-bd4532fc5bc95eb69d0cdf88fcbee45cd99231d2.zip
flyspell.el (flyspell-word): Do not re-check known misspellings.
Avoid re-checking words already found as misspellings by (flyspell-large-region), just do highlighting. Patch by Brandon Craig Rhodes (bug#7322)
Diffstat (limited to 'lisp/textmodes')
-rw-r--r--lisp/textmodes/flyspell.el60
1 files changed, 34 insertions, 26 deletions
diff --git a/lisp/textmodes/flyspell.el b/lisp/textmodes/flyspell.el
index d698c4baeb7..b08b75c728b 100644
--- a/lisp/textmodes/flyspell.el
+++ b/lisp/textmodes/flyspell.el
@@ -1013,11 +1013,13 @@ Mostly we check word delimiters."
1013;;*---------------------------------------------------------------------*/ 1013;;*---------------------------------------------------------------------*/
1014;;* flyspell-word ... */ 1014;;* flyspell-word ... */
1015;;*---------------------------------------------------------------------*/ 1015;;*---------------------------------------------------------------------*/
1016(defun flyspell-word (&optional following) 1016(defun flyspell-word (&optional following known-misspelling)
1017 "Spell check a word. 1017 "Spell check a word.
1018If the optional argument FOLLOWING, or, when called interactively 1018If the optional argument FOLLOWING, or, when called interactively
1019`ispell-following-word', is non-nil, checks the following (rather 1019`ispell-following-word', is non-nil, checks the following (rather
1020than preceding) word when the cursor is not over a word." 1020than preceding) word when the cursor is not over a word. If
1021optional argument KNOWN-MISSPELLING is non nil considers word a
1022misspelling and skips redundant spell-checking step."
1021 (interactive (list ispell-following-word)) 1023 (interactive (list ispell-following-word))
1022 (ispell-set-spellchecker-params) ; Initialize variables and dicts alists 1024 (ispell-set-spellchecker-params) ; Initialize variables and dicts alists
1023 (save-excursion 1025 (save-excursion
@@ -1078,29 +1080,35 @@ than preceding) word when the cursor is not over a word."
1078 (setq flyspell-word-cache-end end) 1080 (setq flyspell-word-cache-end end)
1079 (setq flyspell-word-cache-word word) 1081 (setq flyspell-word-cache-word word)
1080 ;; now check spelling of word. 1082 ;; now check spelling of word.
1081 (ispell-send-string "%\n") 1083 (if (not known-misspelling)
1082 ;; put in verbose mode 1084 (progn
1083 (ispell-send-string (concat "^" word "\n")) 1085 (ispell-send-string "%\n")
1084 ;; we mark the ispell process so it can be killed 1086 ;; put in verbose mode
1085 ;; when emacs is exited without query 1087 (ispell-send-string (concat "^" word "\n"))
1086 (set-process-query-on-exit-flag ispell-process nil) 1088 ;; we mark the ispell process so it can be killed
1087 ;; Wait until ispell has processed word. Since this code is often 1089 ;; when emacs is exited without query
1088 ;; executed from post-command-hook but the ispell process may not 1090 (set-process-query-on-exit-flag ispell-process nil)
1089 ;; be responsive, it's important to make sure we re-enable C-g. 1091 ;; Wait until ispell has processed word. Since this
1090 (with-local-quit 1092 ;; code is often executed from post-command-hook but
1091 (while (progn 1093 ;; the ispell process may not be responsive, it's
1092 (accept-process-output ispell-process) 1094 ;; important to make sure we re-enable C-g.
1093 (not (string= "" (car ispell-filter)))))) 1095 (with-local-quit
1094 ;; (ispell-send-string "!\n") 1096 (while (progn
1095 ;; back to terse mode. 1097 (accept-process-output ispell-process)
1096 ;; Remove leading empty element 1098 (not (string= "" (car ispell-filter))))))
1097 (setq ispell-filter (cdr ispell-filter)) 1099 ;; (ispell-send-string "!\n")
1098 ;; ispell process should return something after word is sent. 1100 ;; back to terse mode.
1099 ;; Tag word as valid (i.e., skip) otherwise 1101 ;; Remove leading empty element
1100 (or ispell-filter 1102 (setq ispell-filter (cdr ispell-filter))
1101 (setq ispell-filter '(*))) 1103 ;; ispell process should return something after word is sent.
1102 (if (consp ispell-filter) 1104 ;; Tag word as valid (i.e., skip) otherwise
1103 (setq poss (ispell-parse-output (car ispell-filter)))) 1105 (or ispell-filter
1106 (setq ispell-filter '(*)))
1107 (if (consp ispell-filter)
1108 (setq poss (ispell-parse-output (car ispell-filter)))))
1109 ;; Else, this was a known misspelling to begin with, and
1110 ;; we should forge an ispell return value.
1111 (setq poss (list word 0 '() '())))
1104 (let ((res (cond ((eq poss t) 1112 (let ((res (cond ((eq poss t)
1105 ;; correct 1113 ;; correct
1106 (setq flyspell-word-cache-result t) 1114 (setq flyspell-word-cache-result t)
@@ -1433,7 +1441,7 @@ The buffer to mark them in is `flyspell-large-region-buffer'."
1433 t 1441 t
1434 nil)))) 1442 nil))))
1435 (setq keep nil) 1443 (setq keep nil)
1436 (flyspell-word) 1444 (flyspell-word nil t)
1437 ;; Search for next misspelled word will begin from 1445 ;; Search for next misspelled word will begin from
1438 ;; end of last validated match. 1446 ;; end of last validated match.
1439 (setq buffer-scan-pos (point)))) 1447 (setq buffer-scan-pos (point))))