* function for spell checking of strings
@ 2012-09-01 18:44 Stefan Schlee
2012-09-03 22:30 ` Herring, Davis
0 siblings, 1 reply; 2+ messages in thread
From: Stefan Schlee @ 2012-09-01 18:44 UTC (permalink / raw)
To: emacs-devel@gnu.org
[-- Attachment #1: Type: text/plain, Size: 870 bytes --]
Hello!
The question I'd like to ask, seems to be somewhere between the topics covered by "emacs-devel@gnu.org" and "help-gnu-evams@gnu.org"
I have already posted it on "help-gnu-evams@gnu.org" but did not get a working answer. Sorry for cross-posting, but some of you might not be watching "help-gnu-evams@gnu.org".
Here is the question:
I want to look up a string in one of the dictionaries accessible from emacs. The string is not contained in a buffer (in which case I would use `ispell-word´) but is only referred to by a variable in my elisp code. There used to be a function 'spell-string' but the spell-packages is obsoleted and the build in help system refers me to 'ispell'. But I cannot find an equivalent function in the 'ispell' package. Does any one know of a solution?
I am using Emacs version 23.2.1.
Thank you in advance, Stefan
[-- Attachment #2: Type: text/html, Size: 1071 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
* RE: function for spell checking of strings
2012-09-01 18:44 function for spell checking of strings Stefan Schlee
@ 2012-09-03 22:30 ` Herring, Davis
0 siblings, 0 replies; 2+ messages in thread
From: Herring, Davis @ 2012-09-03 22:30 UTC (permalink / raw)
To: Stefan Schlee, emacs-devel@gnu.org
> I want to look up a string in one of the dictionaries accessible from
> emacs. The string is not contained in a buffer (in which case I would
> use `ispell-word´) but is only referred to by a variable in my elisp
> code. There used to be a function 'spell-string' but the
> spell-packages is obsoleted and the build in help system refers me to
> 'ispell'. But I cannot find an equivalent function in the 'ispell'
> package. Does any one know of a solution?
I "wrote" this for a similar reason:
;; Ripped off from `ispell-word', of course, since it isn't useful for Lisp.
(defun ispell-check-word (&optional word)
"Check spelling of WORD, or word under or before the cursor if nil.
If it is spelled correctly, return a root string or t if it is exact.
If it is misspelled, return (CORRECTIONS . GUESSES).
If WORD is t, then the following word \(rather than preceding\) is checked.
Word syntax is controlled by the definition of the chosen dictionary,
which is in `ispell-local-dictionary-alist' or `ispell-dictionary-alist'.
This will check or reload the dictionary. Use \\[ispell-change-dictionary]
or \\[ispell-region] to update the Ispell process."
(ispell-init)
(ispell-accept-buffer-local-defs) ; use the correct dictionary
(or (stringp word) (setq word (car (ispell-get-word word))))
(ispell-send-string "%\n") ; put in verbose mode
(ispell-send-string (concat "^" word "\n"))
;; wait until ispell has processed word
(while (progn (ispell-accept-output) (not (string= "" (car ispell-filter)))))
;;(ispell-send-string "!\n") ;back to terse mode.
(setq ispell-filter (cdr ispell-filter)) ; remove extra \n
(let (poss)
(if (and ispell-filter (listp ispell-filter))
(if (> (length ispell-filter) 1)
(error "Ispell and its process have different character maps")
(setq poss (ispell-parse-output (car ispell-filter)))))
(unless poss (error "Error in ispell process"))
(if (or (eq poss t) (stringp poss)) poss
(setq poss (cddr poss)) (cons (car poss) (cadr poss)))))
Davis
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-09-03 22:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-01 18:44 function for spell checking of strings Stefan Schlee
2012-09-03 22:30 ` Herring, Davis
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.