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

    Add keyword-arg forms of the CIDER request APIs
    
    Mirror the nREPL-level change one layer up.  Add keyword-argument
    primaries cider-nrepl-send-eval-request, cider-nrepl-sync-request,
    cider-info-request, cider-eldoc-request, cider-apropos-request and
    cider-load-file-request, each replacing a long positional optional tail
    (the worst offenders were calls like "(cider-sync-request:info var nil
    nil ctx)").
    
    The legacy positional names (cider-nrepl-request:eval,
    cider-nrepl-send-sync-request, cider-sync-request:info, etc.) stay as
    delegating shims, so existing callers keep working unchanged.  Same-file
    callers are routed through the new forms.
---
 CHANGELOG.md               |   4 +
 lisp/cider-client.el       | 186 +++++++++++++++++++++++++++++++++------------
 test/cider-client-tests.el | 100 +++++++++++++++++++++++-
 3 files changed, 238 insertions(+), 52 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index f878f7e58d..02150356e7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -12,6 +12,10 @@
   - Keyword slots: `:on-value`, `:on-stdout`, `:on-stderr`, `:on-done`, 
`:on-eval-error`, `:on-content-type`, `:on-truncated`.
   - Sub-handlers no longer take a buffer argument; they close over whatever 
they need.
   - `nrepl-make-response-handler`, the legacy 7-positional-arg form, is 
preserved as an obsolete shim that adapts the old `(buffer x)` lambdas to the 
new `(x)` lambdas, so existing extensions keep working.
+- Keyword-argument forms for several low-level request APIs, so callers no 
longer pad arguments with `nil` to reach a later one.  In every case the legacy 
positional function is kept as a thin shim that delegates to the new one, so 
existing callers (including third-party packages) keep working unchanged:
+  - Eval requests: `nrepl-send-eval-request` (shim: `nrepl-request:eval`) and 
`cider-nrepl-send-eval-request` (shim: `cider-nrepl-request:eval`), with `:ns`, 
`:line`, `:column`, `:additional-params`, plus `:tooling` at the nREPL level 
and `:connection` at the CIDER level.
+  - Sync requests: `nrepl-sync-request` (shim: `nrepl-send-sync-request`) and 
`cider-nrepl-sync-request` (shim: `cider-nrepl-send-sync-request`), with 
`:abort-on-input`, `:tooling`/`:connection`, and `:callback`.
+  - Op helpers: `cider-info-request` (shim: `cider-sync-request:info`), 
`cider-eldoc-request` (shim: `cider-sync-request:eldoc`), 
`cider-apropos-request` (shim: `cider-sync-request:apropos`), and 
`cider-load-file-request` (shim: `cider-request:load-file`).
 - New `cider-repl-history-doctor` command: walks `cider-repl-input-history` 
looking for entries whose parens don't balance under Clojure syntax, shows each 
in a side buffer, and asks whether to delete it.  When done, rewrites 
`cider-repl-history-file` if one is configured.  Useful for cleaning up history 
after a typo got committed that breaks `cider-repl-history` rendering (see 
[#3915](https://github.com/clojure-emacs/cider/issues/3915)).
 - Recognize [let-go](https://github.com/nooga/let-go) (a Clojure dialect 
implemented in Go) as a known nREPL runtime.  `cider-runtime` returns `let-go` 
for these connections and the connection info line shows the runtime version, 
e.g. `CLJ project@localhost:2137 (let-go 1.0)`.
 - Decouple the nREPL transport layer from CIDER's UI layer (closes 
[#1099](https://github.com/clojure-emacs/cider/issues/1099)):
diff --git a/lisp/cider-client.el b/lisp/cider-client.el
index 9395245000..43e4545d38 100644
--- a/lisp/cider-client.el
+++ b/lisp/cider-client.el
@@ -258,21 +258,22 @@ If TOOLING is truthy then the tooling session is used."
     (nrepl-send-request (cider--resolve-op-in-request request conn)
                         callback conn tooling)))
 
-(defun cider-nrepl-send-sync-request (request &optional connection
-                                              abort-on-input callback)
+(cl-defun cider-nrepl-sync-request (request &key connection abort-on-input 
callback)
   "Send REQUEST to the nREPL server synchronously using CONNECTION.
 Hold till final \"done\" message has arrived and join all response messages
 of the same \"op\" that came along and return the accumulated response.
 If ABORT-ON-INPUT is non-nil, the function will return nil
 at the first sign of user input, so as not to hang the
 interface.
-if CALLBACK is non-nil, it will additionally be called on all received 
messages."
+if CALLBACK is non-nil, it will additionally be called on all received 
messages.
+
+This is the keyword-argument form; `cider-nrepl-send-sync-request' is the
+legacy positional shim retained for backward compatibility."
   (let* ((conn (or connection (cider-current-repl 'infer 'ensure)))
-         (response (nrepl-send-sync-request (cider--resolve-op-in-request 
request conn)
-                                            conn
-                                            abort-on-input
-                                            nil
-                                            callback)))
+         (response (nrepl-sync-request (cider--resolve-op-in-request request 
conn)
+                                       conn
+                                       :abort-on-input abort-on-input
+                                       :callback callback)))
     ;; Handle cider-nrepl middleware's pp-stacktrace in sync responses.
     (when response
       (nrepl-dbind-response response (ex err pp-stacktrace status)
@@ -281,6 +282,23 @@ if CALLBACK is non-nil, it will additionally be called on 
all received messages.
                                            (remove "done" status)))))
     response))
 
+(defun cider-nrepl-send-sync-request (request &optional connection
+                                              abort-on-input callback)
+  "Send REQUEST to the nREPL server synchronously using CONNECTION.
+Hold till final \"done\" message has arrived and join all response messages
+of the same \"op\" that came along and return the accumulated response.
+If ABORT-ON-INPUT is non-nil, the function will return nil
+at the first sign of user input, so as not to hang the
+interface.
+if CALLBACK is non-nil, it will additionally be called on all received 
messages.
+
+This positional form is kept for backward compatibility; new code should
+prefer the keyword-argument `cider-nrepl-sync-request'."
+  (cider-nrepl-sync-request request
+                           :connection connection
+                           :abort-on-input abort-on-input
+                           :callback callback))
+
 (defun cider-nrepl-send-unhandled-request (request &optional connection)
   "Send REQUEST to the nREPL CONNECTION and ignore any responses.
 Immediately mark the REQUEST as done.  Return the id of the sent message."
@@ -291,28 +309,47 @@ Immediately mark the REQUEST as done.  Return the id of 
the sent message."
       (nrepl--mark-id-completed id))
     id))
 
-(defun cider-nrepl-request:eval (input callback &optional ns line column 
additional-params connection)
+(cl-defun cider-nrepl-send-eval-request (input callback
+                                               &key ns line column 
additional-params connection)
   "Send the request INPUT and register the CALLBACK as the response handler.
 If NS is non-nil, include it in the request.  LINE and COLUMN, if non-nil,
 define the position of INPUT in its buffer.  ADDITIONAL-PARAMS is a plist
 to be appended to the request message.  CONNECTION is the connection
-buffer, defaults to (cider-current-repl)."
+buffer, defaults to (cider-current-repl).
+
+This is the keyword-argument form; `cider-nrepl-request:eval' is the legacy
+positional shim retained for backward compatibility."
   (let ((connection (or connection (cider-current-repl 'infer 'ensure)))
         (eval-buffer (current-buffer)))
     (run-hooks 'cider-before-eval-hook)
-    (nrepl-request:eval input
-                        (lambda (response)
-                          (when cider-show-spinner
-                            (cider-eval-spinner connection response))
-                          (when (and (buffer-live-p eval-buffer)
-                                     (member "done" (nrepl-dict-get response 
"status")))
-                            (with-current-buffer eval-buffer
-                              (run-hooks 'cider-after-eval-done-hook)))
-                          (funcall callback response))
-                        connection
-                        ns line column additional-params)
+    (nrepl-send-eval-request input
+                             (lambda (response)
+                               (when cider-show-spinner
+                                 (cider-eval-spinner connection response))
+                               (when (and (buffer-live-p eval-buffer)
+                                          (member "done" (nrepl-dict-get 
response "status")))
+                                 (with-current-buffer eval-buffer
+                                   (run-hooks 'cider-after-eval-done-hook)))
+                               (funcall callback response))
+                             connection
+                             :ns ns :line line :column column
+                             :additional-params additional-params)
     (cider-spinner-start connection)))
 
+(defun cider-nrepl-request:eval (input callback &optional ns line column 
additional-params connection)
+  "Send the request INPUT and register the CALLBACK as the response handler.
+If NS is non-nil, include it in the request.  LINE and COLUMN, if non-nil,
+define the position of INPUT in its buffer.  ADDITIONAL-PARAMS is a plist
+to be appended to the request message.  CONNECTION is the connection
+buffer, defaults to (cider-current-repl).
+
+This positional form is kept for backward compatibility; new code should
+prefer the keyword-argument `cider-nrepl-send-eval-request'."
+  (cider-nrepl-send-eval-request input callback
+                                 :ns ns :line line :column column
+                                 :additional-params additional-params
+                                 :connection connection))
+
 (defun cider-nrepl-sync-request:eval (input &optional connection ns)
   "Send the INPUT to the nREPL CONNECTION synchronously.
 If NS is non-nil, include it in the eval request."
@@ -498,10 +535,10 @@ evaluated in the tooling nREPL session don't affect the 
thread-local
 bindings of the primary eval nREPL session (e.g. this is not going to
 clobber *1/2/3)."
   ;; namespace forms are always evaluated in the "user" namespace
-  (nrepl-request:eval input
-                      callback
-                      (or connection (cider-current-repl 'infer 'ensure))
-                      ns nil nil nil 'tooling))
+  (nrepl-send-eval-request input
+                           callback
+                           (or connection (cider-current-repl 'infer 'ensure))
+                           :ns ns :tooling 'tooling))
 
 (defun cider-sync-tooling-eval (input &optional ns connection)
   "Send the request INPUT to CONNECTION and evaluate in synchronously.
@@ -601,24 +638,27 @@ When multiple matching vars are returned you'll be 
prompted to select one,
 unless ALL is truthy."
   (when (and var (not (string= var "")))
     (let ((var-info (cond
-                     ((cider-nrepl-op-supported-p "cider/info") 
(cider-sync-request:info var nil nil (cider-completion-get-context t)))
+                     ((cider-nrepl-op-supported-p "cider/info") 
(cider-info-request :sym var :context (cider-completion-get-context t)))
                      ((cider-nrepl-op-supported-p "lookup") 
(cider-sync-request:lookup var)))))
       (if all var-info (cider--var-choice var-info)))))
 
 (defun cider-member-info (class member)
   "Return info for MEMBER of CLASS as an nREPL dict."
   (when (and class member)
-    (cider-sync-request:info nil class member (cider-completion-get-context 
t))))
+    (cider-info-request :class class :member member :context 
(cider-completion-get-context t))))
 
 
 ;;; Requests
 
 (declare-function cider-load-file-handler "cider-eval")
-(defun cider-request:load-file (file-contents file-path file-name &optional 
connection callback)
+(cl-defun cider-load-file-request (file-contents file-path file-name &key 
connection callback)
   "Perform the nREPL \"load-file\" op.
 FILE-CONTENTS, FILE-PATH and FILE-NAME are details of the file to be
 loaded.  If CONNECTION is nil, use `cider-current-repl'.  If CALLBACK
-is nil, use `cider-load-file-handler'."
+is nil, use `cider-load-file-handler'.
+
+This is the keyword-argument form; `cider-request:load-file' is the legacy
+positional shim retained for backward compatibility."
   (cider-nrepl-send-request `("op" "load-file"
                               "file" ,file-contents
                               "file-path" ,file-path
@@ -627,6 +667,17 @@ is nil, use `cider-load-file-handler'."
                                 (cider-load-file-handler (current-buffer)))
                             connection))
 
+(defun cider-request:load-file (file-contents file-path file-name &optional 
connection callback)
+  "Perform the nREPL \"load-file\" op.
+FILE-CONTENTS, FILE-PATH and FILE-NAME are details of the file to be
+loaded.  If CONNECTION is nil, use `cider-current-repl'.  If CALLBACK
+is nil, use `cider-load-file-handler'.
+
+This positional form is kept for backward compatibility; new code should
+prefer the keyword-argument `cider-load-file-request'."
+  (cider-load-file-request file-contents file-path file-name
+                           :connection connection :callback callback))
+
 
 ;;; Sync Requests
 
@@ -644,12 +695,15 @@ Emacs Lisp."
   :group 'cider
   :package-version '(cider . "0.13.0"))
 
-(defun cider-sync-request:apropos (query &optional search-ns docs-p privates-p 
case-sensitive-p)
+(cl-defun cider-apropos-request (query &key search-ns docs-p privates-p 
case-sensitive-p)
   "Send \"apropos\" request for regexp QUERY.
 
-Optional arguments include SEARCH-NS, DOCS-P, PRIVATES-P, CASE-SENSITIVE-P."
+Optional arguments include SEARCH-NS, DOCS-P, PRIVATES-P, CASE-SENSITIVE-P.
+
+This is the keyword-argument form; `cider-sync-request:apropos' is the legacy
+positional shim retained for backward compatibility."
   (let* ((query (replace-regexp-in-string "[ \t]+" ".+" query))
-         (response (cider-nrepl-send-sync-request
+         (response (cider-nrepl-sync-request
                     `("op" "cider/apropos"
                       "ns" ,(cider-current-ns)
                       "query" ,query
@@ -662,6 +716,19 @@ Optional arguments include SEARCH-NS, DOCS-P, PRIVATES-P, 
CASE-SENSITIVE-P."
         (user-error "Invalid regexp: %s" (nrepl-dict-get response "error-msg"))
       (nrepl-dict-get response "apropos-matches"))))
 
+(defun cider-sync-request:apropos (query &optional search-ns docs-p privates-p 
case-sensitive-p)
+  "Send \"apropos\" request for regexp QUERY.
+
+Optional arguments include SEARCH-NS, DOCS-P, PRIVATES-P, CASE-SENSITIVE-P.
+
+This positional form is kept for backward compatibility; new code should
+prefer the keyword-argument `cider-apropos-request'."
+  (cider-apropos-request query
+                         :search-ns search-ns
+                         :docs-p docs-p
+                         :privates-p privates-p
+                         :case-sensitive-p case-sensitive-p))
+
 (defun cider-sync-request:classpath (&optional connection)
   "Return a list of classpath entries for CONNECTION."
   (cider-ensure-op-supported "cider/classpath" connection)
@@ -703,8 +770,8 @@ resolve those to absolute paths."
   (when-let* ((dict (thread-first `("op" "completions"
                                     "ns" ,(cider-current-ns)
                                     "prefix" ,prefix)
-                                  (cider-nrepl-send-sync-request 
(cider-current-repl)
-                                                                 
'abort-on-input))))
+                                  (cider-nrepl-sync-request :connection 
(cider-current-repl)
+                                                           :abort-on-input 
'abort-on-input))))
     (nrepl-dict-get dict "completions")))
 
 (defun cider-sync-request:complete (prefix context)
@@ -716,23 +783,25 @@ CONTEXT represents a completion context for compliment."
                                     "context" ,context
                                     "sort-order" "by-name"
                                     ,@(when cider-enhanced-cljs-completion-p 
'("enhanced-cljs-completion?" "t")))
-                                  (cider-nrepl-send-sync-request 
(cider-current-repl)
-                                                                 
'abort-on-input))))
+                                  (cider-nrepl-sync-request :connection 
(cider-current-repl)
+                                                           :abort-on-input 
'abort-on-input))))
     (nrepl-dict-get dict "completions")))
 
 (defun cider-sync-request:complete-flush-caches ()
   "Send \"complete-flush-caches\" op to flush Compliment's caches."
-  (cider-nrepl-send-sync-request (list "op" "cider/complete-flush-caches"
-                                       "session" (cider-nrepl-eval-session))
-                                 nil
-                                 'abort-on-input))
+  (cider-nrepl-sync-request (list "op" "cider/complete-flush-caches"
+                                 "session" (cider-nrepl-eval-session))
+                           :abort-on-input 'abort-on-input))
 
-(defun cider-sync-request:info (symbol &optional class member context)
-  "Send \"info\" op with parameters SYMBOL or CLASS and MEMBER, honor CONTEXT."
+(cl-defun cider-info-request (&key sym class member context)
+  "Send \"info\" op with parameters SYM or CLASS and MEMBER, honor CONTEXT.
+
+This is the keyword-argument form; `cider-sync-request:info' is the legacy
+positional shim retained for backward compatibility."
   (let* ((req
           `("op" "cider/info"
             "ns" ,(cider-current-ns)
-            ,@(when symbol `("sym" ,symbol))
+            ,@(when sym `("sym" ,sym))
             ,@(when class `("class" ,class))
             ,@(when member `("member" ,member))
             ,@(when context `("context" ,context))
@@ -747,11 +816,18 @@ CONTEXT represents a completion context for compliment."
                          (nrepl-dict-get coords "artifact")
                          (nrepl-dict-get coords "version"))))))
          (var-info
-          (cider-nrepl-send-sync-request req (cider-current-repl) nil 
callback)))
+          (cider-nrepl-sync-request req :connection (cider-current-repl) 
:callback callback)))
     (if (member "no-info" (nrepl-dict-get var-info "status"))
         nil
       var-info)))
 
+(defun cider-sync-request:info (symbol &optional class member context)
+  "Send \"info\" op with parameters SYMBOL or CLASS and MEMBER, honor CONTEXT.
+
+This positional form is kept for backward compatibility; new code should
+prefer the keyword-argument `cider-info-request'."
+  (cider-info-request :sym symbol :class class :member member :context 
context))
+
 (defun cider-sync-request:lookup (symbol &optional lookup-fn)
   "Send \"lookup\" op request with parameters SYMBOL and LOOKUP-FN."
   (let ((var-info (thread-first `("op" "lookup"
@@ -763,26 +839,36 @@ CONTEXT represents a completion context for compliment."
         nil
       (nrepl-dict-get var-info "info"))))
 
-(defun cider-sync-request:eldoc (symbol &optional class member context)
-  "Send \"eldoc\" op with parameters SYMBOL or CLASS and MEMBER, honor 
CONTEXT."
+(cl-defun cider-eldoc-request (&key sym class member context)
+  "Send \"eldoc\" op with parameters SYM or CLASS and MEMBER, honor CONTEXT.
+
+This is the keyword-argument form; `cider-sync-request:eldoc' is the legacy
+positional shim retained for backward compatibility."
   (when-let* ((eldoc (thread-first `("op" "cider/eldoc"
                                      "ns" ,(cider-current-ns)
-                                     ,@(when symbol `("sym" ,symbol))
+                                     ,@(when sym `("sym" ,sym))
                                      ,@(when class `("class" ,class))
                                      ,@(when member `("member" ,member))
                                      ,@(when context `("context" ,context)))
-                                   (cider-nrepl-send-sync-request 
(cider-current-repl)
-                                                                  
'abort-on-input))))
+                                   (cider-nrepl-sync-request :connection 
(cider-current-repl)
+                                                            :abort-on-input 
'abort-on-input))))
     (if (member "no-eldoc" (nrepl-dict-get eldoc "status"))
         nil
       eldoc)))
 
+(defun cider-sync-request:eldoc (symbol &optional class member context)
+  "Send \"eldoc\" op with parameters SYMBOL or CLASS and MEMBER, honor CONTEXT.
+
+This positional form is kept for backward compatibility; new code should
+prefer the keyword-argument `cider-eldoc-request'."
+  (cider-eldoc-request :sym symbol :class class :member member :context 
context))
+
 (defun cider-sync-request:eldoc-datomic-query (symbol)
   "Send \"eldoc-datomic-query\" op with parameter SYMBOL."
   (when-let* ((eldoc (thread-first `("op" "cider/eldoc-datomic-query"
                                      "ns" ,(cider-current-ns)
                                      ,@(when symbol `("sym" ,symbol)))
-                                   (cider-nrepl-send-sync-request nil 
'abort-on-input))))
+                                   (cider-nrepl-sync-request :abort-on-input 
'abort-on-input))))
     (if (member "no-eldoc" (nrepl-dict-get eldoc "status"))
         nil
       eldoc)))
diff --git a/test/cider-client-tests.el b/test/cider-client-tests.el
index ba04ab66e1..ea2975a5a3 100644
--- a/test/cider-client-tests.el
+++ b/test/cider-client-tests.el
@@ -43,7 +43,7 @@
     (expect (cider-var-info "") :to-be nil))
 
   (it "returns vars info as an nREPL dict"
-    (spy-on 'cider-sync-request:info :and-return-value
+    (spy-on 'cider-info-request :and-return-value
             '(dict
               "arglists" "([] [x] [x & ys])"
               "ns" "clojure.core"
@@ -81,7 +81,7 @@
 
 (describe "cider-member-info"
   (it "returns member info for a given class and member"
-    (spy-on 'cider-sync-request:info :and-return-value
+    (spy-on 'cider-info-request :and-return-value
             '(dict
               "class" "java.lang.String"
               "member" "length"
@@ -165,6 +165,102 @@
     (ignore-errors
       (kill-buffer "*nrepl-messages*"))))
 
+(describe "cider-nrepl-send-eval-request"
+  (it "delegates to nrepl-send-eval-request with the keyword args mapped 
through"
+    (let (captured)
+      (spy-on 'cider-spinner-start)
+      (spy-on 'nrepl-send-eval-request :and-call-fake
+              (lambda (input _callback connection &rest kwargs)
+                (setq captured (list input connection kwargs))))
+      (cider-nrepl-send-eval-request "(+ 1 1)" #'ignore
+                                     :ns "user" :line 1 :column 2
+                                     :additional-params '("a" "b")
+                                     :connection :fake-conn)
+      (cl-destructuring-bind (input connection kwargs) captured
+        (expect input :to-equal "(+ 1 1)")
+        (expect connection :to-be :fake-conn)
+        (expect (plist-get kwargs :ns) :to-equal "user")
+        (expect (plist-get kwargs :line) :to-equal 1)
+        (expect (plist-get kwargs :column) :to-equal 2)
+        (expect (plist-get kwargs :additional-params) :to-equal '("a" "b")))))
+
+  (it "the positional cider-nrepl-request:eval shim delegates identically"
+    (let (calls)
+      (spy-on 'cider-spinner-start)
+      (spy-on 'nrepl-send-eval-request :and-call-fake
+              (lambda (&rest args) (push args calls)))
+      (cider-nrepl-send-eval-request "(+ 1 1)" #'ignore
+                                     :ns "user" :line 1 :column 2
+                                     :additional-params '("a" "b")
+                                     :connection :fake-conn)
+      (cider-nrepl-request:eval "(+ 1 1)" #'ignore
+                                "user" 1 2 '("a" "b") :fake-conn)
+      (expect (length calls) :to-equal 2)
+      ;; the wrapped callback is a fresh closure each call, so compare
+      ;; everything except it: the input and the connection + keyword args
+      (expect (nth 0 (nth 0 calls)) :to-equal (nth 0 (nth 1 calls)))
+      (expect (nthcdr 2 (nth 0 calls)) :to-equal (nthcdr 2 (nth 1 calls))))))
+
+(describe "cider-nrepl-sync-request"
+  (it "the positional cider-nrepl-send-sync-request shim delegates with 
keywords"
+    (let (captured)
+      (spy-on 'cider-nrepl-sync-request :and-call-fake
+              (lambda (request &rest kwargs) (setq captured (list request 
kwargs))))
+      (cider-nrepl-send-sync-request '("op" "x") :fake-conn 'abort #'ignore)
+      (cl-destructuring-bind (request kwargs) captured
+        (expect request :to-equal '("op" "x"))
+        (expect (plist-get kwargs :connection) :to-be :fake-conn)
+        (expect (plist-get kwargs :abort-on-input) :to-be 'abort)
+        (expect (plist-get kwargs :callback) :to-be #'ignore)))))
+
+(describe "cider-sync-request:info"
+  (it "delegates to cider-info-request with positional args mapped to keywords"
+    (let (captured)
+      (spy-on 'cider-info-request :and-call-fake
+              (lambda (&rest kwargs) (setq captured kwargs)))
+      (cider-sync-request:info "sym" "cls" "mbr" "ctx")
+      (expect (plist-get captured :sym) :to-equal "sym")
+      (expect (plist-get captured :class) :to-equal "cls")
+      (expect (plist-get captured :member) :to-equal "mbr")
+      (expect (plist-get captured :context) :to-equal "ctx"))))
+
+(describe "cider-sync-request:eldoc"
+  (it "delegates to cider-eldoc-request with positional args mapped to 
keywords"
+    (let (captured)
+      (spy-on 'cider-eldoc-request :and-call-fake
+              (lambda (&rest kwargs) (setq captured kwargs)))
+      (cider-sync-request:eldoc "sym" "cls" "mbr" "ctx")
+      (expect (plist-get captured :sym) :to-equal "sym")
+      (expect (plist-get captured :class) :to-equal "cls")
+      (expect (plist-get captured :member) :to-equal "mbr")
+      (expect (plist-get captured :context) :to-equal "ctx"))))
+
+(describe "cider-sync-request:apropos"
+  (it "delegates to cider-apropos-request with positional args mapped to 
keywords"
+    (let (captured)
+      (spy-on 'cider-apropos-request :and-call-fake
+              (lambda (query &rest kwargs) (setq captured (list query 
kwargs))))
+      (cider-sync-request:apropos "qry" "ns" t t t)
+      (cl-destructuring-bind (query kwargs) captured
+        (expect query :to-equal "qry")
+        (expect (plist-get kwargs :search-ns) :to-equal "ns")
+        (expect (plist-get kwargs :docs-p) :to-be t)
+        (expect (plist-get kwargs :privates-p) :to-be t)
+        (expect (plist-get kwargs :case-sensitive-p) :to-be t)))))
+
+(describe "cider-request:load-file"
+  (it "delegates to cider-load-file-request with positional args mapped to 
keywords"
+    (let (captured)
+      (spy-on 'cider-load-file-request :and-call-fake
+              (lambda (fc fp fn &rest kwargs) (setq captured (list fc fp fn 
kwargs))))
+      (cider-request:load-file "contents" "/path" "name" :fake-conn #'ignore)
+      (cl-destructuring-bind (fc fp fn kwargs) captured
+        (expect fc :to-equal "contents")
+        (expect fp :to-equal "/path")
+        (expect fn :to-equal "name")
+        (expect (plist-get kwargs :connection) :to-be :fake-conn)
+        (expect (plist-get kwargs :callback) :to-be #'ignore)))))
+
 (describe "cider-ensure-op-supported"
   (it "returns nil when the op is supported"
     (spy-on 'cider-nrepl-op-supported-p :and-return-value t)

Reply via email to