Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Completion #25

wants to merge 3 commits into from

2 participants


The existing implementation on master doesn't insert the least common substring if there are multiple matches.

@kingtim kingtim referenced this pull request from a commit
@kingtim kingtim merge pull request #25: completion f3a66f2

I did some refactoring and and fixed a bug. When you attempt to complete a full completion (i.e. defmacro<TAB>), try-completion returns t instead of a string. That case is handled now.

Let me know if it isn't working for you on master.

Thanks, @technomancy.

@kingtim kingtim closed this
@technomancy technomancy referenced this pull request

Implement completion #5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 21, 2012
  1. @technomancy
  2. @technomancy
Commits on Jul 24, 2012
  1. @technomancy

    Stop using `nrepl-current-ns` when invoking `nrepl-send-string`.

    technomancy authored
    I was using this because `nrepl-buffer-ns` was always set to "user",
    but that's a bug that should be addressed separately.
This page is out of date. Refresh to see the latest.
Showing with 19 additions and 10 deletions.
  1. +19 −10 nrepl.el
29 nrepl.el
@@ -312,7 +312,7 @@ Empty strings and duplicates are ignored."
(comp str :file) :line)
(meta (resolve '%s)))"
- (nrepl-send-string form (nrepl-current-ns)
+ (nrepl-send-string form nrepl-buffer-ns
(nrepl-jump-to-def-handler (current-buffer)))))
(defun nrepl-jump-back ()
@@ -328,19 +328,27 @@ Empty strings and duplicates are ignored."
(defun nrepl-complete-handler (beginning-of-symbol response)
(nrepl-dbind-response response (value ns out err status id)
(when value
- (let ((completions (car (read-from-string value))))
- (cond ((> (length completions) 1)
- (message "Completions: %s" (mapconcat 'identity completions " ")))
- ((= (length completions) 1)
- (save-excursion
- (delete-region beginning-of-symbol (point)))
- (insert (car completions) " ")))))))
+ (setq vvv value)
+ (let* ((completions (car (read-from-string value)))
+ (current (buffer-substring beginning-of-symbol (point))))
+ (if (not completions)
+ (t (message "No match."))
+ (save-excursion
+ (delete-region beginning-of-symbol (point)))
+ (insert (try-completion current completions))
+ (if (= (length completions) 1)
+ (insert " ")
+ (message "Completions: %s"
+ (mapconcat 'identity completions " "))))))))
(defun nrepl-complete ()
+ ;; TODO: need a unified way to trigger this loading at connect-time
+ ;; TODO: better error handling if dependency is missing
+ (nrepl-send-string "(require 'complete.core)" "user" 'identity)
(let ((form (format "(complete.core/completions \"%s\" *ns*)"
- (nrepl-send-string form (nrepl-current-ns)
+ (nrepl-send-string form nrepl-buffer-ns
(apply-partially 'nrepl-complete-handler
@@ -1133,7 +1141,8 @@ the buffer should appear."
(interactive (list (nrepl-read-symbol-name "Symbol: ")))
(let ((form (format "(clojure.repl/doc %s)" symbol))
(doc-buffer (nrepl-popup-buffer "*nREPL doc*" t)))
- (nrepl-send-string form (nrepl-current-ns) (nrepl-popup-eval-out-handler doc-buffer))))
+ (nrepl-send-string form nrepl-buffer-ns
+ (nrepl-popup-eval-out-handler doc-buffer))))
;; TODO: implement reloading ns
(defun nrepl-load-file (filename)
Something went wrong with that request. Please try again.