all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* flyspell.el: patch for doublons checking from flyspell-large-region
@ 2006-06-28 11:00 Agustin Martin
  2006-06-29  9:40 ` Agustin Martin
  2006-06-29 13:00 ` Richard Stallman
  0 siblings, 2 replies; 3+ messages in thread
From: Agustin Martin @ 2006-06-28 11:00 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 469 bytes --]

Hi,

In the current implementation, flyspell-large-region does not check for
adjacent duplicated words (doublons), while flyspell-mode does. I am
attaching a patch that tries to make sure that region is also checked for
doublons when using flyspell-large-region.

Proposed flyspell.el changelog entry:

(flyspell-check-region-doublons) New function to check for adjacent
    duplicated words (doublons) in the given region.
(flyspell-large-region) Use it.

-- 
Agustin

[-- Attachment #2: flyspell.el.check-large-region-doublons.diff --]
[-- Type: text/plain, Size: 1434 bytes --]

--- flyspell.el.orig	2006-06-28 12:01:43.000000000 +0200
+++ flyspell.el	2006-06-28 12:19:39.000000000 +0200
@@ -1455,6 +1455,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))
+    (goto-char end)
+    (flyspell-word)))
+
 ;;*---------------------------------------------------------------------*/
 ;;*    flyspell-large-region ...                                        */
 ;;*---------------------------------------------------------------------*/
@@ -1499,7 +1515,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...")))))
 

[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: flyspell.el: patch for doublons checking from flyspell-large-region
  2006-06-28 11:00 flyspell.el: patch for doublons checking from flyspell-large-region Agustin Martin
@ 2006-06-29  9:40 ` Agustin Martin
  2006-06-29 13:00 ` Richard Stallman
  1 sibling, 0 replies; 3+ messages in thread
From: Agustin Martin @ 2006-06-29  9:40 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 727 bytes --]

On Wed, Jun 28, 2006 at 01:00:43PM +0200, Agustin Martin wrote:
> Hi,
> 
> In the current implementation, flyspell-large-region does not check for
> adjacent duplicated words (doublons), while flyspell-mode does. I am
> attaching a patch that tries to make sure that region is also checked for
> doublons when using flyspell-large-region.
> 
> Proposed flyspell.el changelog entry:
> 
> (flyspell-check-region-doublons) New function to check for adjacent
>     duplicated words (doublons) in the given region.
> (flyspell-large-region) Use it.

A minor change, (goto-char end) line is redundant, 'move in the
re-search-forward call should already do the job. Attached updated patch, no
changes in changelog entry.

-- 
Agustin

[-- Attachment #2: flyspell.el.check-large-region-doublons.diff1 --]
[-- Type: text/plain, Size: 1413 bytes --]

--- flyspell.el.orig	2006-06-28 12:01:43.000000000 +0200
+++ flyspell.el	2006-06-29 11:33:46.000000000 +0200
@@ -1455,6 +1455,21 @@
 	    (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 ...                                        */
 ;;*---------------------------------------------------------------------*/
@@ -1499,7 +1514,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...")))))
 

[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: flyspell.el: patch for doublons checking from flyspell-large-region
  2006-06-28 11:00 flyspell.el: patch for doublons checking from flyspell-large-region Agustin Martin
  2006-06-29  9:40 ` Agustin Martin
@ 2006-06-29 13:00 ` Richard Stallman
  1 sibling, 0 replies; 3+ messages in thread
From: Richard Stallman @ 2006-06-29 13:00 UTC (permalink / raw)
  Cc: emacs-devel

The change looks safe enough, so if it works for you and no one
objects in a week, let's install it.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-06-29 13:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-06-28 11:00 flyspell.el: patch for doublons checking from flyspell-large-region Agustin Martin
2006-06-29  9:40 ` Agustin Martin
2006-06-29 13:00 ` Richard Stallman

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.