/[emacs]/emacs/lisp/textmodes/flyspell.el
ViewVC logotype

Diff of /emacs/lisp/textmodes/flyspell.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.89 by monnier, Mon Nov 28 16:44:37 2005 UTC revision 1.90 by eliz, Fri Dec 2 13:16:48 2005 UTC
# Line 1307  Word syntax described by `flyspell-dicti Line 1307  Word syntax described by `flyspell-dicti
1307  The list of incorrect words should be in `flyspell-external-ispell-buffer'.  The list of incorrect words should be in `flyspell-external-ispell-buffer'.
1308  \(We finish by killing that buffer and setting the variable to nil.)  \(We finish by killing that buffer and setting the variable to nil.)
1309  The buffer to mark them in is `flyspell-large-region-buffer'."  The buffer to mark them in is `flyspell-large-region-buffer'."
1310      (let (words-not-found
1311    (with-current-buffer flyspell-external-ispell-buffer          (ispell-otherchars (ispell-get-otherchars)))
1312      (goto-char (point-min))      (with-current-buffer flyspell-external-ispell-buffer
1313      ;; Loop over incorrect words.        (goto-char (point-min))
1314      (while (re-search-forward "\\([^\n]+\\)\n" (point-max) t)        ;; Loop over incorrect words.
1315        ;; Bind WORD to the next one.        (while (re-search-forward "\\([^\n]+\\)\n" (point-max) t)
1316        (let ((word (match-string 1)) (wordpos (point)))          ;; Bind WORD to the next one.
1317          ;; Here there used to be code to see if WORD is the same          (let ((word (match-string 1)) (wordpos (point)))
1318          ;; as the previous iteration, and count the number of consecutive            ;; Here there used to be code to see if WORD is the same
1319          ;; identical words, and the loop below would search for that many.            ;; as the previous iteration, and count the number of consecutive
1320          ;; That code seemed to be incorrect, and on principle, should            ;; identical words, and the loop below would search for that many.
1321          ;; be unnecessary too. -- rms.            ;; That code seemed to be incorrect, and on principle, should
1322          (if flyspell-issue-message-flag            ;; be unnecessary too. -- rms.
1323              (message "Spell Checking...%d%% [%s]"            (if flyspell-issue-message-flag
1324                       (* 100 (/ (float (point)) (point-max)))                (message "Spell Checking...%d%% [%s]"
1325                       word))                         (* 100 (/ (float (point)) (point-max)))
1326          ;; Search the other buffer for occurrences of this word,                         word))
1327          ;; and check them.  Stop when we find one that reports "incorrect".            (with-current-buffer flyspell-large-region-buffer
1328          ;; (I don't understand the reason for that logic,              (goto-char flyspell-large-region-beg)
1329          ;; but I didn't want to change it. -- rms.)              (let ((keep t))
1330          (with-current-buffer flyspell-large-region-buffer                ;; Iterate on string search until string is found as word,
1331            (goto-char flyspell-large-region-beg)                ;; not as substring
1332            (let ((keep t))                (while keep
1333              (while keep                  (if (search-forward word
1334                (if (search-forward word                                      flyspell-large-region-end t)
1335                                       flyspell-large-region-end t)                      (progn
1336                    (progn                        (goto-char (- (point) 1))
1337                      (setq flyspell-large-region-beg (point))                        (let* ((match-point (point)) ; flyspell-get-word might move it
1338                      (goto-char (- (point) 1))                               (flyword-prev-l (flyspell-get-word nil))
1339                      (setq keep                               (flyword-prev (car flyword-prev-l))
1340                            ;; Detect when WORD can't be checked properly                               (size-match (= (length flyword-prev) (length word))))
1341                            ;; because flyspell-get-word finds                          (when (or
1342                            ;; just part of it, and treat that as ok.                                 ;; size matches, we are done
1343                            (if (< (length (car (flyspell-get-word nil)))                                 size-match
1344                                   (length word))                                 ;; Matches as part of a boundary-char separated word
1345                                nil                                 (member word
1346                              (flyspell-word))))                                         (split-string flyword-prev ispell-otherchars))
1347                  (error "Bug: misspelled word `%s' (output pos %d) not found in buffer"                                 ;; ispell treats beginning of some TeX
1348                         word wordpos)))))))                                 ;; commands as nroff control sequences
1349      ;; we are done                                 ;; and strips them in the list of
1350      (if flyspell-issue-message-flag (message "Spell Checking completed.")))                                 ;; misspelled words thus giving a
1351    ;; Kill and forget the buffer with the list of incorrect words.                                 ;; non-existent word.  Skip if ispell
1352    (kill-buffer flyspell-external-ispell-buffer)                                 ;; is used, string is a TeX command
1353    (setq flyspell-external-ispell-buffer nil))                                 ;; (char before beginning of word is
1354                                   ;; backslash) and none of the previous
1355                                   ;; contitions match
1356                                   (and (not ispell-really-aspell)
1357                                        (save-excursion
1358                                          (goto-char (- (nth 1 flyword-prev-l) 1))
1359                                          (if (looking-at "[\\]" )
1360                                              t
1361                                            nil))))
1362                              (setq keep nil)
1363                              (flyspell-word)
1364                              ;; Next search will begin from end of last match
1365                              (setq flyspell-large-region-beg match-point))))
1366                      ;; Record if misspelling is not found and try new one
1367                      (add-to-list 'words-not-found
1368                                   (concat " -> " word " - "
1369                                           (int-to-string wordpos)))
1370                      (setq keep nil)))))))
1371          ;; we are done
1372          (if flyspell-issue-message-flag (message "Spell Checking completed.")))
1373        ;; Warn about not found misspellings
1374        (dolist (word words-not-found)
1375          (message "%s: word not found" word))
1376        ;; Kill and forget the buffer with the list of incorrect words.
1377        (kill-buffer flyspell-external-ispell-buffer)
1378        (setq flyspell-external-ispell-buffer nil)))
1379    
1380  ;;*---------------------------------------------------------------------*/  ;;*---------------------------------------------------------------------*/
1381  ;;*    flyspell-process-localwords ...                                  */  ;;*    flyspell-process-localwords ...                                  */
# Line 1375  The buffer to mark them in is `flyspell- Line 1400  The buffer to mark them in is `flyspell-
1400                                                           (match-end 1)))                                                           (match-end 1)))
1401              ;; This can fail when string contains a word with invalid chars.              ;; This can fail when string contains a word with invalid chars.
1402              ;; Error handling needs to be added between Ispell and Emacs.              ;; Error handling needs to be added between Ispell and Emacs.
1403              (if (and (< 1 (length string))                  (if (and (< 1 (length string))
1404                       (equal 0 (string-match ispell-casechars string)))                       (equal 0 (string-match ispell-casechars string)))
1405                  (push string localwords))))))                  (push string localwords))))))
1406      ;; Remove localwords matches from misspellings-buffer.      ;; Remove localwords matches from misspellings-buffer.
# Line 1419  The buffer to mark them in is `flyspell- Line 1444  The buffer to mark them in is `flyspell-
1444                        (if ispell-local-dictionary                        (if ispell-local-dictionary
1445                            (setq ispell-dictionary ispell-local-dictionary))                            (setq ispell-dictionary ispell-local-dictionary))
1446                        (setq args (ispell-get-ispell-args))                        (setq args (ispell-get-ispell-args))
                       (if (eq ispell-parser 'tex)  
                           (setq args (cons "-t" args)))  
1447                        (if ispell-dictionary ; use specified dictionary                        (if ispell-dictionary ; use specified dictionary
1448                            (setq args                            (setq args
1449                                  (append (list "-d" ispell-dictionary) args)))                                  (append (list "-d" ispell-dictionary) args)))

Legend:
Removed from v.1.89  
changed lines
  Added in v.1.90

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26