Skip to content

Clean symbol before doing look up #887

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion cider-interaction.el
Original file line number Diff line number Diff line change
Expand Up @@ -492,13 +492,22 @@ When invoked with a prefix ARG the command doesn't prompt for confirmation."
(bounds-of-thing-at-point 'sexp)))
(bounds-of-thing-at-point 'sexp)))

(defun cider--clean-symbol (symbol)
"Return SYMBOL cleaned so a dictionary match can be found."
(if (string-equal symbol "")
symbol
(let* ((symbol (if (string-equal (substring symbol 0 1) "@")
(substring symbol 1)
symbol)))
symbol)))

;; FIXME: This doesn't have properly at the beginning of the REPL prompt
(defun cider-symbol-at-point ()
"Return the name of the symbol at point, otherwise nil."
(let ((str (substring-no-properties (or (thing-at-point 'symbol) ""))))
(if (equal str (concat (cider-current-ns) "> "))
""
str)))
(cider--clean-symbol str))))

(defun cider-sexp-at-point ()
"Return the sexp at point as a string, otherwise nil."
Expand Down
4 changes: 4 additions & 0 deletions test/cider-tests.el
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,10 @@
(cider-current-ns () "user"))
(should (string= (cider-symbol-at-point) ""))))

(ert-deftest cider-symbol-at-point-deref ()
(noflet ((thing-at-point (thing) "@user"))
(should (string= (cider-symbol-at-point) "user"))))

(ert-deftest test-cider--url-to-file ()
(should (equal "/space test" (cider--url-to-file "file:/space%20test")))
(should (equal "C:/space test" (cider--url-to-file "file:/C:/space%20test"))))
Expand Down