Skip to content

Commit

Permalink
Merge branch 'make-completion-configurable' of https://github.com/hug…
Browse files Browse the repository at this point in the history
…oduncan/nrepl.el into hugoduncan-make-completion-configurable
  • Loading branch information
kingtim committed Sep 5, 2012
2 parents 674a5a2 + a80008e commit a7a11ac
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions nrepl.el
Expand Up @@ -331,24 +331,28 @@ joined together.")


(defalias 'nrepl-jump-back 'pop-tag-mark) (defalias 'nrepl-jump-back 'pop-tag-mark)


(defvar nrepl-completion-fn 'nrepl-completion-complete-core-fn)

(defun nrepl-completion-complete-core-fn (str)
"Return a list of completions using complete.core/completions."
(nrepl-send-string "(clojure.core/require 'complete.core)" "user" 'identity)
(let ((strlst (plist-get
(nrepl-send-string-sync
(format "(complete.core/completions \"%s\" *ns*)" str)
nrepl-buffer-ns)
:value)))
(when strlst
(car (read-from-string strlst)))))

(defun nrepl-complete-at-point () (defun nrepl-complete-at-point ()
;; TODO: need a unified way to trigger this loading at connect-time ;; TODO: need a unified way to trigger this loading at connect-time
;; TODO: better error handling if dependency is missing ;; TODO: better error handling if dependency is missing
(message "complete-at-point %s" nrepl-completion-fn)
(let ((sap (symbol-at-point))) (let ((sap (symbol-at-point)))
(when (and sap (not (in-string-p))) (when (and sap (not (in-string-p)))
(let ((bounds (bounds-of-thing-at-point 'symbol))) (let ((bounds (bounds-of-thing-at-point 'symbol)))
(list (car bounds) (cdr bounds) (list (car bounds) (cdr bounds)
(completion-table-dynamic (completion-table-dynamic nrepl-completion-fn))))))
(lambda (str)
(nrepl-send-string "(clojure.core/require 'complete.core)"
"user" 'identity)
(let ((strlst (plist-get
(nrepl-send-string-sync
(format "(complete.core/completions \"%s\" *ns*)" str)
nrepl-buffer-ns)
:value)))
(when strlst
(car (read-from-string strlst)))))))))))


(defun nrepl-eldoc-format-thing (thing) (defun nrepl-eldoc-format-thing (thing)
(propertize thing 'face 'font-lock-function-name-face)) (propertize thing 'face 'font-lock-function-name-face))
Expand Down

0 comments on commit a7a11ac

Please sign in to comment.