branch: elpa/cider
commit 76ec8f119f91e0667fd1078956fa86a89dea08cc
Author: Bozhidar Batsov <[email protected]>
Commit: Bozhidar Batsov <[email protected]>
Route in-tree callers through the keyword request APIs
Migrate the remaining eval, info, eldoc, apropos and load-file call
sites off the positional shims and onto the new keyword forms. This
drops the nil-padding ("var nil nil ctx", "form nil line col params")
in favor of explicit :sym/:context/:line/... arguments, which makes the
call sites self-documenting.
---
lisp/cider-apropos.el | 12 ++++++++++--
lisp/cider-eldoc.el | 2 +-
lisp/cider-eval.el | 18 +++++++++---------
lisp/cider-mode.el | 2 +-
lisp/cider-repl.el | 21 ++++++++++-----------
lisp/cider-xref-backend.el | 6 +++++-
test/cider-interaction-tests.el | 4 ++--
7 files changed, 38 insertions(+), 27 deletions(-)
diff --git a/lisp/cider-apropos.el b/lisp/cider-apropos.el
index ed9a9310a2..9207946842 100644
--- a/lisp/cider-apropos.el
+++ b/lisp/cider-apropos.el
@@ -146,7 +146,11 @@ optionally search doc strings (based on DOCS-P), include
private vars
(cider-ensure-op-supported "cider/apropos")
(if-let* ((summary (cider-apropos-summary
query ns docs-p privates-p case-sensitive-p))
- (results (cider-sync-request:apropos query ns docs-p privates-p
case-sensitive-p)))
+ (results (cider-apropos-request query
+ :search-ns ns
+ :docs-p docs-p
+ :privates-p privates-p
+ :case-sensitive-p
case-sensitive-p)))
(cider-show-apropos summary results query docs-p)
(message "No apropos matches for %S" query)))
@@ -193,7 +197,11 @@ optionally search doc strings (based on DOCS-P), include
private vars
(if-let* ((summary (cider-apropos-summary
query ns docs-p privates-p case-sensitive-p))
(results (mapcar (lambda (r) (nrepl-dict-get r "name"))
- (cider-sync-request:apropos query ns docs-p
privates-p case-sensitive-p))))
+ (cider-apropos-request query
+ :search-ns ns
+ :docs-p docs-p
+ :privates-p privates-p
+ :case-sensitive-p
case-sensitive-p))))
(cider-apropos-act-on-symbol (completing-read (concat summary ": ")
results))
(message "No apropos matches for %S" query)))
diff --git a/lisp/cider-eldoc.el b/lisp/cider-eldoc.el
index 3d9daa6681..8b88f39ca6 100644
--- a/lisp/cider-eldoc.el
+++ b/lisp/cider-eldoc.el
@@ -420,7 +420,7 @@ This includes the arglist and ns and symbol name (if
available)."
;; generic case
(t (if (equal thing (car cider-eldoc-last-symbol))
(cadr cider-eldoc-last-symbol)
- (when-let* ((eldoc-info (cider-sync-request:eldoc thing nil nil
(cider-completion-get-context t))))
+ (when-let* ((eldoc-info (cider-eldoc-request :sym thing :context
(cider-completion-get-context t))))
(let* ((arglists (nrepl-dict-get eldoc-info "eldoc"))
(docstring (nrepl-dict-get eldoc-info "docstring"))
(type (nrepl-dict-get eldoc-info "type"))
diff --git a/lisp/cider-eval.el b/lisp/cider-eval.el
index 90a82e438a..9512f7df04 100644
--- a/lisp/cider-eval.el
+++ b/lisp/cider-eval.el
@@ -517,16 +517,16 @@ arguments and only proceed with evaluation if it returns
nil."
(cider-map-repls :auto
(lambda (connection)
(cider--prep-interactive-eval form connection)
- (cider-nrepl-request:eval
+ (cider-nrepl-send-eval-request
form
(or callback (cider-interactive-eval-handler nil bounds))
;; always eval ns forms in the user namespace
;; otherwise trying to eval ns form for the first time will produce
an error
- (if (cider-ns-form-p form) "user" (cider-current-ns))
- (when start (line-number-at-pos start))
- (when start (cider-column-number-at-pos start))
- additional-params
- connection))))))
+ :ns (if (cider-ns-form-p form) "user" (cider-current-ns))
+ :line (when start (line-number-at-pos start))
+ :column (when start (cider-column-number-at-pos start))
+ :additional-params additional-params
+ :connection connection))))))
(defun cider-eval-region (start end)
"Evaluate the region between START and END."
@@ -1101,12 +1101,12 @@ all ns aliases and var mappings from the namespace
before reloading it."
(lambda (repl)
(when ns-form
(cider-repl--cache-ns-form ns-form repl))
- (cider-request:load-file (cider--file-string filename)
+ (cider-load-file-request (cider--file-string filename)
(funcall
cider-to-nrepl-filename-function
(cider--server-filename
filename))
(file-name-nondirectory filename)
- repl
- callback)))
+ :connection repl
+ :callback callback)))
(message "Loading %s..." filename))))))
(defun cider-load-file (filename &optional undef-all)
diff --git a/lisp/cider-mode.el b/lisp/cider-mode.el
index 04357b9077..c341f8e54d 100644
--- a/lisp/cider-mode.el
+++ b/lisp/cider-mode.el
@@ -1060,7 +1060,7 @@ See \(info \"(elisp) Special Properties\")"
(let* ((locals (nrepl-dict-get
cider--debug-mode-response "locals"))
(local-val (cadr (assoc sym locals))))
(format " with value:\n%s" local-val))))
- (let* ((info (cider-sync-request:info sym nil nil
(cider-completion-get-context t)))
+ (let* ((info (cider-info-request :sym sym :context
(cider-completion-get-context t)))
(candidates (nrepl-dict-get info "candidates")))
(if candidates
(concat "There were ambiguities resolving this
symbol:\n\n"
diff --git a/lisp/cider-repl.el b/lisp/cider-repl.el
index 2c2be4edc4..41bb3b76dd 100644
--- a/lisp/cider-repl.el
+++ b/lisp/cider-repl.el
@@ -286,15 +286,14 @@ Run CALLBACK once the evaluation is complete."
(interactive)
(let* ((request `(,@(cider--repl-request-plist)
"inhibit-cider-middleware" "true")))
- (cider-nrepl-request:eval
+ (cider-nrepl-send-eval-request
;; Ensure we evaluate _something_ so the initial namespace is correctly
set
(thread-first (or cider-repl-init-code '("nil"))
(string-join "\n"))
(cider-repl-init-eval-handler callback)
- nil
- (line-number-at-pos (point))
- (cider-column-number-at-pos (point))
- request)))
+ :line (line-number-at-pos (point))
+ :column (cider-column-number-at-pos (point))
+ :additional-params request)))
(defun cider-repl-init (buffer &optional callback)
"Initialize the REPL in BUFFER.
@@ -1115,13 +1114,13 @@ If NEWLINE is true then add a newline at the end of the
input."
(goto-char (point-max))
(cider-repl--mark-input-start)
(cider-repl--mark-output-start)
- (cider-nrepl-request:eval
+ (cider-nrepl-send-eval-request
input
(cider-repl-handler (current-buffer))
- (cider-current-ns)
- (line-number-at-pos input-start)
- (cider-column-number-at-pos input-start)
- (cider--repl-request-plist))))))
+ :ns (cider-current-ns)
+ :line (line-number-at-pos input-start)
+ :column (cider-column-number-at-pos input-start)
+ :additional-params (cider--repl-request-plist))))))
(defun cider-repl-return (&optional end-of-input)
"Evaluate the current input string, or insert a newline.
@@ -1384,7 +1383,7 @@ regexes from `cider-locref-regexp-alist' to infer
locations at point."
;; 1) retrieve from info middleware
(when var
(or (cider-sync-request:ns-path var)
- (nrepl-dict-get (cider-sync-request:info var)
"file")))
+ (nrepl-dict-get (cider-info-request :sym var)
"file")))
(when-let* ((file (plist-get loc :file)))
;; 2) file detected by the regexp
(let ((file-from-regexp (if (file-name-absolute-p file)
diff --git a/lisp/cider-xref-backend.el b/lisp/cider-xref-backend.el
index 01e6481347..0f0350f07e 100644
--- a/lisp/cider-xref-backend.el
+++ b/lisp/cider-xref-backend.el
@@ -152,7 +152,11 @@ These are used for presentation purposes."
(cider-ensure-connected)
(cider-ensure-op-supported "cider/apropos")
(when-let* ((ns (cider-current-ns))
- (results (cider-sync-request:apropos pattern ns t t
completion-ignore-case)))
+ (results (cider-apropos-request pattern
+ :search-ns ns
+ :docs-p t
+ :privates-p t
+ :case-sensitive-p
completion-ignore-case)))
(mapcar (lambda (info)
(let* ((symbol (nrepl-dict-get info "name"))
(loc (cider--var-to-xref-location symbol))
diff --git a/test/cider-interaction-tests.el b/test/cider-interaction-tests.el
index 795aea89e3..268b45c1c5 100644
--- a/test/cider-interaction-tests.el
+++ b/test/cider-interaction-tests.el
@@ -89,7 +89,7 @@
(describe "cider-load-file"
(it "works as expected in empty Clojure buffers"
- (spy-on 'cider-request:load-file :and-return-value nil)
+ (spy-on 'cider-load-file-request :and-return-value nil)
(let ((default-directory "/tmp/a-dir"))
(with-repl-buffer "load-file-session" 'clj _b
(with-temp-buffer
@@ -99,7 +99,7 @@
(describe "cider-interactive-eval"
(it "works as expected in empty Clojure buffers"
- (spy-on 'cider-nrepl-request:eval :and-return-value nil)
+ (spy-on 'cider-nrepl-send-eval-request :and-return-value nil)
(let ((default-directory "/tmp/a-dir"))
(with-repl-buffer "interaction-session" 'clj _b
(with-temp-buffer