Permalink
Browse files

Initial check-in

  • Loading branch information...
0 parents commit de31fbc9f9d55891a006463bcee7670b47084015 @purcell committed Nov 15, 2011
Showing with 67 additions and 0 deletions.
  1. +67 −0 hippie-expand-slime.el
@@ -0,0 +1,67 @@
+;;; hippie-expand-slime.el --- Hook slime's completion into hippie-expand
+
+;; Author: Steve Purcell <steve@sanityinc.com>
+;; URL: https://github.com/purcell/hippie-expand-slime
+;; 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:
+
+(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)
+ (progn
+ (he-init-string (slime-symbol-start-pos) (slime-symbol-end-pos))
+ (if (not (equal he-search-string ""))
+ (setq he-expand-list
+ (sort (car (funcall complete-fn he-search-string))
+ 'string-lessp))
+ (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)
+ (progn
+ (if old (he-reset-string))
+ ())
+ (progn
+ (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))
+ t)))
+
+
+;;;###autoload
+(defun try-expand-slime (old)
+ "Simple slime completion function for `hippie-expand'."
+ (try-expand-slime-with-fn old 'slime-simple-completions))
+
+;;;###autoload
+(defun try-expand-slime-fuzzy (old)
+ "Fuzzy slime completion function for `hippie-expand'."
+ (try-expand-slime-with-fn old 'slime-fuzzy-completions))
+
+
+;;;###autoload
+(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."
+ (interactive)
+ (set (make-local-variable 'hippie-expand-try-functions-list) hippie-expand-try-functions-list)
+ (add-to-list 'hippie-expand-try-functions-list
+ (if fuzzy
+ 'try-expand-slime-fuzzy
+ 'try-expand-slime)))
+
+
+(provide 'hippie-expand-slime)
+
+;;; hippie-expand-slime.el ends here

0 comments on commit de31fbc

Please sign in to comment.