help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Automatic handling of TYpos


From: martin rudalics
Subject: Re: Automatic handling of TYpos
Date: Fri, 02 Feb 2007 08:34:10 +0100
User-agent: Mozilla Thunderbird 1.0 (Windows/20041206)

Is there any emacs function that I can turn on to fix THis KInd of
MIstakes automatically ?

In your example there are actually _two_ kinds of "mistakes".  One kind
is that you capitalize words like "this" or "kind" in the middle of a
sentence.  There's no simple solution to that.  The other mistake is
that of an upper-case character in the second position of a word.
Correcting the latter should not be difficult with flyspell.  Try adding
code like the 100% untested below to `flyspell-incorrect-hook' (and be
aware of the fact that auto-correction is something you'll hardly notice
while typing).

(defun flyspell-maybe-downcase-second-character (beg end guesses)
  "Try to downcase second character."
  (when (consp guesses)
    (let ((string (buffer-substring beg end))
          second)
      (when (and (> (- end beg) 1)
                 (not (equal (aref string 0) (downcase (aref string 0))))
                 (not (equal (aref string 1) (downcase (aref string 1)))))
        (setq string
              (concat
               (substring string 0 1)
               (setq second (downcase (substring string 1 2)))
               (substring string 2)))
        (catch 'done
          (dolist (guess guesses)
            (when (string-equal string guess)
              (goto-char (1+ beg))
              (insert second)
              (delete-char 1)
              (throw 'done t))))))))






reply via email to

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