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

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

Re: Auto-correcting proper nouns with flyspell?


From: Dave Täht
Subject: Re: Auto-correcting proper nouns with flyspell?
Date: Wed, 16 Sep 2009 19:32:04 -0600
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.91 (gnu/linux)

"Fabrice Niessen" <fgdmjuzqrjgh@spammotel.com> writes:

> Hi,
>
> Andreas Politz wrote:
>> d@teklibre.org (Dave Täht) writes:
>>
>>> Is there a way to make Emacs (flyspell) automatically capitalize
>>> proper nouns that have no other equivalent, instead of marking them
>>> in yellow with an underscore?
>>
>> Since there is `flyspell-incorrect-hook', you can do all kinds of
>> things.
>>
>> (defun flyspell-correct-case (beg end info) (when (and (consp info)
>>   (equal (downcase (car info)) (downcase (caaddr info))))
>>   (save-excursion (delete-region beg end) (insert (caaddr info)))))
>>
>> (add-hook 'flyspell-incorrect-hook 'flyspell-correct-case))

First, my thanks to Andreas for the beginnings of a solution. I will
give this a shot and see what annoyances crop up, but read on...

> While the idea is good, I personally find this dangerous, as "Emacs"
> then changes things for you, without you knowing which ones in
> particular (how to find where it has been auto-corrected?). I know I
> can expect such a behavior from MS Word, with its wizzard and its
> auto-correction rules, but I personally hate that behavior from Emacs.
>
> For example, "Next meeting on 5th of October" becomes "Next meeting on
> 5Th of October" with such hook. Not nice for that particular case.

Well, my specific question was regarding the set of proper nouns, a
formal definition of which (cribbed from
http://www.chompchomp.com/terms/propernoun.htm) is:

"Nouns name people, places, and things. Every noun can further be
 classified as common or proper. A proper noun has two distinctive
 features: 1) it will name a specific [usually a one-of-a-kind] item,
 and 2) it will begin with a capital letter no matter where it occurs in
 a sentence."

Flyspell wants to offer up a list of alternatives to michael, for
example, such as Miguel, that might make sense to a non-native speaker,
but I think the desirable percentage of these sort of corrections is
vanishingly small.

So, to me, the next step is finding a database of truly proper nouns
and figuring out how to make the hook Andreas suggested work against it.

> On the other hand, one thing that I want from Emacs + ispell, and that
> MS doesn't offer (IMHO): the possibility to leave buffers unscanned
> for errors when just opening files for reading. As soon as we change
> something in them, then, yes, ispell is launched over the whole
> buffer. I have this behavior already working for years, but I still
> have troubles with ispell and some modes (like Org). Have to spend
> some time identifiying the root cause.

I have run into this too (was subject to a minor rant on the org-mode
mailing list a few days ago). Before org and semantic, I rarely cracked
a few dozen files open at a time, now it is often in the hundreds. I
actually find semantic unusable in precisely the situations where it
would be most useful - very large - ardour.org sized - codebases. I'll
keep trying it though)

Org, in particular, fires up my 8 or 9 text mode hooks and flyspell for
every buffer it scans in the background and that can get chunky,
especially on the first scan.

I would like to defer instanciation of my ever increasing number of
text-mode hooks, until I actually have the buffer visible on the screen
(best), or I actually type a character in the buffer (not as good).

Like everything else in emacs, I'm pretty sure there's a way to do that,
but haven't gotten around to doing it.

> If you're interested, take a look at
> http://www.mygooglest.com/fni/dot-emacs.html.

Will do.

This is my kinder, gentler fix to my org configuration, to only let it
scan agenda entries when the system is idle for a minute. I would like
to make it even gentler and have it not run after 7PM at all, but
haven't got around to it yet. It may be overly or underly complex as
written.

(setq org-agenda-to-appt-timer-running nil) 
(setq org-agenda-to-appt-timer nil)

(defun org-agenda-to-appt-run () 
       "Run org-agenda-to-appt and reset the flag"
         (org-agenda-to-appt)
           (setq org-agenda-to-appt-timer-running nil)
             )

;; I could set this as a hook to run automatically after modifying an
;; org-mode buffer, too. Experiment for a while first

(defun org-agenda-to-appt-background (&optional idletime) 
  "Run org-agenda-to-appt only when the computer is idle"
  (if (not org-agenda-to-appt-timer-running) 
    (progn 
    (setq org-agenda-to-appt-timer-running t)
    (if (not idletime) (setq idletime 60)) 
    (setq org-agenda-to-appt-timer 
      (run-with-idle-timer idletime nil 
         'org-agenda-to-appt-run-background)
   )))) 

;; Not sure if keeping the cancel timer stuff around is the right thing,
;; but I want to be able to turn it off after business hours.

(when window-system
  (setq appt-display-format 'window)
  (defun org-osd-display (min-to-app new-time msg)
    (rgr/osd-display msg msg -1 "center" "center" "Verdana 20"))
  (setq appt-disp-window-function (function org-osd-display))
  
  ;; Run once, activate and schedule refresh (org-remember-insinuate)
  (setq appt-background-timer (run-at-time nil 600
  'org-agenda-to-appt-background)) (appt-activate t))


>
> Best regards,
>   Fabrice

-- 
Dave Taht
http://the-edge.blogspot.com


reply via email to

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