From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Herring, Davis" Newsgroups: gmane.emacs.devel Subject: RE: function for spell checking of strings Date: Mon, 3 Sep 2012 22:30:12 +0000 Message-ID: References: <1346525043.32699.YahooMailNeo@web125405.mail.ne1.yahoo.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1346711420 26013 80.91.229.3 (3 Sep 2012 22:30:20 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 3 Sep 2012 22:30:20 +0000 (UTC) To: Stefan Schlee , "emacs-devel@gnu.org" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Sep 04 00:30:22 2012 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1T8f9x-0006uT-QF for ged-emacs-devel@m.gmane.org; Tue, 04 Sep 2012 00:30:21 +0200 Original-Received: from localhost ([::1]:47956 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T8f9v-0002Og-2g for ged-emacs-devel@m.gmane.org; Mon, 03 Sep 2012 18:30:19 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:53001) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T8f9s-0002Ob-TN for emacs-devel@gnu.org; Mon, 03 Sep 2012 18:30:17 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T8f9r-0005HI-RG for emacs-devel@gnu.org; Mon, 03 Sep 2012 18:30:16 -0400 Original-Received: from proofpoint5.lanl.gov ([204.121.3.53]:56113) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T8f9r-0005GD-HK for emacs-devel@gnu.org; Mon, 03 Sep 2012 18:30:15 -0400 Original-Received: from mailrelay1.lanl.gov (mailrelay1.lanl.gov [128.165.4.101]) by proofpoint5.lanl.gov (8.14.4/8.14.4) with ESMTP id q83MUDKi031487; Mon, 3 Sep 2012 16:30:13 -0600 Original-Received: from localhost (localhost.localdomain [127.0.0.1]) by mailrelay1.lanl.gov (Postfix) with ESMTP id D3B5BE42998; Mon, 3 Sep 2012 16:30:13 -0600 (MDT) X-NIE-2-Virus-Scanner: amavisd-new at mailrelay1.lanl.gov Original-Received: from ECS-EXG-P-CH03.win.lanl.gov (ecs-exg-p-ch03.win.lanl.gov [128.165.106.13]) by mailrelay1.lanl.gov (Postfix) with ESMTP id C05C9E4298C; Mon, 3 Sep 2012 16:30:13 -0600 (MDT) Original-Received: from ECS-EXG-P-MB01.win.lanl.gov ([169.254.1.44]) by ECS-EXG-P-CH03.win.lanl.gov ([128.165.106.13]) with mapi id 14.02.0309.002; Mon, 3 Sep 2012 16:30:13 -0600 Thread-Topic: function for spell checking of strings Thread-Index: AQHNiHHHolW7glyRwU+2B7ULrRuEUZd5NXsr In-Reply-To: <1346525043.32699.YahooMailNeo@web125405.mail.ne1.yahoo.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [128.165.185.6] X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.7.7855, 1.0.431, 0.0.0000 definitions=2012-09-03_04:2012-09-03, 2012-09-03, 1970-01-01 signatures=0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Received-From: 204.121.3.53 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:152973 Archived-At: > I want to look up a string in one of the dictionaries accessible from=0A= > emacs. The string is not contained in a buffer (in which case I would=0A= > use `ispell-word=B4) but is only referred to by a variable in my elisp=0A= > code. There used to be a function 'spell-string' but the=0A= > spell-packages is obsoleted and the build in help system refers me to=0A= > 'ispell'. But I cannot find an equivalent function in the 'ispell'=0A= > package. Does any one know of a solution?=0A= =0A= I "wrote" this for a similar reason:=0A= =0A= ;; Ripped off from `ispell-word', of course, since it isn't useful for Lisp= .=0A= (defun ispell-check-word (&optional word)=0A= "Check spelling of WORD, or word under or before the cursor if nil.=0A= If it is spelled correctly, return a root string or t if it is exact.=0A= If it is misspelled, return (CORRECTIONS . GUESSES).=0A= =0A= If WORD is t, then the following word \(rather than preceding\) is checked.= =0A= =0A= Word syntax is controlled by the definition of the chosen dictionary,=0A= which is in `ispell-local-dictionary-alist' or `ispell-dictionary-alist'.= =0A= =0A= This will check or reload the dictionary. Use \\[ispell-change-dictionary]= =0A= or \\[ispell-region] to update the Ispell process."=0A= (ispell-init)=0A= (ispell-accept-buffer-local-defs) ; use the correct dictionary=0A= (or (stringp word) (setq word (car (ispell-get-word word))))=0A= =0A= (ispell-send-string "%\n") ; put in verbose mode=0A= (ispell-send-string (concat "^" word "\n"))=0A= ;; wait until ispell has processed word=0A= (while (progn (ispell-accept-output) (not (string=3D "" (car ispell-filte= r)))))=0A= ;;(ispell-send-string "!\n") ;back to terse mode.=0A= (setq ispell-filter (cdr ispell-filter)) ; remove extra \n=0A= (let (poss)=0A= (if (and ispell-filter (listp ispell-filter))=0A= (if (> (length ispell-filter) 1)=0A= (error "Ispell and its process have different character maps")= =0A= (setq poss (ispell-parse-output (car ispell-filter)))))=0A= (unless poss (error "Error in ispell process"))=0A= (if (or (eq poss t) (stringp poss)) poss=0A= (setq poss (cddr poss)) (cons (car poss) (cadr poss)))))=0A= =0A= Davis=0A=