Skip to content

Instantly share code, notes, and snippets.

@bamanzi
Created February 17, 2012 08:33
Show Gist options
  • Save bamanzi/1851835 to your computer and use it in GitHub Desktop.
Save bamanzi/1851835 to your computer and use it in GitHub Desktop.
[emacs] auto-complete + ispell
(defun ac-ispell-get-word ()
(format "\\(%s\\)" (car (ispell-get-word nil "\\*"))))
(defun ac-ispell-get-candidates (prefix)
(let ((word prefix)
(interior-frag nil))
(lookup-words (concat (and interior-frag "*") word
(if (or interior-frag (null ispell-look-p))
"*"))
ispell-complete-word-dict)))
(ac-define-source ispell
'((prefix . ac-prefix)
(candidates . ac-ispell-get-candidates)))
;; it's not a good idea to add `ac-source-ispell' to `ac-sources',
;; I'll recommend manual invoking.
;; newer version of `ac-define-source' would provide us an `ac-complete-ispell-word'.
;; in case it didn't:
(defun ac-expand-ispell-word ()
(interactive)
(let ((ac-sources '(ac-source-ispell)))
(call-interactively 'ac-start)))
(define-key global-map (kbd "C-/ s") 'ac-expand-ispell-word)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment