emacs-autocomplete-words

This is part of The Pile, a partial archive of some open source mailing lists and newsgroups.



Subject: Re: Autocomplete with a dictionary
From: John Wiegley <johnw@gnu.org>
Date: 16 Jun 2001 16:28:13 -0400


>>>>> On Sat Jun 16, Lijiv writes:

> The default autocomplete feature (M-/) works only for words which
> have been in the same file. Is there any way to force emacs to do
> autocomplete from a dictionary. i.e, I have a dictionary file and
> emacs should complete words which exists in the dictionary file.

M-x ispell-complete-word will do exactly what you wish.  I believe it
is bound to M-TAB automatically for you in textual modes.

John


Path: nntp.stanford.edu!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!t-online.de!nautilus.eusc.inter.net!newsfeed.Austria.EU.net!newsfeed.kpnqwest.at!anon.lcs.mit.edu!nym.alias.net!mail2news
X-Sent: 18 Jun 2001 17:40:56 GMT

===

Subject: Re: Autocomplete with a dictionary
From: John Wiegley <johnw@gnu.org>
Date: 18 Jun 2001 13:40:46 -0400


>>>>> On Mon Jun 18, Kai writes:

> On 18 Jun 2001, Stephan Zimmermann wrote:
>> Is there also a way to make ispell-complete-word work like
>> dabbrev-expand ?  It's quite nice to cycle through all possible
>> completitions...

> John's great package pcomplete allows cycling.  Maybe you can tell
> it to use ispell-complete-word somehow.  (Though I don't know how).

Hmmm... all pcomplete needs is the part of the word you want to
complete against, and a list of possible completions.

Here is the code you need (untested).  Now just type in part of a word
and hit M-tab.

----------------------------------------------------------------------
(require 'pcomplete)

(add-hook 'text-mode hook
 (function (lambda nil
  (when (featurep 'pcomplete)
    (local-set-key [(meta tab)] 'pcomplete)
    (local-set-key [(meta control ?i)] 'pcomplete)

    (set (make-variable-buffer-local 'pcomplete-default-completion-function)
         'find-ispell-completions)
    (set (make-variable-buffer-local 'pcomplete-command-completion-function)
         'find-ispell-completions)
    (set (make-variable-buffer-local 'pcomplete-parse-arguments-function)
         'find-current-word)))))

;; now we need find-ispell-completions and find-current-word:

(defun find-ispell-completions ()
  "Return a list of possible completions for this word."
  (mapcar
   (function
    (lambda (member)
      (car member)))
   (lookup-words (concat pcomplete-stub "*") 
                 ispell-complete-word-dict)))

(defun find-current-word ()
  (let ((end (point)))
    (save-restriction
      (save-excursion
        (skip-chars-backward "^\\[ \t\n")
        (narrow-to-region (point) end))
      (pcomplete-parse-buffer-arguments))))


Path: nntp.stanford.edu!newsfeed.stanford.edu!cyclone.bc.net!news-hog.berkeley.edu!ucberkeley!news.ycc.yale.edu!rum.cs.yale.edu!rum.cs.yale.edu
From: "Stefan Monnier <foo@acm.com>" <monnier+comp.emacs/news/@flint.cs.yale.edu>
Newsgroups: comp.emacs
Subject: Re: Autocomplete with a dictionary
Date: 18 Jun 2001 14:08:37 -0400
Organization: Yale University
Lines: 8

===







the rest of The Pile (a partial mailing list archive)

doom@kzsu.stanford.edu