Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
78 lines (61 sloc) 2.44 KB
;;; hippie-expand-slime.el --- Hook slime's completion into hippie-expand
;; Author: Steve Purcell <>
;; URL:
;; Version: DEV
;;; Commentary:
;; Usage:
;; (require 'hippie-expand-slime)
;; (add-hook 'slime-mode-hook 'set-up-slime-hippie-expand)
;; (add-hook 'slime-repl-mode-hook 'set-up-slime-hippie-expand))
;;; Code:
(require 'slime)
(require 'hippie-exp)
(autoload 'slime-fuzzy-completions "slime-fuzzy")
;; Return list of completions for PREFIX using `slime-fuzzy-completions'
;; returns a flat, sorted list of completion candidates
(defun hippie-expand-slime-fuzzy-completions (prefix)
(let ((completions (slime-fuzzy-completions prefix)))
(and completions
(mapcar 'car (car completions)))))
(defun try-expand-slime-with-fn (old complete-fn)
"Completion function for `hippie-expand' which uses one of
slime's completion functions."
(if (not old)
(he-init-string (slime-symbol-start-pos) (slime-symbol-end-pos))
(if (not (equal he-search-string ""))
(setq he-expand-list
(funcall complete-fn he-search-string))
(setq he-expand-list ()))))
(while (and he-expand-list
(he-string-member (car he-expand-list) he-tried-table))
(setq he-expand-list (cdr he-expand-list)))
(if (null he-expand-list)
(if old (he-reset-string))
(he-substitute-string (car he-expand-list))
(setq he-tried-table (cons (car he-expand-list) (cdr he-tried-table)))
(setq he-expand-list (cdr he-expand-list))
(defun try-expand-slime (old)
"Simple slime completion function for `hippie-expand'."
(try-expand-slime-with-fn old 'slime-simple-completions))
(defun try-expand-slime-fuzzy (old)
"Fuzzy slime completion function for `hippie-expand'."
(try-expand-slime-with-fn old 'hippie-expand-slime-fuzzy-completions))
(defun set-up-slime-hippie-expand (&optional fuzzy)
"Add an optionally-fuzzy slime completion function to the front of
`hippie-expand-try-functions-list' for the current buffer."
(set (make-local-variable 'hippie-expand-try-functions-list) hippie-expand-try-functions-list)
(add-to-list 'hippie-expand-try-functions-list
(if fuzzy
(provide 'hippie-expand-slime)
;;; hippie-expand-slime.el ends here