all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Auto-correcting proper nouns with flyspell?
@ 2009-09-15  2:34 Dave Täht
  2009-09-16  9:53 ` Andreas Politz
       [not found] ` <mailman.6789.1253094817.2239.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 7+ messages in thread
From: Dave Täht @ 2009-09-15  2:34 UTC (permalink / raw
  To: help-gnu-emacs


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?

You don't dave a car or michael a wrench, and while you may ring a
clapper on occasion, I am more likely to write to a Brian Clapper than ring
a clapper.
   
Typing brian shows up as mis-spelt rather than being auto-corrected into
Brian. As examples, the first suggestion for brian, dave, or michael in
flyspell (ESC-TAB) just recapitalizes it. Why can't it just do that for
me?

If I meant, brain, not Brian, I'll go and fix it. It's easy to spot
wrongly capitalized words in the middle of a sentence.

"I was really talking about Einstein's Brian, and the mysteries locked
within."

I know I could fix this with abbrev, but there are an awful lot of very
distinct proper nouns in this world, and flyspell already does most of
the right thing...

It would also be nice to be able to prioritize your proper names over
ancient words nobody uses anymore. Take smith for example. How often do
you use a smith these days? How often do you correspond with John Smith?
How often do you have a smith in the john? 


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


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

* Re: Auto-correcting proper nouns with flyspell?
  2009-09-15  2:34 Auto-correcting proper nouns with flyspell? Dave Täht
@ 2009-09-16  9:53 ` Andreas Politz
       [not found] ` <mailman.6789.1253094817.2239.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 7+ messages in thread
From: Andreas Politz @ 2009-09-16  9:53 UTC (permalink / raw
  To: help-gnu-emacs

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))

-ap





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

* Re: Auto-correcting proper nouns with flyspell?
       [not found] ` <mailman.6789.1253094817.2239.help-gnu-emacs@gnu.org>
@ 2009-09-16 11:53   ` Fabrice Niessen
  2009-09-17  0:28     ` Andreas Politz
                       ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Fabrice Niessen @ 2009-09-16 11:53 UTC (permalink / raw
  To: help-gnu-emacs-mXXj517/zsQ

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))

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.

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.

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

Best regards,
  Fabrice

-- 
Fabrice Niessen
Search the Web with "My Google Search Tools" on http://www.MyGooglest.com


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

* Re: Auto-correcting proper nouns with flyspell?
  2009-09-16 11:53   ` Fabrice Niessen
@ 2009-09-17  0:28     ` Andreas Politz
  2009-09-17  1:32     ` Dave Täht
       [not found]     ` <mailman.6834.1253147339.2239.help-gnu-emacs@gnu.org>
  2 siblings, 0 replies; 7+ messages in thread
From: Andreas Politz @ 2009-09-17  0:28 UTC (permalink / raw
  To: help-gnu-emacs

"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.
>> [code]
> While the idea is good, I personally find this dangerous, as "Emacs" [..]

I was merely, at least partially, answering the question.  I didn't mean
for it to be looked at as a full-fledged solution to the problem.

-ap





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

* Re: Auto-correcting proper nouns with flyspell?
  2009-09-16 11:53   ` Fabrice Niessen
  2009-09-17  0:28     ` Andreas Politz
@ 2009-09-17  1:32     ` Dave Täht
  2009-09-17  9:16       ` Fabrice Niessen
       [not found]     ` <mailman.6834.1253147339.2239.help-gnu-emacs@gnu.org>
  2 siblings, 1 reply; 7+ messages in thread
From: Dave Täht @ 2009-09-17  1:32 UTC (permalink / raw
  To: help-gnu-emacs

"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


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

* Re: Auto-correcting proper nouns with flyspell?
       [not found]     ` <mailman.6834.1253147339.2239.help-gnu-emacs@gnu.org>
@ 2009-09-17  8:14       ` Fabrice Niessen
  0 siblings, 0 replies; 7+ messages in thread
From: Fabrice Niessen @ 2009-09-17  8:14 UTC (permalink / raw
  To: help-gnu-emacs-mXXj517/zsQ

Hi Andreas,

Andreas Politz wrote:
> "Fabrice Niessen" <fgdmjuzqrjgh-geNee64TY+gS+FvcfC7Uqw@public.gmane.org> writes:
>> 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.
>>> [code]
>>
>> While the idea is good, I personally find this dangerous, as "Emacs" [..]
>
> I was merely, at least partially, answering the question. I didn't mean for
> it to be looked at as a full-fledged solution to the problem.

Yes, I know. And I was pleased learning some new aspects of `flyspell' with
that hook I didn't know about...

Thanks for having written down the code the OP wanted.

I was just trying to show the OP that such a rule may lead to mistakes we're
not really aware of...

Best regards,
  Fabrice

-- 
Fabrice Niessen
Search the Web with "My Google Search Tools" on http://www.MyGooglest.com


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

* Re: Auto-correcting proper nouns with flyspell?
  2009-09-17  1:32     ` Dave Täht
@ 2009-09-17  9:16       ` Fabrice Niessen
  0 siblings, 0 replies; 7+ messages in thread
From: Fabrice Niessen @ 2009-09-17  9:16 UTC (permalink / raw
  To: help-gnu-emacs-mXXj517/zsQ

Hi Dave,

Dave Täht wrote:
> "Fabrice Niessen" <fgdmjuzqrjgh-geNee64TY+gS+FvcfC7Uqw@public.gmane.org> writes:
>> Andreas Politz wrote:
>>> d@teklibre.org (Dave Täht) writes:
>>
>> [...]
>>
>> 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).

I agree with you that waiting for the fontifying and the spelling of Org files
when firing up Emacs is annoying, at least as long as you don't switch to
those buffers. Good point.

Though, in some cases, I don't want to get my buffers scanned for spelling
mistakes if I don't (plan to) edit them:

- files that I edit, and which are scanned when I edit them, don't need to be
  rescanned at opening: I know that the spelling is correct;

- files that I may not or don't want to edit (because I'm not the author,
  because they're read-only, etc., etc.) shouldn't be scanned. The decision
  point is: wait until I change those files.


> 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.
>
> [code]

Thanks for sharing.

Best regards,
  Fabrice

-- 
Fabrice Niessen
Search the Web with "My Google Search Tools" on http://www.MyGooglest.com


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

end of thread, other threads:[~2009-09-17  9:16 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-15  2:34 Auto-correcting proper nouns with flyspell? Dave Täht
2009-09-16  9:53 ` Andreas Politz
     [not found] ` <mailman.6789.1253094817.2239.help-gnu-emacs@gnu.org>
2009-09-16 11:53   ` Fabrice Niessen
2009-09-17  0:28     ` Andreas Politz
2009-09-17  1:32     ` Dave Täht
2009-09-17  9:16       ` Fabrice Niessen
     [not found]     ` <mailman.6834.1253147339.2239.help-gnu-emacs@gnu.org>
2009-09-17  8:14       ` Fabrice Niessen

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.