[slime-devel] Slime contrib for completion via completion-ui
Madhu
enometh at meer.net
Sun May 3 07:13:06 UTC 2009
Here all it takes to use Dr.Cubitt's `completion-ui' package with SLIME.
Completion-UI is available at
<URL:http://www.dr-qubit.org/emacs.php#completion>
In the code shown below I'm using the contrib function
`slime-completions' from contrib/slime-c-p-c, which must be enabled.
You may prefer to replace
(slime-completions prefix) with
(slime-simple-completions prefix)
if you did not wish to use slime-c-p-c, [slime-c-p-c is broken in new
emacsen by default but it work OK via completion-ui as shown]
(completion-ui-register-source
(lambda (prefix &optional maxnum)
(let* ((completions-from-swank
(slime-completions prefix)) ; <---
(completions (car completions-from-swank)))
(if maxnum
(butlast
completions (- (length completions) maxnum))
completions)))
:prefix-function
(lambda ()
"Return prefix string at point for completion."
(let* ((end (point))
(beg (save-excursion
(backward-sexp 1)
(while (= (char-syntax (following-char)) ?\')
(forward-char 1))
(point))))
(buffer-substring-no-properties beg end)))
:name 'lisp-symbol-swank)
(defun default-slime-completion-ui-bindings ()
"Enable `complete-lisp-symbol-swank' which is registered via
completion-ui on the M-TAB and TAB keys in `slime-mode' and
`slime-repl-mode' respectively."
(define-key slime-mode-map "\C-[\C-i" 'complete-lisp-symbol-swank)
(define-key slime-repl-mode-map "\t" 'complete-lisp-symbol-swank))
(default-slime-completion-ui-bindings)
More information about the slime-devel
mailing list