branch: elpa/cider
commit 184637971f861e3429ac7773c4b72a9b412ace32
Author: Bozhidar Batsov <[email protected]>
Commit: Bozhidar Batsov <[email protected]>

    Make cider-find-keyword's prefix arg invert cider-prompt-for-symbol
    
    The prefix arg was OR-ed with `cider-prompt-for-symbol', so when the option
    was enabled the prompt was unconditional and the prefix couldn't suppress 
it,
    contradicting the docstring.  Use `cider--prompt-for-symbol-p', like the
    sibling find commands.
---
 lisp/cider-find.el       |  2 +-
 test/cider-find-tests.el | 17 ++++++++++++++++-
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/lisp/cider-find.el b/lisp/cider-find.el
index 4d3ab03cc4..f052673fa4 100644
--- a/lisp/cider-find.el
+++ b/lisp/cider-find.el
@@ -272,7 +272,7 @@ thing at point."
   (interactive "P")
   (cider-ensure-session)
   (let* ((kw (let ((kw-at-point (cider-symbol-at-point 'look-back)))
-               (if (or cider-prompt-for-symbol arg)
+               (if (cider--prompt-for-symbol-p arg)
                    (read-string
                     (format "Keyword (default %s): " kw-at-point)
                     nil nil kw-at-point)
diff --git a/test/cider-find-tests.el b/test/cider-find-tests.el
index 095c9de6a3..90bbd7c9f5 100644
--- a/test/cider-find-tests.el
+++ b/test/cider-find-tests.el
@@ -77,7 +77,22 @@
     (spy-on 'cider-ensure-session :and-return-value t)
     (spy-on 'cider-symbol-at-point :and-return-value nil)
     (let ((cider-prompt-for-symbol nil))
-      (expect (cider-find-keyword nil) :to-throw 'user-error))))
+      (expect (cider-find-keyword nil) :to-throw 'user-error)))
+
+  ;; Regression: a prefix arg must invert `cider-prompt-for-symbol', not be
+  ;; OR-ed with it (which made the prompt unconditional when the option was t).
+  (it "inverts cider-prompt-for-symbol with a prefix arg"
+    (spy-on 'cider-ensure-session :and-return-value t)
+    (spy-on 'cider-symbol-at-point :and-return-value ":foo")
+    (spy-on 'read-string :and-return-value ":foo")
+    (spy-on 'cider--find-keyword-loc :and-return-value
+            (nrepl-dict "dest" (current-buffer) "dest-point" 1))
+    (spy-on 'cider-jump-to)
+    (let ((cider-prompt-for-symbol t))
+      (cider-find-keyword '(4))         ; prefix inverts t -> no prompt
+      (expect 'read-string :not :to-have-been-called)
+      (cider-find-keyword nil)          ; no prefix -> prompt
+      (expect 'read-string :to-have-been-called))))
 
 (describe "cider--find-keyword-loc"
   (it "finds the given keyword, discarding false positives"

Reply via email to