Skip to content

Commit eccfcea

Browse files
authored
[Fix #3010] Address middleware error on invalid keywords (#3016)
To solve the problem we move `::` expansion logic to cider-browse-spec, where it is actually used.
1 parent 061a6db commit eccfcea

File tree

4 files changed

+11
-12
lines changed

4 files changed

+11
-12
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
* [#3014](https://github.com/clojure-emacs/cider/pull/3014): Update Krell repl initialization code to follow latest guidelines as found in Krell wiki.
88
* [#3012](https://github.com/clojure-emacs/cider/issues/3012): Allow connecting sibling repls from any buffer.
9-
9+
* [#3010](https://github.com/clojure-emacs/cider/issues/3010): Remove :: auto-resolved keyword expansion logic from cider-symbol-at-point, moving it to cider-browse-spec.
1010

1111
## 1.1.0 (2021-04-22)
1212

cider-browse-spec.el

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,10 @@ a more user friendly representation of SPEC-FORM."
277277
"Browse SPEC."
278278
(cider-ensure-connected)
279279
(cider-ensure-op-supported "spec-form")
280+
;; Expand auto-resolved keywords
281+
(when-let* ((val (and (string-match-p "^::.+" spec)
282+
(nrepl-dict-get (cider-sync-tooling-eval spec (cider-current-ns)) "value"))))
283+
(setq spec val))
280284
(with-current-buffer (cider-popup-buffer cider-browse-spec-buffer 'select #'cider-browse-spec-view-mode 'ancillary)
281285
(setq-local cider-browse-spec--current-spec spec)
282286
(cider-browse-spec--draw-spec-buffer (current-buffer)

cider-util.el

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@
4242
(require 'cider-compat)
4343
(require 'clojure-mode)
4444

45-
(declare-function cider-sync-request:macroexpand "cider-macroexpansion")
46-
4745
(defalias 'cider-pop-back 'pop-tag-mark)
4846

4947
(defcustom cider-font-lock-max-length 10000
@@ -127,11 +125,10 @@ instead."
127125
(defun cider-symbol-at-point (&optional look-back)
128126
"Return the name of the symbol at point, otherwise nil.
129127
Ignores the REPL prompt. If LOOK-BACK is non-nil, move backwards trying to
130-
find a symbol if there isn't one at point."
128+
find a symbol if there isn't one at point.
129+
Does not strip the : from keywords, nor attempt to expand :: auto-resolved
130+
keywords."
131131
(or (when-let* ((str (thing-at-point 'symbol)))
132-
;; resolve ns-aliased keywords
133-
(when (string-match-p "^::.+" str)
134-
(setq str (or (ignore-errors (cider-sync-request:macroexpand "macroexpand-1" str)) "")))
135132
(unless (text-property-any 0 (length str) 'field 'cider-repl-prompt str)
136133
;; remove font-locking
137134
(setq str (substring-no-properties str))

test/cider-util-tests.el

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,11 @@ buffer."
129129
(with-clojure-buffer ":abc/foo"
130130
(expect (cider-symbol-at-point) :to-equal ":abc/foo")))
131131

132-
(it "attempts to resolve namespaced keywords"
133-
(spy-on 'cider-sync-request:macroexpand :and-return-value ":foo.bar/abc")
132+
(it "does not attempt to resolve auto-resolved keywords"
134133
(with-clojure-buffer "(ns foo.bar) ::abc"
135-
(expect (cider-symbol-at-point) :to-equal ":foo.bar/abc"))
136-
(spy-on 'cider-sync-request:macroexpand :and-return-value ":clojure.string/abc")
134+
(expect (cider-symbol-at-point) :to-equal "::abc"))
137135
(with-clojure-buffer "(ns foo.bar (:require [clojure.string :as str])) ::str/abc"
138-
(expect (cider-symbol-at-point) :to-equal ":clojure.string/abc"))))
136+
(expect (cider-symbol-at-point) :to-equal "::str/abc"))))
139137

140138
(describe "when there's nothing at point"
141139
(it "returns nil"

0 commit comments

Comments
 (0)