diff lisp/textmodes/flyspell.el @ 72924:d50645027830

* textmodes/flyspell.el (flyspell-check-region-doublons): New function to detect duplicated words. (flyspell-large-region): Use it.
author Chong Yidong <cyd@stupidchicken.com>
date Sat, 16 Sep 2006 15:05:47 +0000
parents 6cd2742162f9
children 9b6f22920434 b5c13d1564a9
line wrap: on
line diff
--- a/lisp/textmodes/flyspell.el	Sat Sep 16 14:19:31 2006 +0000
+++ b/lisp/textmodes/flyspell.el	Sat Sep 16 15:05:47 2006 +0000
@@ -1460,6 +1460,22 @@
 	    (while (re-search-forward regexp nil t)
 	      (delete-region (match-beginning 0) (match-end 0)))))))))
 
+;;* ---------------------------------------------------------------
+;;*     flyspell-check-region-doublons
+;;* ---------------------------------------------------------------
+(defun flyspell-check-region-doublons (beg end)
+  "Check for adjacent duplicated words (doublons) in the given region."
+  (save-excursion
+    (goto-char beg)
+    (flyspell-word)     ; Make sure current word is checked
+    (backward-word 1)
+    (while (and (< (point) end)
+		(re-search-forward "\\b\\([^ \n\t]+\\)[ \n\t]+\\1\\b"
+				   end 'move))
+      (flyspell-word)
+      (backward-word 1))
+    (flyspell-word)))
+
 ;;*---------------------------------------------------------------------*/
 ;;*    flyspell-large-region ...                                        */
 ;;*---------------------------------------------------------------------*/
@@ -1504,7 +1520,8 @@
 	  (progn
 	    (flyspell-process-localwords buffer)
 	    (with-current-buffer curbuf
-	      (flyspell-delete-region-overlays beg end))
+	      (flyspell-delete-region-overlays beg end)
+	      (flyspell-check-region-doublons beg end))
 	    (flyspell-external-point-words))
 	(error "Can't check region...")))))