Skip to content

Instantly share code, notes, and snippets.

@thisirs
Created September 11, 2012 09:57
Show Gist options
  • Save thisirs/3697342 to your computer and use it in GitHub Desktop.
Save thisirs/3697342 to your computer and use it in GitHub Desktop.
hippie-expand and flyspell
(defun try-complete-flyspell (old)
(when (not old)
;; use the correct dictionary
(flyspell-accept-buffer-local-defs)
(setq he-next-expand 0)
(he-init-string (he-dabbrev-beg) (point))
;; now check spelling of word.
(ispell-send-string "%\n") ;put in verbose mode
(ispell-send-string (concat "^" he-search-string "\n"))
;; wait until ispell has processed word
(while (progn
(accept-process-output ispell-process)
(not (string= "" (car ispell-filter)))))
;; Remove leading empty element
(setq ispell-filter (cdr ispell-filter))
;; ispell process should return something after word is sent.
;; Tag word as valid (i.e., skip) otherwise
(or ispell-filter
(setq ispell-filter '(*)))
(if (consp ispell-filter)
(setq he-expand-list (ispell-parse-output (car ispell-filter))
he-expand-list (if (consp he-expand-list)
(nth 2 (ispell-parse-output (car ispell-filter)))))))
(while (and he-expand-list
(or (not (car he-expand-list))
(he-string-member (car he-expand-list) he-tried-table t)))
(setq he-expand-list (cdr he-expand-list)))
(if (null he-expand-list)
(progn
(if old (he-reset-string))
())
(progn
(he-substitute-string (car he-expand-list) t)
(setq he-expand-list (cdr he-expand-list))
t)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment