Skip to content

Commit

Permalink
Don't use list where backquoting would be clearer
Browse files Browse the repository at this point in the history
  • Loading branch information
Tianxiang Xiong authored and bbatsov committed Mar 1, 2017
1 parent 386a7c4 commit 5d32b96
Show file tree
Hide file tree
Showing 10 changed files with 122 additions and 120 deletions.
10 changes: 5 additions & 5 deletions cider-browse-ns.el
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,11 @@ Each item consists of a ns-var and the first line of its docstring."
Return a list of the type ('ns or 'var) and the value."
(let ((line (car (split-string (string-trim (thing-at-point 'line)) " "))))
(if (string-match "\\." line)
(list 'ns line)
(list 'var (format "%s/%s"
(or (get-text-property (point) 'cider-browse-ns-current-ns)
cider-browse-ns-current-ns)
line)))))
`(ns ,line)
`(var ,(format "%s/%s"
(or (get-text-property (point) 'cider-browse-ns-current-ns)
cider-browse-ns-current-ns)
line)))))

(defun cider-browse-ns-doc-at-point ()
"Show the documentation for the thing at current point."
Expand Down
64 changes: 32 additions & 32 deletions cider-client.el
Original file line number Diff line number Diff line change
Expand Up @@ -731,9 +731,9 @@ with respect to the bound values of \\=`*print-length*\\=`, \\=`*print-level*\\=
PPRINT-FN is the name of the Clojure function to use.
RIGHT-MARGIN specifies the maximum column-width of the pretty-printed
result, and is included in the request if non-nil."
(append (list "pprint" "true"
"pprint-fn" (or pprint-fn (cider--pprint-fn)))
(and right-margin (list "print-right-margin" right-margin))))
(nconc `("pprint" "true"
"pprint-fn" ,(or pprint-fn (cider--pprint-fn)))
(and right-margin `("print-right-margin" ,right-margin))))

(defun cider-tooling-eval (input callback &optional ns)
"Send the request INPUT and register the CALLBACK as the response handler.
Expand Down Expand Up @@ -851,10 +851,10 @@ loaded.
If CONNECTION is nil, use `cider-current-connection'.
If CALLBACK is nil, use `cider-load-file-handler'."
(cider-nrepl-send-request (list "op" "load-file"
"file" file-contents
"file-path" file-path
"file-name" file-name)
(cider-nrepl-send-request `("op" "load-file"
"file" ,file-contents
"file-path" ,file-path
"file-name" ,file-name)
(or callback
(cider-load-file-handler (current-buffer)))
connection))
Expand Down Expand Up @@ -897,27 +897,27 @@ Optional arguments include SEARCH-NS, DOCS-P, PRIVATES-P, CASE-SENSITIVE-P."
(defun cider-sync-request:classpath ()
"Return a list of classpath entries."
(cider-ensure-op-supported "classpath")
(thread-first (list "op" "classpath")
(thread-first '("op" "classpath")
(cider-nrepl-send-sync-request)
(nrepl-dict-get "classpath")))

(defun cider-sync-request:complete (str context)
"Return a list of completions for STR using nREPL's \"complete\" op.
CONTEXT represents a completion context for compliment."
(when-let ((dict (thread-first (list "op" "complete"
"ns" (cider-current-ns)
"symbol" str
"context" context)
(when-let ((dict (thread-first `("op" "complete"
"ns" ,(cider-current-ns)
"symbol" ,str
"context" ,context)
(cider-nrepl-send-sync-request nil 'abort-on-input))))
(nrepl-dict-get dict "completions")))

(defun cider-sync-request:info (symbol &optional class member)
"Send \"info\" op with parameters SYMBOL or CLASS and MEMBER."
(let ((var-info (thread-first `("op" "info"
"ns" ,(cider-current-ns)
,@(when symbol (list "symbol" symbol))
,@(when class (list "class" class))
,@(when member (list "member" member)))
,@(when symbol `("symbol" ,symbol))
,@(when class `("class" ,class))
,@(when member `("member" ,member)))
(cider-nrepl-send-sync-request))))
(if (member "no-info" (nrepl-dict-get var-info "status"))
nil
Expand All @@ -927,65 +927,65 @@ CONTEXT represents a completion context for compliment."
"Send \"eldoc\" op with parameters SYMBOL or CLASS and MEMBER."
(when-let ((eldoc (thread-first `("op" "eldoc"
"ns" ,(cider-current-ns)
,@(when symbol (list "symbol" symbol))
,@(when class (list "class" class))
,@(when member (list "member" member)))
,@(when symbol `("symbol" ,symbol))
,@(when class `("class" ,class))
,@(when member `("member" ,member)))
(cider-nrepl-send-sync-request nil 'abort-on-input))))
(if (member "no-eldoc" (nrepl-dict-get eldoc "status"))
nil
eldoc)))

(defun cider-sync-request:ns-list ()
"Get a list of the available namespaces."
(thread-first (list "op" "ns-list"
"filter-regexps" cider-filtered-namespaces-regexps)
(thread-first `("op" "ns-list"
"filter-regexps" ,cider-filtered-namespaces-regexps)
(cider-nrepl-send-sync-request)
(nrepl-dict-get "ns-list")))

(defun cider-sync-request:ns-vars (ns)
"Get a list of the vars in NS."
(thread-first (list "op" "ns-vars"
"ns" ns)
(thread-first `("op" "ns-vars"
"ns" ,ns)
(cider-nrepl-send-sync-request)
(nrepl-dict-get "ns-vars")))

(defun cider-sync-request:ns-vars-with-meta (ns)
"Get a map of the vars in NS to its metadata information."
(thread-first (list "op" "ns-vars-with-meta"
"ns" ns)
(thread-first `("op" "ns-vars-with-meta"
"ns" ,ns)
(cider-nrepl-send-sync-request)
(nrepl-dict-get "ns-vars-with-meta")))

(defun cider-sync-request:ns-load-all ()
"Load all project namespaces."
(thread-first (list "op" "ns-load-all")
(thread-first '("op" "ns-load-all")
(cider-nrepl-send-sync-request)
(nrepl-dict-get "loaded-ns")))

(defun cider-sync-request:resource (name)
"Perform nREPL \"resource\" op with resource name NAME."
(thread-first (list "op" "resource"
"name" name)
(thread-first `("op" "resource"
"name" ,name)
(cider-nrepl-send-sync-request)
(nrepl-dict-get "resource-path")))

(defun cider-sync-request:resources-list ()
"Return a list of all resources on the classpath."
(thread-first (list "op" "resources-list")
(thread-first '("op" "resources-list")
(cider-nrepl-send-sync-request)
(nrepl-dict-get "resources-list")))

(defun cider-sync-request:format-code (code)
"Perform nREPL \"format-code\" op with CODE."
(thread-first (list "op" "format-code"
"code" code)
(thread-first `("op" "format-code"
"code" ,code)
(cider-nrepl-send-sync-request)
(nrepl-dict-get "formatted-code")))

(defun cider-sync-request:format-edn (edn right-margin)
"Perform \"format-edn\" op with EDN and RIGHT-MARGIN."
(let* ((response (thread-first (list "op" "format-edn"
"edn" edn)
(let* ((response (thread-first `("op" "format-edn"
"edn" ,edn)
(append (cider--nrepl-pprint-request-plist right-margin))
(cider-nrepl-send-sync-request)))
(err (nrepl-dict-get response "err")))
Expand Down
2 changes: 1 addition & 1 deletion cider-compat.el
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ bound and (optionally) used in BODY, and its cadr is a sexp to be
evalled to set symbol's value. In the special case you only want
to bind a single value, BINDINGS can just be a plain tuple."
(declare (indent 1) (debug if-let))
(list 'if-let bindings (macroexp-progn body)))))
`(if-let ,bindings ,(macroexp-progn body)))))

(provide 'cider-compat)
;;; cider-compat.el ends here
17 changes: 9 additions & 8 deletions cider-debug.el
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ This variable must be set before starting the repl connection."
(defun cider-browse-instrumented-defs ()
"List all instrumented definitions."
(interactive)
(if-let ((all (thread-first (cider-nrepl-send-sync-request (list "op" "debug-instrumented-defs"))
(if-let ((all (thread-first (cider-nrepl-send-sync-request '("op" "debug-instrumented-defs"))
(nrepl-dict-get "list"))))
(with-current-buffer (cider-popup-buffer cider-browse-ns-buffer t)
(let ((inhibit-read-only t))
Expand Down Expand Up @@ -162,11 +162,11 @@ This variable must be set before starting the repl connection."
(defun cider--debug-init-connection ()
"Initialize a connection with the cider.debug middleware."
(cider-nrepl-send-request
(append '("op" "init-debugger")
(when cider-debug-print-level
(list "print-level" cider-debug-print-level))
(when cider-debug-print-length
(list "print-length" cider-debug-print-length)))
(nconc '("op" "init-debugger")
(when cider-debug-print-level
`("print-level" ,cider-debug-print-level))
(when cider-debug-print-length
`("print-length" ,cider-debug-print-length)))
#'cider--debug-response-handler))


Expand Down Expand Up @@ -417,8 +417,9 @@ message."
(when (and (string-prefix-p ":" command) force)
(setq command (format "{:response %s :force? true}" command)))
(cider-nrepl-send-unhandled-request
(list "op" "debug-input" "input" (or command ":quit")
"key" (or key (nrepl-dict-get cider--debug-mode-response "key"))))
`("op" "debug-input"
"input" ,(or command ":quit")
"key" ,(or key (nrepl-dict-get cider--debug-mode-response "key"))))
(ignore-errors (cider--debug-mode -1)))

(defun cider--debug-quit ()
Expand Down
12 changes: 6 additions & 6 deletions cider-eldoc.el
Original file line number Diff line number Diff line change
Expand Up @@ -313,9 +313,9 @@ Then go back to the point and return its eldoc."
(goto-char current-point)
(when-let (eldoc-info (cider-eldoc-info
(cider--eldoc-remove-dot (cider-symbol-at-point))))
(list "eldoc-info" eldoc-info
"thing" (cider-symbol-at-point)
"pos" 0)))))))
`("eldoc-info" ,eldoc-info
"thing" ,(cider-symbol-at-point)
"pos" 0)))))))

(defun cider-eldoc-info-at-sexp-beginning ()
"Return eldoc info for first symbol in the sexp."
Expand All @@ -328,9 +328,9 @@ Then go back to the point and return its eldoc."
(cider-in-comment-p))
(when-let (eldoc-info (cider-eldoc-info
(cider--eldoc-remove-dot (cider-symbol-at-point))))
(list "eldoc-info" eldoc-info
"thing" (cider-symbol-at-point)
"pos" argument-index))))))
`("eldoc-info" ,eldoc-info
"thing" ,(cider-symbol-at-point)
"pos" ,argument-index))))))

(defun cider-eldoc-info-in-current-sexp ()
"Return eldoc information from the sexp.
Expand Down
20 changes: 10 additions & 10 deletions cider-inspector.el
Original file line number Diff line number Diff line change
Expand Up @@ -192,48 +192,48 @@ Current page will be reset to zero."
;; nREPL interactions
(defun cider-sync-request:inspect-pop ()
"Move one level up in the inspector stack."
(thread-first (list "op" "inspect-pop")
(thread-first '("op" "inspect-pop")
(cider-nrepl-send-sync-request)
(nrepl-dict-get "value")))

(defun cider-sync-request:inspect-push (idx)
"Inspect the inside value specified by IDX."
(thread-first (list "op" "inspect-push"
"idx" idx)
(thread-first `("op" "inspect-push"
"idx" ,idx)
(cider-nrepl-send-sync-request)
(nrepl-dict-get "value")))

(defun cider-sync-request:inspect-refresh ()
"Re-render the currently inspected value."
(thread-first (list "op" "inspect-refresh")
(thread-first '("op" "inspect-refresh")
(cider-nrepl-send-sync-request)
(nrepl-dict-get "value")))

(defun cider-sync-request:inspect-next-page ()
"Jump to the next page in paginated collection view."
(thread-first (list "op" "inspect-next-page")
(thread-first '("op" "inspect-next-page")
(cider-nrepl-send-sync-request)
(nrepl-dict-get "value")))

(defun cider-sync-request:inspect-prev-page ()
"Jump to the previous page in paginated collection view."
(thread-first (list "op" "inspect-prev-page")
(thread-first '("op" "inspect-prev-page")
(cider-nrepl-send-sync-request)
(nrepl-dict-get "value")))

(defun cider-sync-request:inspect-set-page-size (page-size)
"Set the page size in paginated view to PAGE-SIZE."
(thread-first (list "op" "inspect-set-page-size"
"page-size" page-size)
(thread-first `("op" "inspect-set-page-size"
"page-size" ,page-size)
(cider-nrepl-send-sync-request)
(nrepl-dict-get "value")))

(defun cider-sync-request:inspect-expr (expr ns page-size)
"Evaluate EXPR in context of NS and inspect its result.
Set the page size in paginated view to PAGE-SIZE."
(thread-first (append (nrepl--eval-request expr ns)
(list "inspect" "true"
"page-size" page-size))
`("inspect" "true"
"page-size" ,page-size))
(cider-nrepl-send-sync-request)
(nrepl-dict-get "value")))

Expand Down
Loading

0 comments on commit 5d32b96

Please sign in to comment.