From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: d@teklibre.org (Dave =?utf-8?Q?T=C3=A4ht?=) Newsgroups: gmane.emacs.help Subject: Re: Auto-correcting proper nouns with flyspell? Date: Wed, 16 Sep 2009 19:32:04 -0600 Organization: Teklibre - http://www.teklibre.com Message-ID: <87ab0ucq5n.fsf@mahal.sjds.teklibre.org> References: <87ljkhdjgk.fsf@mahal.sjds.teklibre.org> <87ocpb5cmh.fsf@mundaneum.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1253158861 19858 80.91.229.12 (17 Sep 2009 03:41:01 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 17 Sep 2009 03:41:01 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Sep 17 05:40:53 2009 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Mo7rW-0002RY-Cr for geh-help-gnu-emacs@m.gmane.org; Thu, 17 Sep 2009 05:40:53 +0200 Original-Received: from localhost ([127.0.0.1]:55028 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mo7rT-0004qE-Rt for geh-help-gnu-emacs@m.gmane.org; Wed, 16 Sep 2009 23:40:47 -0400 Original-Path: news.stanford.edu!usenet.stanford.edu!news.isc.org!mahal.sjds.teklibre.org!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 131 Original-NNTP-Posting-Host: toutatis.isc.org Original-X-Trace: sf1.isc.org 1253156832 27790 149.20.54.64 (17 Sep 2009 03:07:12 GMT) Original-X-Complaints-To: abuse@isc.org Original-NNTP-Posting-Date: Thu, 17 Sep 2009 03:07:12 +0000 (UTC) X-PGP-FP: D179 9E87 2617 CA13 9A84 E833 A5D7 A325 C395 E2E4 X-PGP: 0xC395E2E4 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.91 (gnu/linux) Cancel-Lock: sha1:C8L0WNkw5PUsr66iTVTp14luBSE= Original-Xref: news.stanford.edu gnu.emacs.help:173102 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:68224 Archived-At: "Fabrice Niessen" 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