emacs-devel
[Top][All Lists]
Advanced

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

flyspell: check repeated words in another way.


From: Michaël Cadilhac
Subject: flyspell: check repeated words in another way.
Date: Thu, 30 Aug 2007 17:44:17 +0200
User-agent: Gnus/5.110007 (No Gnus v0.7) Emacs/23.0.50 (gnu/linux)

Hi folk!

You all know how French is a beautiful language, constructed with poetry
in mind, and has been for many years one of the thing the French are
proudest about.

However, such beautifulness doesn't come without a price.  For instance,
when we write « we love each other », we say « nous nous aimons ».  If
you have a close look, you'll see there's a repeated « nous », and this
is normal.  Another example would be « vous vous battez », with a
doubled « vous ».  Those are the only exceptions I can think of, but
anyway, the problem is that flyspell flags them as errors.

Maybe the following could be installed, and if it's too specific, it
could be useful for someone.

Index: flyspell.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/textmodes/flyspell.el,v
retrieving revision 1.122
diff -b -u -w -r1.122 flyspell.el
--- flyspell.el 13 Aug 2007 13:40:48 -0000      1.122
+++ flyspell.el 30 Aug 2007 15:33:39 -0000
@@ -66,12 +66,22 @@
   :type 'boolean)
 
 (defcustom flyspell-mark-duplications-flag t
-  "Non-nil means Flyspell reports a repeated word as an error.
+  "Non-nil means Flyspell treats repeated words as errors.
+See `flyspell-mark-duplications-exceptions' to add exceptions to this rule.
 Detection of repeated words is not implemented in
 \"large\" regions; see `flyspell-large-region'."
   :group 'flyspell
   :type 'boolean)
 
+(defcustom flyspell-mark-duplications-exceptions
+  '(("francais" . ("nous" "vous")))
+  "A list of exception for duplicated words.
+It should be a list of (LANGUAGE . EXCEPTION-LIST).  LANGUAGE is matched
+against the current dictionary and EXCEPTION-LIST is a list of strings.
+The duplicated word is downcased before it is compared with the exceptions."
+  :group 'flyspell
+  :type '(alist :key-type string :value-type (repeat string)))
+
 (defcustom flyspell-sort-corrections nil
   "Non-nil means, sort the corrections alphabetically before popping them."
   :group 'flyspell
@@ -1022,6 +1032,13 @@
                     (and (> start (point-min))
                          (not (memq (char-after (1- start)) '(?\} ?\\)))))
                 flyspell-mark-duplications-flag
+                (not (catch 'exception
+                       (dolist (except flyspell-mark-duplications-exceptions)
+                         (and (string= (or ispell-local-dictionary
+                                           ispell-dictionary)
+                                       (car except))
+                              (member (downcase word) (cdr except))
+                              (throw 'exception t)))))
                 (save-excursion
                   (goto-char start)
                   (let* ((bound
So long!

-- 
 |   Michaël `Micha' Cadilhac       |  21 seems like a good value: half of   |
 |   http://michael.cadilhac.name   |  of 42 and just old enough to drink!   |
 |   JID/MSN:                       |   Why would you want to change it?     |
 `----  address@hidden  |          -- Stefan Monnier        -  --'

Attachment: pgpphaJPDx2ZQ.pgp
Description: PGP signature


reply via email to

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