emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r102323: flyspell.el (flyspell-word):


From: Agustin Martin
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r102323: flyspell.el (flyspell-word): Do not re-check known misspellings.
Date: Wed, 10 Nov 2010 11:54:43 +0100
User-agent: Bazaar (2.0.3)

------------------------------------------------------------
revno: 102323
committer: Agustin Martin <address@hidden>
branch nick: trunk
timestamp: Wed 2010-11-10 11:54:43 +0100
message:
  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)
modified:
  lisp/ChangeLog
  lisp/textmodes/flyspell.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2010-11-10 08:21:06 +0000
+++ b/lisp/ChangeLog    2010-11-10 10:54:43 +0000
@@ -1,3 +1,9 @@
+2010-11-10  Agustín Martín  <address@hidden>
+
+       * textmodes/flyspell.el (flyspell-word): Do not re-check words
+       already found as misspellings by (flyspell-large-region), just
+       do highlighting.  Patch by Brandon Craig Rhodes (bug#7322)
+
 2010-11-10  Glenn Morris  <address@hidden>
 
        * progmodes/octave-mod.el (octave-mark-block): Update for smie change.

=== modified file 'lisp/textmodes/flyspell.el'
--- a/lisp/textmodes/flyspell.el        2010-11-07 01:36:33 +0000
+++ b/lisp/textmodes/flyspell.el        2010-11-10 10:54:43 +0000
@@ -1013,11 +1013,13 @@
 ;;*---------------------------------------------------------------------*/
 ;;*    flyspell-word ...                                                */
 ;;*---------------------------------------------------------------------*/
-(defun flyspell-word (&optional following)
+(defun flyspell-word (&optional following known-misspelling)
   "Spell check a word.
 If the optional argument FOLLOWING, or, when called interactively
 `ispell-following-word', is non-nil, checks the following (rather
-than preceding) word when the cursor is not over a word."
+than preceding) word when the cursor is not over a word.  If
+optional argument KNOWN-MISSPELLING is non nil considers word a
+misspelling and skips redundant spell-checking step."
   (interactive (list ispell-following-word))
   (ispell-set-spellchecker-params)    ; Initialize variables and dicts alists
   (save-excursion
@@ -1078,29 +1080,35 @@
            (setq flyspell-word-cache-end end)
            (setq flyspell-word-cache-word word)
            ;; now check spelling of word.
-           (ispell-send-string "%\n")
-           ;; put in verbose mode
-           (ispell-send-string (concat "^" word "\n"))
-           ;; we mark the ispell process so it can be killed
-           ;; when emacs is exited without query
-           (set-process-query-on-exit-flag ispell-process nil)
-           ;; Wait until ispell has processed word.  Since this code is often
-            ;; executed from post-command-hook but the ispell process may not
-            ;; be responsive, it's important to make sure we re-enable C-g.
-           (with-local-quit
-             (while (progn
-                      (accept-process-output ispell-process)
-                      (not (string= "" (car ispell-filter))))))
-           ;; (ispell-send-string "!\n")
-           ;; back to terse mode.
-           ;; Remove leading empty element
-           (setq ispell-filter (cdr ispell-filter))
-           ;; ispell process should return something after word is sent.
-           ;; Tag word as valid (i.e., skip) otherwise
-           (or ispell-filter
-               (setq ispell-filter '(*)))
-           (if (consp ispell-filter)
-               (setq poss (ispell-parse-output (car ispell-filter))))
+            (if (not known-misspelling)
+                (progn
+                  (ispell-send-string "%\n")
+                  ;; put in verbose mode
+                  (ispell-send-string (concat "^" word "\n"))
+                  ;; we mark the ispell process so it can be killed
+                  ;; when emacs is exited without query
+                  (set-process-query-on-exit-flag ispell-process nil)
+                  ;; Wait until ispell has processed word.  Since this
+                  ;; code is often executed from post-command-hook but
+                  ;; the ispell process may not be responsive, it's
+                  ;; important to make sure we re-enable C-g.
+                  (with-local-quit
+                    (while (progn
+                             (accept-process-output ispell-process)
+                             (not (string= "" (car ispell-filter))))))
+                  ;; (ispell-send-string "!\n")
+                  ;; back to terse mode.
+                  ;; Remove leading empty element
+                  (setq ispell-filter (cdr ispell-filter))
+                  ;; ispell process should return something after word is sent.
+                  ;; Tag word as valid (i.e., skip) otherwise
+                  (or ispell-filter
+                      (setq ispell-filter '(*)))
+                  (if (consp ispell-filter)
+                      (setq poss (ispell-parse-output (car ispell-filter)))))
+              ;; Else, this was a known misspelling to begin with, and
+              ;; we should forge an ispell return value.
+              (setq poss (list word 0 '() '())))
            (let ((res (cond ((eq poss t)
                              ;; correct
                              (setq flyspell-word-cache-result t)
@@ -1433,7 +1441,7 @@
                                        t
                                      nil))))
                        (setq keep nil)
-                       (flyspell-word)
+                       (flyspell-word nil t)
                        ;; Search for next misspelled word will begin from
                        ;; end of last validated match.
                        (setq buffer-scan-pos (point))))


reply via email to

[Prev in Thread] Current Thread [Next in Thread]