(require 'pcomplete) (setq pcomplete-ignore-case t) ; ignore case (setq pcomplete-cycle-cutoff-length nil) ; cycle through all completions
(defun pcomplete-text-setup () "Setup the dictionary completion functions for text-mode." (interactive) (require 'ispell) (local-set-key [(meta control ?i)] 'pcomplete) ; bind M-C-i to 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)) (add-hook 'text-mode-hook 'pcomplete-text-setup)
(defun find-ispell-completions () "Return a list of completions using the ispell dictionary." (pcomplete-here ; preserve the cases of the original string (mapcar (lambda (str) (concat pcomplete-stub (substring str (length pcomplete-stub)))) (lookup-words (concat pcomplete-stub "*") ispell-complete-word-dict))))