Permalink
Browse files

Check we're really on a symbol before completing

  • Loading branch information...
1 parent 958b042 commit f5cc4d0ae9d82bc51d992f3c53c0f7c21d0f67a9 @tsdh tsdh committed Aug 22, 2012
Showing with 11 additions and 10 deletions.
  1. +11 −10 nrepl.el
View
@@ -328,16 +328,17 @@ joined together.")
;; 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*)"
- (symbol-at-point)))
- ;; This might error, for example if point _ is in (_)
- (beginning-of-symbol (ignore-errors (save-excursion (backward-sexp) (point)))))
- (when (and beginning-of-symbol (not (in-string-p)))
- (let ((completions (car (read-from-string
- (plist-get (nrepl-send-string-sync form nrepl-buffer-ns)
- :value)))))
- (when completions
- (list beginning-of-symbol (point) completions))))))
+ (let ((sap (symbol-at-point)))
+ (when sap
+ (let ((form (format "(complete.core/completions \"%s\" *ns*)" sap))
+ ;; This might error, for example if point _ is in (_)
+ (beginning-of-symbol (ignore-errors (save-excursion (backward-sexp) (point)))))
+ (when (and beginning-of-symbol (not (in-string-p)))
+ (let ((completions (car (read-from-string
+ (plist-get (nrepl-send-string-sync form nrepl-buffer-ns)
+ :value)))))
+ (when completions
+ (list beginning-of-symbol (point) completions))))))))
(defun nrepl-eldoc-format-thing (thing)
(propertize thing 'face 'font-lock-function-name-face))

0 comments on commit f5cc4d0

Please sign in to comment.