Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 68 lines (53 sloc) 2.145 kB
de31fbc @purcell Initial check-in
authored
1 ;;; hippie-expand-slime.el --- Hook slime's completion into hippie-expand
2
3 ;; Author: Steve Purcell <steve@sanityinc.com>
4 ;; URL: https://github.com/purcell/hippie-expand-slime
5 ;; Version: DEV
6
7 ;;; Commentary:
8
9 ;; Usage:
10
11 ;; (require 'hippie-expand-slime)
12 ;; (add-hook 'slime-mode-hook 'set-up-slime-hippie-expand)
13 ;; (add-hook 'slime-repl-mode-hook 'set-up-slime-hippie-expand))
14
15 ;;; Code:
16
17 (defun try-expand-slime-with-fn (old complete-fn)
18 "Completion function for `hippie-expand' which uses one of
19 slime's completion functions."
20 (if (not old)
21 (progn
22 (he-init-string (slime-symbol-start-pos) (slime-symbol-end-pos))
23 (if (not (equal he-search-string ""))
24 (setq he-expand-list
25 (sort (car (funcall complete-fn he-search-string))
26 'string-lessp))
27 (setq he-expand-list ()))))
28 (while (and he-expand-list
29 (he-string-member (car he-expand-list) he-tried-table))
30 (setq he-expand-list (cdr he-expand-list)))
31 (if (null he-expand-list)
32 (progn
33 (if old (he-reset-string))
34 ())
35 (progn
36 (he-substitute-string (car he-expand-list))
37 (setq he-tried-table (cons (car he-expand-list) (cdr he-tried-table)))
38 (setq he-expand-list (cdr he-expand-list))
39 t)))
40
41
42 ;;;###autoload
43 (defun try-expand-slime (old)
44 "Simple slime completion function for `hippie-expand'."
45 (try-expand-slime-with-fn old 'slime-simple-completions))
46
47 ;;;###autoload
48 (defun try-expand-slime-fuzzy (old)
49 "Fuzzy slime completion function for `hippie-expand'."
50 (try-expand-slime-with-fn old 'slime-fuzzy-completions))
51
52
53 ;;;###autoload
54 (defun set-up-slime-hippie-expand (&optional fuzzy)
55 "Add an optionally-fuzzy slime completion function to the front of
56 `hippie-expand-try-functions-list' for the current buffer."
57 (interactive)
58 (set (make-local-variable 'hippie-expand-try-functions-list) hippie-expand-try-functions-list)
59 (add-to-list 'hippie-expand-try-functions-list
60 (if fuzzy
61 'try-expand-slime-fuzzy
62 'try-expand-slime)))
63
64
65 (provide 'hippie-expand-slime)
66
67 ;;; hippie-expand-slime.el ends here
Something went wrong with that request. Please try again.