summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md1
-rw-r--r--cider-apropos.el9
-rw-r--r--cider-browse-ns.el15
-rw-r--r--cider-classpath.el3
-rw-r--r--cider-client.el171
-rw-r--r--cider-common.el18
-rw-r--r--cider-compat.el160
-rw-r--r--cider-debug.el24
-rw-r--r--cider-doc.el12
-rw-r--r--cider-eldoc.el9
-rw-r--r--cider-grimoire.el17
-rw-r--r--cider-interaction.el81
-rw-r--r--cider-macroexpansion.el23
-rwxr-xr-x[-rw-r--r--]cider-mode.el31
-rw-r--r--cider-overlays.el7
-rw-r--r--cider-popup.el6
-rw-r--r--cider-repl.el3
-rw-r--r--cider-resolve.el13
-rw-r--r--cider-stacktrace.el20
-rw-r--r--cider-test.el31
-rw-r--r--cider-util.el16
-rw-r--r--cider.el59
-rw-r--r--nrepl-client.el38
-rw-r--r--test/cider-tests--no-auto.el4
24 files changed, 485 insertions, 286 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 63029ba0..cbed96ce 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -41,6 +41,7 @@
### Changes
+* [#1348](https://github.com/clojure-emacs/cider/issues/1348): Drop the dash dependency.
* The usage of the default connection has been reduced significantly. Now evaluations & related commands will be routed via the connection matching the current project automatically unless there's some ambiguity when determining the connection (like multiple or no matching connections). Simply put you'll no longer have to mess around much with connecting-setting commands (e.g. `nrepl-connection-browser`, `cider-rotate-default-connection`).
* [#732](https://github.com/clojure-emacs/cider/issues/732): `cider-quit` and `cider-restart` now operate on the current connection only. With a prefix argument they operate on all connections.
* `nrepl-log-messages` is now set to `t` by default.
diff --git a/cider-apropos.el b/cider-apropos.el
index 66e21355..1d39c643 100644
--- a/cider-apropos.el
+++ b/cider-apropos.el
@@ -27,12 +27,13 @@
(require 'cider-doc)
(require 'cider-util)
+(require 'cider-compat)
+
(require 'cider-client)
(require 'cider-popup)
(require 'nrepl-client)
(require 'clojure-mode)
-(require 'dash)
(require 'apropos)
(require 'button)
@@ -115,9 +116,9 @@ strings, include private vars, and be case sensitive."
(y-or-n-p "Case-sensitive? "))
(list (read-string "Clojure Apropos: "))))
(cider-ensure-op-supported "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)))
+ (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)))
(cider-show-apropos summary results query docs-p)
(message "No apropos matches for %S" query)))
diff --git a/cider-browse-ns.el b/cider-browse-ns.el
index 8b2547d8..3e80ad92 100644
--- a/cider-browse-ns.el
+++ b/cider-browse-ns.el
@@ -35,6 +35,7 @@
(require 'cider-repl)
(require 'cider-client)
+(require 'cider-compat)
(defconst cider-browse-ns-buffer "*Browse NS*")
(defvar-local cider-browse-ns-current-ns nil)
@@ -100,11 +101,11 @@ contents of the buffer are not reset before inserting TITLE and ITEMS."
(with-current-buffer (cider-popup-buffer cider-browse-ns-buffer t)
(let ((vars (cider-sync-request:ns-vars namespace)))
(cider-browse-ns--list (current-buffer)
- namespace
- (mapcar (lambda (var)
- (format "%s"
- (cider-browse-ns--properties var)))
- vars))
+ namespace
+ (mapcar (lambda (var)
+ (format "%s"
+ (cider-browse-ns--properties var)))
+ vars))
(setq-local cider-browse-ns-current-ns namespace))))
;;;###autoload
@@ -131,12 +132,12 @@ contents of the buffer are not reset before inserting TITLE and ITEMS."
(defun cider-browse-ns--doc-at-point ()
"Expand browser according to thing at current point."
(interactive)
- (-when-let (var (cider-browse-ns--var-at-point))
+ (when-let (var (cider-browse-ns--var-at-point))
(cider-doc-lookup var)))
(defun cider-browse-ns--find-at-point ()
(interactive)
- (-when-let (var (cider-browse-ns--var-at-point))
+ (when-let (var (cider-browse-ns--var-at-point))
(cider-find-var current-prefix-arg var)))
(defun cider-browse-ns--handle-mouse (event)
diff --git a/cider-classpath.el b/cider-classpath.el
index 3bc87f32..a435a30c 100644
--- a/cider-classpath.el
+++ b/cider-classpath.el
@@ -25,6 +25,7 @@
(require 'cider-client)
(require 'cider-popup)
+(require 'cider-compat)
(defvar cider-classpath-buffer "*Classpath*")
@@ -98,7 +99,7 @@
(defun cider-open-classpath-entry ()
"Open a classpath entry."
(interactive)
- (-when-let (entry (completing-read "Classpath entries: " (cider-sync-request:classpath)))
+ (when-let (entry (completing-read "Classpath entries: " (cider-sync-request:classpath)))
(find-file-other-window entry)))
(provide 'cider-classpath)
diff --git a/cider-client.el b/cider-client.el
index 48d93c25..fc193d77 100644
--- a/cider-client.el
+++ b/cider-client.el
@@ -29,6 +29,9 @@
(require 'nrepl-client)
(require 'cider-common)
+(require 'cider-compat)
+(require 'seq)
+
;;; Connection Buffer Management
(defvar cider-connections nil
@@ -64,14 +67,14 @@ found."
"Return the list of connection buffers.
If the list is empty and buffer-local, return the global value."
(or (setq cider-connections
- (-filter #'buffer-live-p cider-connections))
+ (seq-filter #'buffer-live-p cider-connections))
(when (local-variable-p 'cider-connect)
(kill-local-variable 'cider-connections)
- (-filter #'buffer-live-p cider-connections))))
+ (seq-filter #'buffer-live-p cider-connections))))
(defun cider-repl-buffers ()
"Return the list of REPL buffers."
- (-filter
+ (seq-filter
(lambda (buffer)
(with-current-buffer buffer (derived-mode-p 'cider-repl-mode)))
(buffer-list)))
@@ -124,10 +127,10 @@ precedence over other connections associated with the same project.
If ALL-CONNECTIONS is non-nil, the return value is a list and all matching
connections are returned, instead of just the most recent."
- (let ((fn (if all-connections #'-filter #'-first)))
+ (let ((fn (if all-connections #'seq-filter #'seq-find)))
(or (funcall fn (lambda (conn)
- (-when-let (conn-proj-dir (with-current-buffer conn
- nrepl-project-dir))
+ (when-let (conn-proj-dir (with-current-buffer conn
+ nrepl-project-dir))
(equal (file-truename project-directory)
(file-truename conn-proj-dir))))
cider-connections)
@@ -193,11 +196,11 @@ file extension."
(car repls)
;; OW, find one matching the extension of current file.
(let ((type (or type (file-name-extension (or (buffer-file-name) "")))))
- (or (-first (lambda (conn)
- (equal (with-current-buffer conn
- (or cider-repl-type "clj"))
- type))
- (append repls cider-connections))
+ (or (seq-find (lambda (conn)
+ (equal (with-current-buffer conn
+ (or cider-repl-type "clj"))
+ type))
+ (append repls cider-connections))
(car repls)
(car cider-connections))))))))
@@ -215,7 +218,7 @@ file extension."
(declare-function cider-popup-buffer-mode "cider-popup")
(define-derived-mode cider-connections-buffer-mode cider-popup-buffer-mode
- "CIDER Connections"
+ "CIDER Connections"
"CIDER Connections Buffer Mode.
\\{cider-connections-buffer-mode-map}
\\{cider-popup-buffer-mode-map}"
@@ -227,7 +230,7 @@ file extension."
(defun cider-connection-browser ()
"Open a browser buffer for nREPL connections."
(interactive)
- (-if-let (buffer (get-buffer cider--connection-browser-buffer-name))
+ (if-let (buffer (get-buffer cider--connection-browser-buffer-name))
(progn
(cider--connections-refresh-buffer buffer)
(unless (get-buffer-window buffer)
@@ -240,7 +243,7 @@ file extension."
"Refresh the connections buffer, if the buffer exists.
The connections buffer is determined by
`cider--connection-browser-buffer-name'"
- (-when-let (buffer (get-buffer cider--connection-browser-buffer-name))
+ (when-let (buffer (get-buffer cider--connection-browser-buffer-name))
(cider--connections-refresh-buffer buffer)))
(add-hook 'nrepl-disconnected-hook #'cider--connections-refresh)
@@ -287,7 +290,7 @@ The connections buffer is determined by
(ewoc-filter ewoc (lambda (n) (member n connections)))
(let ((existing))
(ewoc-map (lambda (n) (setq existing (cons n existing))) ewoc)
- (let ((added (-difference connections existing)))
+ (let ((added (seq-difference connections existing)))
(mapc (apply-partially 'ewoc-enter-last ewoc) added)
(save-excursion (ewoc-refresh ewoc)))))
@@ -362,7 +365,7 @@ The ns is extracted from the ns form for Clojure buffers and from
REPL's ns, otherwise fall back to \"user\"."
(or cider-buffer-ns
(clojure-find-ns)
- (-when-let (repl-buf (cider-current-connection))
+ (when-let (repl-buf (cider-current-connection))
(buffer-local-value 'cider-buffer-ns repl-buf))
"user"))
@@ -516,7 +519,7 @@ unless ALL is truthy."
"Find the definition of VAR, optionally at a specific LINE.
Display the results in a different window."
- (-if-let (info (cider-var-info var))
+ (if-let (info (cider-var-info var))
(progn
(if line (setq info (nrepl-dict-put info "line" line)))
(cider--jump-to-loc-from-info info t))
@@ -524,7 +527,7 @@ Display the results in a different window."
(defun cider--find-var (var &optional line)
"Find the definition of VAR, optionally at a specific LINE."
- (-if-let (info (cider-var-info var))
+ (if-let (info (cider-var-info var))
(progn
(if line (setq info (nrepl-dict-put info "line" line)))
(cider--jump-to-loc-from-info info))
@@ -568,101 +571,101 @@ loaded. If CALLBACK is nil, use `cider-load-file-handler'."
;;; Sync Requests
(defun cider-sync-request:apropos (query &optional search-ns docs-p privates-p case-sensitive-p)
"Send \"apropos\" op with args SEARCH-NS, DOCS-P, PRIVATES-P, CASE-SENSITIVE-P."
- (-> `("op" "apropos"
- "ns" ,(cider-current-ns)
- "query" ,query
- ,@(when search-ns `("search-ns" ,search-ns))
- ,@(when docs-p '("docs?" "t"))
- ,@(when privates-p '("privates?" "t"))
- ,@(when case-sensitive-p '("case-sensitive?" "t")))
- (cider-nrepl-send-sync-request)
- (nrepl-dict-get "apropos-matches")))
+ (thread-first `("op" "apropos"
+ "ns" ,(cider-current-ns)
+ "query" ,query
+ ,@(when search-ns `("search-ns" ,search-ns))
+ ,@(when docs-p '("docs?" "t"))
+ ,@(when privates-p '("privates?" "t"))
+ ,@(when case-sensitive-p '("case-sensitive?" "t")))
+ (cider-nrepl-send-sync-request)
+ (nrepl-dict-get "apropos-matches")))
(defun cider-sync-request:classpath ()
"Return a list of classpath entries."
(cider-ensure-op-supported "classpath")
- (-> (list "op" "classpath"
- "session" (cider-current-session))
- (cider-nrepl-send-sync-request)
- (nrepl-dict-get "classpath")))
+ (thread-first (list "op" "classpath"
+ "session" (cider-current-session))
+ (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."
- (-when-let (dict (-> (list "op" "complete"
- "session" (cider-current-session)
- "ns" (cider-current-ns)
- "symbol" str
- "context" context)
- (cider-nrepl-send-sync-request 'abort-on-input)))
+ (when-let (dict (thread-first (list "op" "complete"
+ "session" (cider-current-session)
+ "ns" (cider-current-ns)
+ "symbol" str
+ "context" context)
+ (cider-nrepl-send-sync-request '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 (-> `("op" "info"
- "session" ,(cider-current-session)
- "ns" ,(cider-current-ns)
- ,@(when symbol (list "symbol" symbol))
- ,@(when class (list "class" class))
- ,@(when member (list "member" member)))
- (cider-nrepl-send-sync-request))))
+ (let ((var-info (thread-first `("op" "info"
+ "session" ,(cider-current-session)
+ "ns" ,(cider-current-ns)
+ ,@(when symbol (list "symbol" symbol))
+ ,@(when class (list "class" class))
+ ,@(when member (list "member" member)))
+ (cider-nrepl-send-sync-request))))
(if (member "no-info" (nrepl-dict-get var-info "status"))
nil
var-info)))
(defun cider-sync-request:eldoc (symbol &optional class member)
"Send \"eldoc\" op with parameters SYMBOL or CLASS and MEMBER."
- (-when-let (eldoc (-> `("op" "eldoc"
- "session" ,(cider-current-session)
- "ns" ,(cider-current-ns)
- ,@(when symbol (list "symbol" symbol))
- ,@(when class (list "class" class))
- ,@(when member (list "member" member)))
- (cider-nrepl-send-sync-request 'abort-on-input)))
+ (when-let (eldoc (thread-first `("op" "eldoc"
+ "session" ,(cider-current-session)
+ "ns" ,(cider-current-ns)
+ ,@(when symbol (list "symbol" symbol))
+ ,@(when class (list "class" class))
+ ,@(when member (list "member" member)))
+ (cider-nrepl-send-sync-request '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."
- (-> (list "op" "ns-list"
- "session" (cider-current-session))
- (cider-nrepl-send-sync-request)
- (nrepl-dict-get "ns-list")))
+ (thread-first (list "op" "ns-list"
+ "session" (cider-current-session))
+ (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."
- (-> (list "op" "ns-vars"
- "session" (cider-current-session)
- "ns" ns)
- (cider-nrepl-send-sync-request)
- (nrepl-dict-get "ns-vars")))
+ (thread-first (list "op" "ns-vars"
+ "session" (cider-current-session)
+ "ns" ns)
+ (cider-nrepl-send-sync-request)
+ (nrepl-dict-get "ns-vars")))
(defun cider-sync-request:resource (name)
"Perform nREPL \"resource\" op with resource name NAME."
- (-> (list "op" "resource"
- "name" name)
- (cider-nrepl-send-sync-request)
- (nrepl-dict-get "resource-path")))
+ (thread-first (list "op" "resource"
+ "name" name)
+ (cider-nrepl-send-sync-request)
+ (nrepl-dict-get "resource-path")))
(defun cider-sync-request:resources-list ()
"Perform nREPL \"resource\" op with resource name NAME."
- (-> (list "op" "resources-list")
- (cider-nrepl-send-sync-request)
- (nrepl-dict-get "resources-list")))
+ (thread-first (list "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."
- (-> (list "op" "format-code"
- "code" code)
- (cider-nrepl-send-sync-request)
- (nrepl-dict-get "formatted-code")))
+ (thread-first (list "op" "format-code"
+ "code" code)
+ (cider-nrepl-send-sync-request)
+ (nrepl-dict-get "formatted-code")))
(defun cider-sync-request:format-edn (edn &optional right-margin)
"Perform \"format-edn\" op with EDN and RIGHT-MARGIN."
- (let* ((response (-> (list "op" "format-edn"
- "edn" edn)
- (append (and right-margin (list "right-margin" right-margin)))
- (cider-nrepl-send-sync-request)))
+ (let* ((response (thread-first (list "op" "format-edn"
+ "edn" edn)
+ (append (and right-margin (list "right-margin" right-margin)))
+ (cider-nrepl-send-sync-request)))
(err (nrepl-dict-get response "err")))
(when err
;; err will be a stacktrace with a first line that looks like:
@@ -722,25 +725,25 @@ EVAL-BUFFER is the buffer where the spinner was started."
"Retrieve the underlying connection's Java version."
(with-current-buffer (cider-current-connection "clj")
(when nrepl-versions
- (-> nrepl-versions
- (nrepl-dict-get "java")
- (nrepl-dict-get "version-string")))))
+ (thread-first nrepl-versions
+ (nrepl-dict-get "java")
+ (nrepl-dict-get "version-string")))))
(defun cider--clojure-version ()
"Retrieve the underlying connection's Clojure version."
(with-current-buffer (cider-current-connection "clj")
(when nrepl-versions
- (-> nrepl-versions
- (nrepl-dict-get "clojure")
- (nrepl-dict-get "version-string")))))
+ (thread-first nrepl-versions
+ (nrepl-dict-get "clojure")
+ (nrepl-dict-get "version-string")))))
(defun cider--nrepl-version ()
"Retrieve the underlying connection's nREPL version."
(with-current-buffer (cider-current-connection "clj")
(when nrepl-versions
- (-> nrepl-versions
- (nrepl-dict-get "nrepl")
- (nrepl-dict-get "version-string")))))
+ (thread-first nrepl-versions
+ (nrepl-dict-get "nrepl")
+ (nrepl-dict-get "version-string")))))
(defun cider--connection-info (connection-buffer)
"Return info about CONNECTION-BUFFER.
diff --git a/cider-common.el b/cider-common.el
index dd89fa8b..c09af577 100644
--- a/cider-common.el
+++ b/cider-common.el
@@ -24,9 +24,9 @@
;;; Code:
-(require 'dash)
-(require 'cider-util)
+(require 'cider-compat)
(require 'nrepl-client)
+(require 'cider-util)
(defcustom cider-prompt-for-symbol t
"Controls when to prompt for symbol when a command requires one.
@@ -168,14 +168,14 @@ relative, it is expanded within each of the open Clojure buffers till an
existing file ending with URL has been found."
(require 'arc-mode)
(cond ((string-match "^file:\\(.+\\)" url)
- (-when-let* ((file (cider--url-to-file (match-string 1 url)))
- (path (cider--file-path file)))
+ (when-let ((file (cider--url-to-file (match-string 1 url)))
+ (path (cider--file-path file)))
(find-file-noselect path)))
((string-match "^\\(jar\\|zip\\):\\(file:.+\\)!/\\(.+\\)" url)
- (-when-let* ((entry (match-string 3 url))
- (file (cider--url-to-file (match-string 2 url)))
- (path (cider--file-path file))
- (name (format "%s:%s" path entry)))
+ (when-let ((entry (match-string 3 url))
+ (file (cider--url-to-file (match-string 2 url)))
+ (path (cider--file-path file))
+ (name (format "%s:%s" path entry)))
(or (find-buffer-visiting name)
(if (tramp-tramp-file-p path)
(progn
@@ -199,7 +199,7 @@ existing file ending with URL has been found."
(set-buffer-modified-p nil)
(set-auto-mode)
(current-buffer))))))
- (t (-if-let (path (cider--file-path url))
+ (t (if-let (path (cider--file-path url))
(find-file-noselect path)
(unless (file-name-absolute-p url)
(let ((cider-buffers (cider-util--clojure-buffers))
diff --git a/cider-compat.el b/cider-compat.el
new file mode 100644
index 00000000..d1307336
--- /dev/null
+++ b/cider-compat.el
@@ -0,0 +1,160 @@
+;;; cider-compat.el --- Contributed functions from other projects -*- lexical-binding: t -*-
+
+;; Copyright © 2012-2015 Tim King, Phil Hagelberg
+;; Copyright © 2013-2015 Bozhidar Batsov, Hugo Duncan, Steve Purcell
+;;
+
+;; This program is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+;; This file is not part of GNU Emacs.
+
+;;; Code:
+
+;;; copied from subr-x, as a dash replacement
+
+(eval-and-compile
+
+ (unless (fboundp 'thread-first )
+
+ (defmacro internal--thread-argument (first? &rest forms)
+ "Internal implementation for `thread-first' and `thread-last'.
+When Argument FIRST? is non-nil argument is threaded first, else
+last. FORMS are the expressions to be threaded."
+ (pcase forms
+ (`(,x (,f . ,args) . ,rest)
+ `(internal--thread-argument
+ ,first? ,(if first? `(,f ,x ,@args) `(,f ,@args ,x)) ,@rest))
+ (`(,x ,f . ,rest) `(internal--thread-argument ,first? (,f ,x) ,@rest))
+ (_ (car forms))))
+
+ (defmacro thread-first (&rest forms)
+ "Thread FORMS elements as the first argument of their successor.
+Example:
+ (thread-first
+ 5
+ (+ 20)
+ (/ 25)
+ -
+ (+ 40))
+Is equivalent to:
+ (+ (- (/ (+ 5 20) 25)) 40)
+Note how the single `-' got converted into a list before
+threading."
+ (declare (indent 1)
+ (debug (form &rest [&or symbolp (sexp &rest form)])))
+ `(internal--thread-argument t ,@forms)))
+
+ (unless (fboundp 'thread-last )
+
+ (defmacro thread-last (&rest forms)
+ "Thread FORMS elements as the last argument of their successor.
+Example:
+ (thread-last
+ 5
+ (+ 20)
+ (/ 25)
+ -
+ (+ 40))
+Is equivalent to:
+ (+ 40 (- (/ 25 (+ 20 5))))
+Note how the single `-' got converted into a list before
+threading."
+ (declare (indent 1) (debug thread-first))
+ `(internal--thread-argument nil ,@forms))))
+
+
+(eval-and-compile
+
+ (unless (fboundp 'internal--listify)
+
+ (defsubst internal--listify (elt)
+ "Wrap ELT in a list if it is not one."
+ (if (not (listp elt))
+ (list elt)
+ elt)))
+
+ (unless (fboundp 'internal--check-binding)
+
+ (defsubst internal--check-binding (binding)
+ "Check BINDING is properly formed."
+ (when (> (length binding) 2)
+ (signal
+ 'error
+ (cons "`let' bindings can have only one value-form" binding)))
+ binding))
+
+ (unless (fboundp 'internal--build-binding-value-form)
+
+ (defsubst internal--build-binding-value-form (binding prev-var)
+ "Build the conditional value form for BINDING using PREV-VAR."
+ `(,(car binding) (and ,prev-var ,(cadr binding)))))
+
+ (unless (fboundp ' internal--build-binding)
+
+ (defun internal--build-binding (binding prev-var)
+ "Check and build a single BINDING with PREV-VAR."
+ (thread-first
+ binding
+ internal--listify
+ internal--check-binding
+ (internal--build-binding-value-form prev-var))))
+
+ (unless (fboundp ' internal--build-bindings)
+
+ (defun internal--build-bindings (bindings)
+ "Check and build conditional value forms for BINDINGS."
+ (let ((prev-var t))
+ (mapcar (lambda (binding)
+ (let ((binding (internal--build-binding binding prev-var)))
+ (setq prev-var (car binding))
+ binding))
+ bindings)))))
+
+(eval-and-compile
+
+ (unless (fboundp 'if-let)
+
+ (defmacro if-let (bindings then &rest else)
+
+ "Process BINDINGS and if all values are non-nil eval THEN, else ELSE.
+Argument BINDINGS is a list of tuples whose car is a symbol to be
+bound and (optionally) used in THEN, 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 2)
+ (debug ([&or (&rest (symbolp form)) (symbolp form)] form body)))
+ (when (and (<= (length bindings) 2)
+ (not (listp (car bindings))))
+ ;; Adjust the single binding case
+ (setq bindings (list bindings)))
+ `(let* ,(internal--build-bindings bindings)
+ (if ,(car (internal--listify (car (last bindings))))
+ ,then
+ ,@else)))
+
+
+ (defmacro when-let (bindings &rest body)
+ "Process BINDINGS and if all values are non-nil eval BODY.
+Argument BINDINGS is a list of tuples whose car is a symbol to be
+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))))
+
+
+
+ )
+
+(provide 'cider-compat)
diff --git a/cider-debug.el b/cider-debug.el
index 7841b831..a96016b2 100644
--- a/cider-debug.el
+++ b/cider-debug.el
@@ -28,10 +28,12 @@
(require 'nrepl-client)
(require 'cider-interaction)
(require 'cider-client)
+(require 'cider-util)
(require 'cider-inspector)
(require 'cider-browse-ns)
(require 'cider-common)
-(require 'dash)
+(require 'cider-compat)
+(require 'seq)
(require 'spinner)
@@ -107,8 +109,8 @@ This variable must be set before starting the repl connection."
(defun cider-browse-instrumented-defs ()
"List all instrumented definitions."
(interactive)
- (-if-let (all (-> (cider-nrepl-send-sync-request (list "op" "debug-instrumented-defs"))
- (nrepl-dict-get "list")))
+ (if-let (all (thread-first (cider-nrepl-send-sync-request (list "op" "debug-instrumented-defs"))
+ (nrepl-dict-get "list")))
(with-current-buffer (cider-popup-buffer cider-browse-ns-buffer t)
(let ((inhibit-read-only t))
(erase-buffer)
@@ -203,7 +205,7 @@ Each element of LOCALS should be a list of at least two elements."
;; `eval' is now integrated with things like `C-x C-e' and `C-c M-:'
;; so we don't advertise this key to reduce clutter.
;; `inspect' would conflict with `inject'.
- (-difference command-list '("eval" "inspect")) " ")
+ (seq-difference command-list '("eval" "inspect")) " ")
"\n"))
(defvar-local cider--debug-prompt-overlay nil)
@@ -291,7 +293,7 @@ In order to work properly, this mode must be activated by
(nrepl-dict-get cider--debug-mode-response "key")))
;; Set the keymap.
(let ((alist (mapcar (lambda (k) (cons (string-to-char k) (concat ":" k)))
- (-difference input-type '("inspect")))))
+ (seq-difference input-type '("inspect")))))
(setq cider--debug-mode-commands-alist alist)
(dolist (it alist)
(define-key cider--debug-mode-map (vector (car it)) #'cider-debug-mode-send-reply)))
@@ -311,8 +313,8 @@ In order to work properly, this mode must be activated by
;; We wait a moment before clearing overlays and the read-onlyness, so that
;; cider-nrepl has a chance to send the next message, and so that the user
;; doesn't accidentally hit `n' between two messages (thus editing the code).
- (-when-let (proc (unless nrepl-ongoing-sync-request
- (get-buffer-process (cider-current-connection))))
+ (when-let (proc (unless nrepl-ongoing-sync-request
+ (get-buffer-process (cider-current-connection))))
(accept-process-output proc 0.5))
(unless cider--debug-mode
(setq buffer-read-only nil)
@@ -389,7 +391,7 @@ specific message."
"Create a new debugging buffer with CODE and namespace NS.
ID is the id of the message that instrumented CODE."
(let ((buffer-name (format cider--debug-buffer-format id)))
- (-if-let (buffer (get-buffer buffer-name))
+ (if-let (buffer (get-buffer buffer-name))
(cider-popup-buffer-display buffer 'select)
(with-current-buffer (cider-popup-buffer buffer-name 'select
#'clojure-mode 'ancillary)
@@ -407,7 +409,7 @@ ID is the id of the message that instrumented CODE."
(defun cider--debug-goto-keyval (key)
"Find KEY in current sexp or return nil."
- (-when-let (limit (ignore-errors (save-excursion (up-list) (point))))
+ (when-let (limit (ignore-errors (save-excursion (up-list) (point))))
(search-forward-regexp (concat "\\_<" (regexp-quote key) "\\_>")
limit 'noerror)))
@@ -486,8 +488,8 @@ needed. It is expected to contain at least \"key\", \"input-type\", and
(when (or code (and file point))
;; We prefer in-source debugging.
(when (and file point)
- (-if-let (buf (find-buffer-visiting file))
- (-if-let (win (get-buffer-window buf))
+ (if-let (buf (find-buffer-visiting file))
+ (if-let (win (get-buffer-window buf))
(select-window win)
(pop-to-buffer buf))
(find-file file))
diff --git a/cider-doc.el b/cider-doc.el
index 48ce0ed6..e69f39d7 100644
--- a/cider-doc.el
+++ b/cider-doc.el
@@ -26,12 +26,14 @@
;;; Code:
(require 'cider-common)
+(require 'cider-compat)
+(require 'cider-util)
(require 'cider-popup)
(require 'cider-client)
+(require 'cider-grimoire)
(require 'nrepl-client)
(require 'org-table)
(require 'button)
-(require 'dash)
(require 'easymenu)
@@ -202,8 +204,8 @@ opposite of what that option dictates."
"Open the source for the current symbol, if available."
(interactive)
(if cider-docview-file
- (-if-let (buffer (and (not (cider--tooling-file-p cider-docview-file))
- (cider-find-file cider-docview-file)))
+ (if-let (buffer (and (not (cider--tooling-file-p cider-docview-file))
+ (cider-find-file cider-docview-file)))
(cider-jump-to buffer (if cider-docview-line
(cons cider-docview-line nil)
cider-docview-symbol)
@@ -236,12 +238,12 @@ opposite of what that option dictates."
(defun cider-create-doc-buffer (symbol)
"Populates *cider-doc* with the documentation for SYMBOL."
- (-when-let (info (cider-var-info symbol))
+ (when-let (info (cider-var-info symbol))
(cider-docview-render (cider-make-popup-buffer cider-doc-buffer) symbol info)))
(defun cider-doc-lookup (symbol)
"Look up documentation for SYMBOL."
- (-if-let (buffer (cider-create-doc-buffer symbol))
+ (if-let (buffer (cider-create-doc-buffer symbol))
(cider-popup-buffer-display buffer t)
(user-error "Symbol %s not resolved" symbol)))
diff --git a/cider-eldoc.el b/cider-eldoc.el
index a09d43c4..fe31dd67 100644
--- a/cider-eldoc.el
+++ b/cider-eldoc.el
@@ -32,9 +32,12 @@
(require 'cider-client)
(require 'cider-common) ; for cider-symbol-at-point
+(require 'cider-compat)
+(require 'cider-util)
+
+(require 'cl-lib)
(require 'eldoc)
-(require 'dash)
(defvar cider-extra-eldoc-commands '("yas-expand")
"Extra commands to be added to eldoc's safe commands list.")
@@ -67,7 +70,7 @@ POS is the index of the currently highlighted argument."
(defun cider--find-rest-args-position (arglist)
"Find the position of & in the ARGLIST vector."
- (-elem-index '& (append arglist ())))
+ (cl-position '& (append arglist ())))
(defun cider-highlight-arglist (arglist pos)
"Format the ARGLIST for eldoc.
@@ -130,7 +133,7 @@ Return the number of nested sexp the point was over or after. "
;; check if we can used the cached eldoc info
(if (string= thing (car cider-eldoc-last-symbol))
(cdr cider-eldoc-last-symbol)
- (-when-let (eldoc-info (cider-sync-request:eldoc (substring-no-properties thing)))
+ (when-let (eldoc-info (cider-sync-request:eldoc (substring-no-properties thing)))
(let ((arglist (nrepl-dict-get eldoc-info "eldoc")))
(setq cider-eldoc-last-symbol (cons thing arglist))
arglist)))))
diff --git a/cider-grimoire.el b/cider-grimoire.el
index 7628f319..8de916c4 100644
--- a/cider-grimoire.el
+++ b/cider-grimoire.el
@@ -27,21 +27,22 @@
(require 'cider-client)
(require 'cider-common)
+(require 'cider-compat)
(require 'cider-popup)
+
(require 'nrepl-client)
-(require 'dash)
(require 'url-vars)
(defconst cider-grimoire-url "http://conj.io/")
(defun cider-grimoire-replace-special (name)
"Convert the dashes in NAME to a grimoire friendly format."
- (->> name
- (replace-regexp-in-string "\\?" "_QMARK_")
- (replace-regexp-in-string "\\." "_DOT_")
- (replace-regexp-in-string "\\/" "_SLASH_")
- (replace-regexp-in-string "\\(\\`_\\)\\|\\(_\\'\\)" "")))
+ (thread-last name
+ (replace-regexp-in-string "\\?" "_QMARK_")
+ (replace-regexp-in-string "\\." "_DOT_")
+ (replace-regexp-in-string "\\/" "_SLASH_")
+ (replace-regexp-in-string "\\(\\`_\\)\\|\\(_\\'\\)" "")))
(defun cider-grimoire-url (name ns)
"Generate a grimoire search v0 url from NAME, NS."
@@ -51,7 +52,7 @@
(defun cider-grimoire-web-lookup (symbol)
"Look up the grimoire documentation for SYMBOL."
- (-if-let (var-info (cider-var-info symbol))
+ (if-let (var-info (cider-var-info symbol))
(let ((name (nrepl-dict-get var-info "name"))
(ns (nrepl-dict-get var-info "ns")))
(browse-url (cider-grimoire-url name ns)))
@@ -80,7 +81,7 @@ opposite of what that option dictates."
(defun cider-grimoire-lookup (symbol)
"Look up the grimoire documentation for SYMBOL."
- (-if-let (var-info (cider-var-info symbol))
+ (if-let (var-info (cider-var-info symbol))
(let ((name (nrepl-dict-get var-info "name"))
(ns (nrepl-dict-get var-info "ns"))
(url-request-method "GET")
diff --git a/cider-interaction.el b/cider-interaction.el
index 3e0f9c39..e456cf7d 100644
--- a/cider-interaction.el
+++ b/cider-interaction.el
@@ -34,14 +34,15 @@
(require 'cider-repl)
(require 'cider-popup)
(require 'cider-common)
+(require 'cider-util)
(require 'cider-stacktrace)
(require 'cider-test)
(require 'cider-doc)
(require 'cider-eldoc)
(require 'cider-overlays)
+(require 'cider-compat)
(require 'clojure-mode)
-(require 'dash)
(require 'thingatpt)
(require 'etags)
(require 'arc-mode)
@@ -273,7 +274,7 @@ When invoked with a prefix ARG the command doesn't prompt for confirmation."
(defun cider--quit-error-window ()
"Buries the `cider-error-buffer' and quits its containing window."
- (-when-let (error-win (get-buffer-window cider-error-buffer))
+ (when-let (error-win (get-buffer-window cider-error-buffer))
(quit-window nil error-win)))
;;;
@@ -349,12 +350,12 @@ A default value of thing at point is given when prompted."
CALLBACK upon failure to invoke prompt if not prompted previously.
Show results in a different window if OTHER-WINDOW is true."
- (-if-let (info (cider-var-info symbol-file))
+ (if-let (info (cider-var-info symbol-file))
(cider--jump-to-loc-from-info info other-window)
(progn
(cider-ensure-op-supported "resource")
- (-if-let* ((resource (cider-sync-request:resource symbol-file))
- (buffer (cider-find-file resource)))
+ (if-let ((resource (cider-sync-request:resource symbol-file))
+ (buffer (cider-find-file resource)))
(cider-jump-to buffer 0 other-window)
(if (cider--prompt-for-symbol-p current-prefix-arg)
(error "Resource or var %s not resolved" symbol-file)
@@ -387,8 +388,8 @@ value is thing at point."
(cider-ensure-op-supported "resource")
(when (= (length path) 0)
(error "Cannot find resource for empty path"))
- (-if-let* ((resource (cider-sync-request:resource path))
- (buffer (cider-find-file resource)))
+ (if-let ((resource (cider-sync-request:resource path))
+ (buffer (cider-find-file resource)))
(cider-jump-to buffer nil (cider--open-other-window-p current-prefix-arg))
(if (cider--prompt-for-symbol-p current-prefix-arg)
(error "Cannot find resource %s" path)
@@ -424,13 +425,13 @@ Invert meaning of `cider-prompt-for-symbol' if PREFIX indicates it should be."
(defun cider-sync-request:ns-path (ns)
"Get the path to the file containing NS."
- (-> (list "op" "ns-path"
- "ns" ns)
- cider-nrepl-send-sync-request
- (nrepl-dict-get "path")))
+ (thread-first (list "op" "ns-path"
+ "ns" ns)
+ cider-nrepl-send-sync-request
+ (nrepl-dict-get "path")))
(defun cider--find-ns (ns &optional other-window)
- (-if-let (path (cider-sync-request:ns-path ns))
+ (if-let (path (cider-sync-request:ns-path ns))
(cider-jump-to (cider-find-file path) nil other-window)
(user-error "Can't find %s" ns)))
@@ -543,7 +544,7 @@ The formatting is performed by `cider-annotate-completion-function'."
(defun cider-complete-at-point ()
"Complete the symbol at point."
- (-when-let (sap (cider-symbol-at-point))
+ (when-let (sap (cider-symbol-at-point))
(when (and (cider-connected-p)
(not (or (cider-in-string-p) (cider-in-comment-p))))
(let ((bounds (bounds-of-thing-at-point 'symbol)))
@@ -559,10 +560,10 @@ The formatting is performed by `cider-annotate-completion-function'."
Returns the cons of the buffer itself and the location of VAR's definition
in the buffer."
- (-when-let* ((info (cider-var-info var))
- (file (nrepl-dict-get info "file"))
- (line (nrepl-dict-get info "line"))
- (buffer (cider-find-file file)))
+ (when-let ((info (cider-var-info var))
+ (file (nrepl-dict-get info "file"))
+ (line (nrepl-dict-get info "line"))
+ (buffer (cider-find-file file)))
(with-current-buffer buffer
(save-excursion
(goto-char (point-min))
@@ -693,7 +694,7 @@ This is used by pretty-printing commands and intentionally discards their result
(defun cider-visit-error-buffer ()
"Visit the `cider-error-buffer' (usually *cider-error*) if it exists."
(interactive)
- (-if-let (buffer (get-buffer cider-error-buffer))
+ (if-let (buffer (get-buffer cider-error-buffer))
(cider-popup-buffer-display buffer cider-auto-select-error-buffer)
(user-error "No %s buffer" cider-error-buffer)))
@@ -866,7 +867,7 @@ If location could not be found, return nil."
(col (nth 2 info)))
(unless (or (not (stringp file))
(cider--tooling-file-p file))
- (-when-let (buffer (cider-find-file file))
+ (when-let (buffer (cider-find-file file))
(with-current-buffer buffer
(save-excursion
(save-restriction
@@ -884,9 +885,9 @@ If location could not be found, return nil."
"Highlight and jump to compilation error extracted from MESSAGE.
EVAL-BUFFER is the buffer that was current during user's interactive
evaluation command. Honor `cider-auto-jump-to-error'."
- (-when-let* ((loc (cider--find-last-error-location message))
- (overlay (make-overlay (nth 0 loc) (nth 1 loc) (nth 2 loc)))
- (info (cider-extract-error-info cider-compilation-regexp message)))
+ (when-let ((loc (cider--find-last-error-location message))
+ (overlay (make-overlay (nth 0 loc) (nth 1 loc) (nth 2 loc)))
+ (info (cider-extract-error-info cider-compilation-regexp message)))
(let* ((face (nth 3 info))
(note (nth 4 info))
(auto-jump (if (eq cider-auto-jump-to-error 'errors-only)
@@ -907,7 +908,7 @@ evaluation command. Honor `cider-auto-jump-to-error'."
;; configuration (https://github.com/clojure-emacs/cider/issues/847). In
;; that case we don't jump at all in order to avoid covering *cider-error*
;; buffer.
- (-when-let (win (get-buffer-window eval-buffer))
+ (when-let (win (get-buffer-window eval-buffer))
(with-selected-window win
(cider-jump-to (nth 2 loc) (car loc)))))))))
@@ -1164,10 +1165,10 @@ If invoked with a prefix ARG eval the expression after inserting it."
(defun cider-ping ()
"Check that communication with the nREPL server works."
(interactive)
- (-> (cider-nrepl-sync-request:eval "\"PONG\"")
- (nrepl-dict-get "value")
- (read)
- (message)))
+ (thread-first (cider-nrepl-sync-request:eval "\"PONG\"")
+ (nrepl-dict-get "value")
+ (read)
+ (message)))
(defun cider-enable-on-existing-clojure-buffers ()
"Enable CIDER's minor mode on existing Clojure buffers.
@@ -1197,10 +1198,10 @@ See command `cider-mode'."
(defun cider-sync-request:toggle-trace-var (symbol)
"Toggle var tracing for SYMBOL."
(cider-ensure-op-supported "toggle-trace-var")
- (-> (list "op" "toggle-trace-var"
- "ns" (cider-current-ns)
- "sym" symbol)
- (cider-nrepl-send-sync-request)))
+ (thread-first (list "op" "toggle-trace-var"
+ "ns" (cider-current-ns)
+ "sym" symbol)
+ (cider-nrepl-send-sync-request)))
(defun cider--toggle-trace-var (sym)
(let* ((trace-response (cider-sync-request:toggle-trace-var sym))
@@ -1226,9 +1227,9 @@ opposite of what that option dictates."
(defun cider-sync-request:toggle-trace-ns (ns)
"Toggle namespace tracing for NS."
(cider-ensure-op-supported "toggle-trace-ns")
- (-> (list "op" "toggle-trace-ns"
- "ns" ns)
- (cider-nrepl-send-sync-request)))
+ (thread-first (list "op" "toggle-trace-ns"
+ "ns" ns)
+ (cider-nrepl-send-sync-request)))
(defun cider-toggle-trace-ns (query)
"Toggle ns tracing.
@@ -1346,7 +1347,7 @@ unloaded."
(file-name-nondirectory
(buffer-file-name))))))
(cider-ensure-connected)
- (-when-let (buf (find-buffer-visiting filename))
+ (when-let (buf (find-buffer-visiting filename))
(with-current-buffer buf
(remove-overlays nil nil 'cider-type 'instrumented-defs)
(cider--clear-compilation-highlights)))
@@ -1468,7 +1469,7 @@ the string contents of the region into a formatted string."
(newline)
(insert (format "Supported ops:"))
(newline)
- (-each ops (lambda (op) (insert (format " * %s" op)) (newline)))))
+ (mapc (lambda (op) (insert (format " * %s" op)) (newline)) ops)))
(display-buffer cider-nrepl-session-buffer))))
(defun cider-close-nrepl-session ()
@@ -1484,7 +1485,7 @@ the string contents of the region into a formatted string."
"Close the BUFFER and kill its associated process (if any)."
(when (buffer-live-p buffer)
(with-current-buffer buffer
- (-when-let (proc (get-buffer-process buffer))
+ (when-let (proc (get-buffer-process buffer))
(when (process-live-p proc)
(when (or (not nrepl-server-buffer)
;; Sync request will hang if the server is dead.
@@ -1566,9 +1567,9 @@ VAR is a fully qualified Clojure variable name as a string."
With a prefix argument, prompt for function to run instead of -main."
(interactive (list (when current-prefix-arg (read-string "Function name: "))))
(let ((name (or function "-main")))
- (-when-let (response (cider-nrepl-send-sync-request
- (list "op" "ns-list-vars-by-name" "name" name)))
- (-if-let (vars (split-string (substring (nrepl-dict-get response "var-list") 1 -1)))
+ (when-let (response (cider-nrepl-send-sync-request
+ (list "op" "ns-list-vars-by-name" "name" name)))
+ (if-let (vars (split-string (substring (nrepl-dict-get response "var-list") 1 -1)))
(cider-interactive-eval
(if (= (length vars) 1)
(concat "(" (car vars) ")")
diff --git a/cider-macroexpansion.el b/cider-macroexpansion.el
index 35d68610..4285d9c1 100644
--- a/cider-macroexpansion.el
+++ b/cider-macroexpansion.el
@@ -31,6 +31,7 @@
;;; Code:
(require 'cider-mode)
+(require 'cider-compat)
(defconst cider-macroexpansion-buffer "*cider-macroexpansion*")
@@ -63,17 +64,17 @@ Possible values are:
The default for DISPLAY-NAMESPACES is taken from
`cider-macroexpansion-display-namespaces'."
(cider-ensure-op-supported "macroexpand")
- (-> (list "op" "macroexpand"
- "expander" expander
- "code" expr
- "ns" (cider-current-ns)
- "display-namespaces"
- (or display-namespaces
- (symbol-name cider-macroexpansion-display-namespaces)))
- (append (when cider-macroexpansion-print-metadata
- (list "print-meta" "true")))
- (cider-nrepl-send-sync-request)
- (nrepl-dict-get "expansion")))
+ (thread-first (list "op" "macroexpand"
+ "expander" expander
+ "code" expr
+ "ns" (cider-current-ns)
+ "display-namespaces"
+ (or display-namespaces
+ (symbol-name cider-macroexpansion-display-namespaces)))
+ (append (when cider-macroexpansion-print-metadata
+ (list "print-meta" "true")))
+ (cider-nrepl-send-sync-request)
+ (nrepl-dict-get "expansion")))
(defun cider-macroexpand-undo (&optional arg)
"Undo the last macroexpansion, using `undo-only'.
diff --git a/cider-mode.el b/cider-mode.el
index d6194178..1d243f41 100644..100755
--- a/cider-mode.el
+++ b/cider-mode.el
@@ -35,6 +35,7 @@
(require 'cider-eldoc)
(require 'cider-resolve)
(require 'cider-doc)
+(require 'cider-compat)
(defcustom cider-mode-line-show-connection t
"If the mode-line lighter should detail the connection."
@@ -46,7 +47,7 @@
"Return info for the `cider-mode' modeline.
Info contains project name and host:port endpoint."
- (-if-let (current-connection (ignore-errors (cider-current-connection)))
+ (if-let (current-connection (ignore-errors (cider-current-connection)))
(with-current-buffer current-connection
(concat
(when cider-repl-type
@@ -305,13 +306,13 @@ Returns to the buffer in which the command was invoked."
;;; Dynamic indentation
(defun cider--get-symbol-indent (symbol-name)
"Return the indent metadata for SYMBOL-NAME in the current namespace."
- (-when-let (indent
- (nrepl-dict-get (cider-resolve-var (cider-current-ns) symbol-name)
- "indent"))
- (let ((format (format ":indent metadata on ‘%s’ is unreadable! \nERROR: %%s"
- symbol-name)))
- (with-demoted-errors format
- (cider--deep-vector-to-list (read indent))))))
+ (when-let (indent
+ (nrepl-dict-get (cider-resolve-var (cider-current-ns) symbol-name)
+ "indent"))
+ (let ((format (format ":indent metadata on ‘%s’ is unreadable! \nERROR: %%s"
+ symbol-name)))
+ (with-demoted-errors format
+ (cider--deep-vector-to-list (read indent))))))
;;; Dynamic font locking
(defcustom cider-font-lock-dynamically '(macro core deprecated)
@@ -353,8 +354,8 @@ The value can also be t, which means to font-lock as much as possible."
(defun cider--compile-font-lock-keywords (symbols-plist core-plist)
"Return a list of font-lock rules for the symbols in SYMBOLS-PLIST."
(let ((cider-font-lock-dynamically (if (eq cider-font-lock-dynamically t)
- '(function var macro core deprecated)
- cider-font-lock-dynamically))
+ '(function var macro core deprecated)
+ cider-font-lock-dynamically))
deprecated
macros functions vars instrumented)
(when (memq 'core cider-font-lock-dynamically)
@@ -417,11 +418,11 @@ namespace itself."
(interactive)
(when cider-font-lock-dynamically
(font-lock-remove-keywords nil cider--dynamic-font-lock-keywords)
- (-when-let (symbols (cider-resolve-ns-symbols (or ns (cider-current-ns))))
- (setq-local cider--dynamic-font-lock-keywords
- (cider--compile-font-lock-keywords
- symbols (cider-resolve-ns-symbols (cider-resolve-core-ns))))
- (font-lock-add-keywords nil cider--dynamic-font-lock-keywords 'end))
+ (when-let (symbols (cider-resolve-ns-symbols (or ns (cider-current-ns))))
+ (setq-local cider--dynamic-font-lock-keywords
+ (cider--compile-font-lock-keywords
+ symbols (cider-resolve-ns-symbols (cider-resolve-core-ns))))
+ (font-lock-add-keywords nil cider--dynamic-font-lock-keywords 'end))
(if (fboundp 'font-lock-flush)
(font-lock-flush)
(with-no-warnings
diff --git a/cider-overlays.el b/cider-overlays.el
index ace77385..5ce5462d 100644
--- a/cider-overlays.el
+++ b/cider-overlays.el
@@ -26,6 +26,7 @@
;;; Code:
(require 'cider-common)
+(require 'cider-compat)
(require 'cl-lib)
@@ -136,8 +137,8 @@ All arguments beyond these (PROPS) are properties to be used on the
overlay."
(declare (indent 1))
;; If the marker points to a dead buffer, don't do anything.
- (-if-let (buffer (if (markerp where) (marker-buffer where)
- (current-buffer)))
+ (if-let (buffer (if (markerp where) (marker-buffer where)
+ (current-buffer)))
(with-current-buffer buffer
(remove-overlays nil nil 'cider-type 'result)
(save-excursion
@@ -166,7 +167,7 @@ overlay."
#'cider--remove-result-overlay-after-command
nil 'local)
(cider--remove-result-overlay-after-command))))
- (-when-let (win (get-buffer-window buffer))
+ (when-let (win (get-buffer-window buffer))
;; Left edge is visible.
(when (and (<= (window-start win) (point))
;; In 24.3 `<=' is still a binary perdicate.
diff --git a/cider-popup.el b/cider-popup.el
index 983c1368..13d28bfd 100644
--- a/cider-popup.el
+++ b/cider-popup.el
@@ -20,7 +20,7 @@
;;; Code:
(require 'nrepl-client)
-(require 'dash)
+(require 'cider-compat)
(define-minor-mode cider-popup-buffer-mode
"Mode for CIDER popup buffers"
@@ -43,8 +43,8 @@ If SELECT is non-nil, select the newly created window.
If major MODE is non-nil, enable it for the popup buffer.
If ANCILLARY is non-nil, the buffer is added to `cider-ancillary-buffers'
and automatically removed when killed."
- (-> (cider-make-popup-buffer name mode ancillary)
- (cider-popup-buffer-display select)))
+ (thread-first (cider-make-popup-buffer name mode ancillary)
+ (cider-popup-buffer-display select)))
(defun cider-popup-buffer-display (buffer &optional select)
"Display BUFFER.
diff --git a/cider-repl.el b/cider-repl.el
index 72b23622..f2796be6 100644
--- a/cider-repl.el
+++ b/cider-repl.el
@@ -34,6 +34,7 @@
(require 'cider-doc)
(require 'cider-eldoc) ; for cider-eldoc-setup
(require 'cider-common)
+(require 'cider-compat)
(require 'clojure-mode)
(require 'easymenu)
@@ -187,7 +188,7 @@ Currently, this is only used to keep `cider-repl-type' updated."
(dolist (b (buffer-list))
(with-current-buffer b
(when cider-mode
- (-when-let (ns-dict (nrepl-dict-get changed-namespaces (cider-current-ns)))
+ (when-let (ns-dict (nrepl-dict-get changed-namespaces (cider-current-ns)))
(cider-refresh-dynamic-font-lock ns-dict))))))))))
(declare-function cider-default-err-handler "cider-interaction")
diff --git a/cider-resolve.el b/cider-resolve.el
index 91a93a8a..c617f6f9 100644
--- a/cider-resolve.el
+++ b/cider-resolve.el
@@ -66,6 +66,7 @@
(require 'cider-client)
(require 'nrepl-client)
+(require 'cider-util)
(defvar cider-repl-ns-cache)
@@ -94,7 +95,7 @@ Return nil only if VAR cannot be resolved."
(cider-resolve--get-in (or var-ns ns) "interns" name)
(unless var-ns
;; If the var had no prefix, it might be referred.
- (-if-let (referal (cider-resolve--get-in ns "refers" name))
+ (if-let (referal (cider-resolve--get-in ns "refers" name))
(cider-resolve-var ns referal)
;; Or it might be from core.
(unless (equal ns "clojure.core")
@@ -106,16 +107,16 @@ This will be clojure.core or cljs.core depending on `cider-repl-type'."
(when (cider-connected-p)
(with-current-buffer (cider-current-connection)
(cider-resolve--get-in (if (equal cider-repl-type "cljs")
- "cljs.core"
- "clojure.core")))))
+ "cljs.core"
+ "clojure.core")))))
(defun cider-resolve-ns-symbols (ns)
"Return a plist of all valid symbols in NS.
Each entry's value is the metadata of the var that the symbol refers to.
NS can be the namespace name, or a dict of the namespace itself."
- (-when-let (dict (if (stringp ns)
- (cider-resolve--get-in ns)
- ns))
+ (when-let (dict (if (stringp ns)
+ (cider-resolve--get-in ns)
+ ns))
(nrepl-dbind-response dict (interns refers aliases)
(append (cdr interns)
(nrepl-dict-flat-map (lambda (alias namespace)
diff --git a/cider-stacktrace.el b/cider-stacktrace.el
index b5f1b05b..7157ae8c 100644
--- a/cider-stacktrace.el
+++ b/cider-stacktrace.el
@@ -28,10 +28,13 @@
(require 'cl-lib)
(require 'cider-popup)
(require 'button)
-(require 'dash)
(require 'easymenu)
(require 'cider-common)
+(require 'cider-compat)
(require 'cider-client)
+(require 'cider-util)
+
+(require 'seq)
;; Variables
@@ -203,7 +206,7 @@ cyclical data structures."
(setq-local cider-stacktrace-prior-filters nil)
(setq-local cider-stacktrace-hidden-frame-count 0)
(setq-local cider-stacktrace-filters cider-stacktrace-default-filters)
- (setq-local cider-stacktrace-cause-visibility (apply 'vector (-repeat 10 0))))
+ (setq-local cider-stacktrace-cause-visibility (apply 'vector (make-list 10 0))))
;; Stacktrace filtering
@@ -253,20 +256,21 @@ hidden count."
(while (not (eobp))
(unless (get-text-property (point) 'collapsed)
(let* ((flags (get-text-property (point) 'flags))
- (hide (if (-intersection filters flags) t nil)))
+ (hide (if (seq-intersection filters flags) t nil)))
(when hide (setq hidden (+ 1 hidden)))
(put-text-property (point) (line-beginning-position 2) 'invisible hide)))
(forward-line 1))
(setq cider-stacktrace-hidden-frame-count hidden)))
(cider-stacktrace-indicate-filters filters)))
+
(defun cider-stacktrace-apply-cause-visibility ()
"Apply `cider-stacktrace-cause-visibility' to causes and reapply filters."
(with-current-buffer cider-error-buffer
(save-excursion
(goto-char (point-min))
(cl-flet ((next-detail (end)
- (-when-let (pos (next-single-property-change (point) 'detail))
+ (when-let (pos (next-single-property-change (point) 'detail))
(when (< pos end)
(goto-char pos)))))
(let ((inhibit-read-only t))
@@ -293,14 +297,14 @@ hidden count."
"Move point to the previous exception cause, if one exists."
(interactive)
(with-current-buffer cider-error-buffer
- (-when-let (pos (previous-single-property-change (point) 'cause))
+ (when-let (pos (previous-single-property-change (point) 'cause))
(goto-char pos))))
(defun cider-stacktrace-next-cause ()
"Move point to the next exception cause, if one exists."
(interactive)
(with-current-buffer cider-error-buffer
- (-when-let (pos (next-single-property-change (point) 'cause))
+ (when-let (pos (next-single-property-change (point) 'cause))
(goto-char pos))))
(defun cider-stacktrace-cycle-cause (num &optional level)
@@ -325,14 +329,14 @@ it wraps to 0."
(let* ((num (get-text-property (point) 'cause))
(level (1+ (elt cider-stacktrace-cause-visibility num))))
(setq-local cider-stacktrace-cause-visibility
- (apply 'vector (-repeat 10 (mod level 3))))
+ (apply 'vector (make-list 10 (mod level 3))))
(cider-stacktrace-apply-cause-visibility)))))
(defun cider-stacktrace-cycle-current-cause ()
"Cycle the visibility of current exception at point, if any."
(interactive)
(with-current-buffer cider-error-buffer
- (-when-let (num (get-text-property (point) 'cause))
+ (when-let (num (get-text-property (point) 'cause))
(cider-stacktrace-cycle-cause num))))
(defun cider-stacktrace-cycle-cause-1 ()
diff --git a/cider-test.el b/cider-test.el
index a5a19d42..35df3629 100644
--- a/cider-test.el
+++ b/cider-test.el
@@ -32,8 +32,9 @@
(require 'cider-client)
(require 'cider-popup)
(require 'cider-stacktrace)
+(require 'cider-compat)
+
(require 'button)
-(require 'dash)
(require 'easymenu)
;;; Variables
@@ -147,7 +148,7 @@
(defun cider-test-show-report ()
"Show the test report buffer, if one exists."
(interactive)
- (-if-let (report-buffer (get-buffer cider-test-report-buffer))
+ (if-let (report-buffer (get-buffer cider-test-report-buffer))
(switch-to-buffer report-buffer)
(message "No test report buffer")))
@@ -155,14 +156,14 @@
"Move point to the previous test result, if one exists."
(interactive)
(with-current-buffer (get-buffer cider-test-report-buffer)
- (-when-let (pos (previous-single-property-change (point) 'type))
+ (when-let (pos (previous-single-property-change (point) 'type))
(goto-char pos))))
(defun cider-test-next-result ()
"Move point to the next test result, if one exists."
(interactive)
(with-current-buffer (get-buffer cider-test-report-buffer)
- (-when-let (pos (next-single-property-change (point) 'type))
+ (when-let (pos (next-single-property-change (point) 'type))
(goto-char pos))))
(defun cider-test-jump (&optional arg)
@@ -374,15 +375,15 @@ With the actual value, the outermost '(not ...)' s-expression is removed."
"Return the buffer visiting the file in which VAR is defined, or nil if
not found."
(cider-ensure-op-supported "info")
- (-when-let* ((info (cider-var-info var))
- (file (nrepl-dict-get info "file")))
+ (when-let ((info (cider-var-info var))
+ (file (nrepl-dict-get info "file")))
(cider-find-file file)))
(defun cider-test-highlight-problems (ns results)
"Highlight all non-passing tests in the NS test RESULTS."
(nrepl-dict-map
(lambda (var tests)
- (-when-let (buffer (cider-find-var-file (concat ns "/" var)))
+ (when-let (buffer (cider-find-var-file (concat ns "/" var)))
(dolist (test tests)
(nrepl-dbind-response test (type)
(unless (equal "pass" type)
@@ -392,9 +393,9 @@ not found."
(defun cider-test-clear-highlights ()
"Clear highlighting of non-passing tests from the last test run."
(interactive)
- (-when-let (ns cider-test-last-test-ns)
+ (when-let (ns cider-test-last-test-ns)
(dolist (var (nrepl-dict-keys cider-test-last-results))
- (-when-let (buffer (cider-find-var-file (concat ns "/" var)))
+ (when-let (buffer (cider-find-var-file (concat ns "/" var)))
(with-current-buffer buffer
(remove-overlays))))))
@@ -460,7 +461,7 @@ displayed. When test failures/errors occur, their sources are highlighted."
(defun cider-test-rerun-tests ()
"Rerun failed and erring tests from the last tested namespace."
(interactive)
- (-if-let (ns cider-test-last-test-ns)
+ (if-let (ns cider-test-last-test-ns)
(cider-test-execute ns t)
(message "No namespace to retest")))
@@ -470,11 +471,11 @@ displayed. When test failures/errors occur, their sources are highlighted."
With a prefix arg SUPPRESS-INFERENCE it will try to run the tests in the
current ns."
(interactive "P")
- (-if-let (ns (if suppress-inference
- (clojure-find-ns)
- (or (funcall cider-test-infer-test-ns (clojure-find-ns))
- (when (eq major-mode 'cider-test-report-mode)
- cider-test-last-test-ns))))
+ (if-let (ns (if suppress-inference
+ (clojure-find-ns)
+ (or (funcall cider-test-infer-test-ns (clojure-find-ns))
+ (when (eq major-mode 'cider-test-report-mode)
+ cider-test-last-test-ns))))
(cider-test-execute ns nil)
(message "No namespace to test in current context")))
diff --git a/cider-util.el b/cider-util.el
index 114c5a2e..c448fabb 100644
--- a/cider-util.el
+++ b/cider-util.el
@@ -30,10 +30,9 @@
;;; Code:
-(require 'dash)
+(require 'seq)
(require 'cl-lib)
(require 'clojure-mode)
-(require 'nrepl-client)
(defalias 'cider-pop-back 'pop-tag-mark)
(define-obsolete-function-alias 'cider-jump-back 'cider-pop-back "0.10.0")
@@ -54,7 +53,7 @@ Setting this to nil removes the fontification restriction."
(defun cider-util--clojure-buffers ()
"Return a list of all existing `clojure-mode' buffers."
- (-filter
+ (seq-filter
(lambda (buffer) (with-current-buffer buffer (derived-mode-p 'clojure-mode)))
(buffer-list)))
@@ -117,6 +116,14 @@ which nREPL uses for temporary evaluation file names."
(bounds-of-thing-at-point 'sexp)))
(bounds-of-thing-at-point 'sexp)))
+(defun cider-map-indexed (f list)
+ "Return a list of (F index item) for each item in LIST."
+ (let ((i 0)
+ (out))
+ (dolist (it list (nreverse out))
+ (push (funcall f i it) out)
+ (setq i (1+ i)))))
+
(defun cider-symbol-at-point ()
"Return the name of the symbol at point, otherwise nil."
(let ((str (or (thing-at-point 'symbol) "")))
@@ -152,6 +159,7 @@ instead."
(progn (clojure-forward-logical-sexp 1)
(point))))))
+
;;; Text properties
(defun cider-maybe-intern (name)
@@ -160,7 +168,7 @@ instead."
(defun cider-intern-keys (props)
"Copy plist-style PROPS with any non-symbol keys replaced with symbols."
- (-map-indexed (lambda (i x) (if (cl-oddp i) x (cider-maybe-intern x))) props))
+ (cider-map-indexed (lambda (i x) (if (cl-oddp i) x (cider-maybe-intern x))) props))
(defmacro cider-propertize-region (props &rest body)
"Execute BODY and add PROPS to all the text it inserts.
diff --git a/cider.el b/cider.el
index 5473a7f5..a3eeec75 100644
--- a/cider.el
+++ b/cider.el
@@ -11,7 +11,7 @@
;; Maintainer: Bozhidar Batsov <bozhidar@batsov.com>
;; URL: http://www.github.com/clojure-emacs/cider
;; Version: 0.10.0-cvs
-;; Package-Requires: ((clojure-mode "4.2.0") (dash "2.11.0") (pkg-info "0.4") (emacs "24.3") (queue "0.1.1") (spinner "1.4"))
+;; Package-Requires: ((clojure-mode "4.2.0") (pkg-info "0.4") (emacs "24.3") (queue "0.1.1") (spinner "1.4") (seq "1.9"))
;; Keywords: languages, clojure, cider
;; This program is free software: you can redistribute it and/or modify
@@ -72,9 +72,12 @@
(require 'cider-repl)
(require 'cider-mode)
(require 'cider-common)
+(require 'cider-compat)
(require 'cider-debug)
(require 'tramp-sh)
+(require 'seq)
+
(defconst cider-version "0.10.0-snapshot"
"Fallback version used when it cannot be extracted automatically.
Normally it won't be used, unless `pkg-info' fails to extract the
@@ -223,15 +226,15 @@ confirmation and return 'new/nil for y/n answer respectively. If other
REPL buffers with dead process exist, ask the user if any of those should
be reused."
(let* ((repl-buffs (cider-repl-buffers))
- (exact-buff (-first (lambda (buff)
- (with-current-buffer buff
- (or (and endpoint (equal endpoint nrepl-endpoint))
- (and project-directory (equal project-directory nrepl-project-dir)))))
- repl-buffs)))
+ (exact-buff (seq-find (lambda (buff)
+ (with-current-buffer buff
+ (or (and endpoint (equal endpoint nrepl-endpoint))
+ (and project-directory (equal project-directory nrepl-project-dir)))))
+ repl-buffs)))
(cl-flet ((zombie-buffer-or-new
- () (let ((zombie-buffs (-remove (lambda (buff)
- (process-live-p (get-buffer-process buff)))
- repl-buffs)))
+ () (let ((zombie-buffs (seq-remove (lambda (buff)
+ (process-live-p (get-buffer-process buff)))
+ repl-buffs)))
(if zombie-buffs
(if (y-or-n-p (format "Zombie REPL buffers exist (%s). Reuse? "
(mapconcat #'buffer-name zombie-buffs ", ")))
@@ -270,7 +273,7 @@ own buffer."
(cider-jack-in-params project-type))
(cider-jack-in-params project-type)))
(cmd (format "%s %s" (cider-jack-in-command project-type) params)))
- (-when-let (repl-buff (cider-find-reusable-repl-buffer nil project-dir))
+ (when-let (repl-buff (cider-find-reusable-repl-buffer nil project-dir))
(let ((nrepl-create-client-buffer-function #'cider-repl-create)
(nrepl-use-this-as-repl-buffer repl-buff))
(nrepl-start-server-process
@@ -296,7 +299,7 @@ When the optional param PROJECT-DIR is present, the connection
gets associated with it."
(interactive (cider-select-endpoint))
(setq cider-current-clojure-buffer (current-buffer))
- (-when-let (repl-buff (cider-find-reusable-repl-buffer `(,host ,port) nil))
+ (when-let (repl-buff (cider-find-reusable-repl-buffer `(,host ,port) nil))
(let* ((nrepl-create-client-buffer-function #'cider-repl-create)
(nrepl-use-this-as-repl-buffer repl-buff)
(conn (process-buffer (nrepl-start-client-process host port))))
@@ -316,15 +319,15 @@ gets associated with it."
(defun cider-select-endpoint ()
"Interactively select the host and port to connect to."
(let* ((ssh-hosts (cider--ssh-hosts))
- (hosts (-distinct (append (when cider-host-history
- ;; history elements are strings of the form "host:port"
- (list (split-string (car cider-host-history) ":")))
- (list (list (cider-current-host)))
- cider-known-endpoints
- ssh-hosts
- (when (file-remote-p default-directory)
- ;; add localhost even in remote buffers
- '(("localhost"))))))
+ (hosts (seq-uniq (append (when cider-host-history
+ ;; history elements are strings of the form "host:port"
+ (list (split-string (car cider-host-history) ":")))
+ (list (list (cider-current-host)))
+ cider-known-endpoints
+ ssh-hosts
+ (when (file-remote-p default-directory)
+ ;; add localhost even in remote buffers
+ '(("localhost"))))))
(sel-host (cider--completing-read-host hosts))
(host (car sel-host))
(port (or (cadr sel-host)
@@ -333,9 +336,9 @@ gets associated with it."
(defun cider--ssh-hosts ()
"Retrieve all ssh host from local configuration files."
- (-map (lambda (s) (list (replace-regexp-in-string ":$" "" s)))
- (let ((tramp-completion-mode t))
- (tramp-completion-handle-file-name-all-completions "" "/ssh:"))))
+ (seq-map (lambda (s) (list (replace-regexp-in-string ":$" "" s)))
+ (let ((tramp-completion-mode t))
+ (tramp-completion-handle-file-name-all-completions "" "/ssh:"))))
(defun cider--completing-read-host (hosts)
"Interactively select host from HOSTS.
@@ -383,10 +386,10 @@ When DIR is non-nil also look for nREPL port files in DIR. Return a list
of list of the form (project-dir port)."
(let* ((paths (cider--running-nrepl-paths))
(proj-ports (mapcar (lambda (d)
- (-when-let (port (and d (nrepl-extract-port (cider--file-path d))))
+ (when-let (port (and d (nrepl-extract-port (cider--file-path d))))
(list (file-name-nondirectory (directory-file-name d)) port)))
(cons (clojure-project-dir dir) paths))))
- (-distinct (delq nil proj-ports))))
+ (seq-uniq (delq nil proj-ports))))
(defun cider--running-nrepl-paths ()
"Retrieve project paths of running nREPL servers.
@@ -398,7 +401,7 @@ Use `cider-ps-running-nrepls-command' and `cider-ps-running-nrepl-path-regexp-li
(goto-char 1)
(while (re-search-forward regexp nil t)
(setq paths (cons (match-string 1) paths)))))
- (-distinct paths)))
+ (seq-uniq paths)))
(defun cider-project-type ()
"Determine the type, either leiningen or boot, of the current project.
@@ -436,8 +439,8 @@ In case `default-directory' is non-local we assume the command is available."
(defun cider--check-required-nrepl-ops ()
"Check whether all required nREPL ops are present."
(let* ((current-connection (cider-current-connection))
- (missing-ops (-remove (lambda (op) (nrepl-op-supported-p op current-connection))
- cider-required-nrepl-ops)))
+ (missing-ops (seq-remove (lambda (op) (nrepl-op-supported-p op current-connection))
+ cider-required-nrepl-ops)))
(when missing-ops
(cider-repl-emit-interactive-stderr
(format "WARNING: The following required nREPL ops are not supported: \n%s\nPlease, install (or update) cider-nrepl %s and restart CIDER"
diff --git a/nrepl-client.el b/nrepl-client.el
index f3d71a2c..d6ea251e 100644
--- a/nrepl-client.el
+++ b/nrepl-client.el
@@ -67,7 +67,9 @@
;; description.
;;; Code:
-(require 'dash)
+(require 'seq)
+(require 'cider-compat)
+
(require 'thingatpt)
(require 'etags)
(require 'ansi-color)
@@ -554,8 +556,8 @@ Integers, lists and nrepl-dicts are treated according to bencode
specification. Everything else is encoded as string."
(cond
((integerp object) (format "i%de" object))
- ((nrepl-dict-p object) (format "d%se" (apply #'concat (-map #'nrepl-bencode (cdr object)))))
- ((listp object) (format "l%se" (apply #'concat (-map #'nrepl-bencode object))))
+ ((nrepl-dict-p object) (format "d%se" (apply #'concat (seq-map #'nrepl-bencode (cdr object)))))
+ ((listp object) (format "l%se" (apply #'concat (seq-map #'nrepl-bencode object))))
(t (format "%s:%s" (string-bytes object) object))))
@@ -612,7 +614,7 @@ and kill the process buffer."
(message "nREPL: Connection closed unexpectedly (%s)"
(substring message 0 -1)))
(when (equal (process-status process) 'closed)
- (-when-let (client-buffer (process-buffer process))
+ (when-let (client-buffer (process-buffer process))
(with-current-buffer client-buffer
(run-hooks 'nrepl-disconnected-hook)
(when (buffer-live-p nrepl-server-buffer)
@@ -673,9 +675,9 @@ If NO-ERROR is non-nil, show messages instead of throwing an error."
(error "nREPL: SSH port forwarding failed. Check the '%s' buffer" tunnel-buf)
(message "nREPL: SSH port forwarding established to localhost:%s" port)
(let ((endpoint (nrepl--direct-connect "localhost" port)))
- (-> endpoint
- (plist-put :tunnel tunnel)
- (plist-put :remote-host host))))))
+ (thread-first endpoint
+ (plist-put :tunnel tunnel)
+ (plist-put :remote-host host))))))
(defun nrepl--ssh-tunnel-command (ssh dir port)
"Command string to open SSH tunnel to the host associated with DIR's PORT."
@@ -751,11 +753,11 @@ process."
(process-put client-proc :response-q (nrepl-response-queue))
(with-current-buffer client-buf
- (-when-let (server-buf (and server-proc (process-buffer server-proc)))
+ (when-let (server-buf (and server-proc (process-buffer server-proc)))
(setq nrepl-project-dir (buffer-local-value 'nrepl-project-dir server-buf)
nrepl-server-buffer server-buf))
(setq nrepl-endpoint `(,host ,port)
- nrepl-tunnel-buffer (-when-let (tunnel (plist-get endpoint :tunnel))
+ nrepl-tunnel-buffer (when-let (tunnel (plist-get endpoint :tunnel))
(process-buffer tunnel))
nrepl-pending-requests (make-hash-table :test 'equal)
nrepl-completed-requests (make-hash-table :test 'equal)))
@@ -812,7 +814,7 @@ values of *1, *2, etc."
It is safe to call this function multiple times on the same ID."
;; FIXME: This should go away eventually when we get rid of
;; pending-request hash table
- (-when-let (handler (gethash id nrepl-pending-requests))
+ (when-let (handler (gethash id nrepl-pending-requests))
(puthash id handler nrepl-completed-requests)
(remhash id nrepl-pending-requests)))
@@ -942,11 +944,11 @@ sign of user input, so as not to hang the interface."
(accept-process-output nil 0.01))
;; If we couldn't finish, return nil.
(when (member "done" status)
- (-when-let* ((ex (nrepl-dict-get response "ex"))
- (err (nrepl-dict-get response "err")))
+ (when-let ((ex (nrepl-dict-get response "ex"))
+ (err (nrepl-dict-get response "err")))
(cider-repl-emit-interactive-stderr err)
(message "%s" err))
- (-when-let (id (nrepl-dict-get response "id"))
+ (when-let (id (nrepl-dict-get response "id"))
(with-current-buffer connection
(nrepl--mark-id-completed id)))
response)))
@@ -1082,7 +1084,7 @@ the port, and the client buffer."
(set-marker (process-mark process) (point)))
(when moving
(goto-char (process-mark process))
- (-when-let (win (get-buffer-window))
+ (when-let (win (get-buffer-window))
(set-window-point win (point))))))
;; detect the port the server is listening on from its output
(when (string-match "nREPL server started on port \\([0-9]+\\)" output)
@@ -1173,7 +1175,7 @@ operations.")
(delete-region (point-min) (- (point) 1)))
(goto-char (point-max))
(nrepl--pp msg (nrepl--message-color (lax-plist-get (cdr msg) "id")))
- (-when-let (win (get-buffer-window))
+ (when-let (win (get-buffer-window))
(set-window-point win (point-max)))
(setq buffer-read-only t))))
@@ -1187,9 +1189,9 @@ operations.")
"Return the color to use when pretty-printing the nREPL message with ID.
If ID is nil, return nil."
(when id
- (-> (string-to-number id)
- (mod (length nrepl-message-colors))
- (nth nrepl-message-colors))))
+ (thread-first (string-to-number id)
+ (mod (length nrepl-message-colors))
+ (nth nrepl-message-colors))))
(defcustom nrepl-dict-max-message-size 5
"Max number of lines a dict can have before being truncated.
diff --git a/test/cider-tests--no-auto.el b/test/cider-tests--no-auto.el
index 496b5790..c8fa1aaf 100644
--- a/test/cider-tests--no-auto.el
+++ b/test/cider-tests--no-auto.el
@@ -32,7 +32,7 @@
(require 'ert)
(require 'cider)
-(require 'dash)
+(require 'cider-contrib)
(require 'cl-lib)
;;; Docs
@@ -52,7 +52,7 @@ from the latter. Remaining content is compared for string equality."
(replace-match ""))
(goto-line 2)
(buffer-substring (point) (point-max)))))
- (cider-doc (-if-let (doc-buffer (cider-doc-buffer-for sym))
+ (cider-doc (if-let (doc-buffer (cider-doc-buffer-for sym))
(with-current-buffer doc-buffer
(let ((inhibit-read-only t))
(goto-char (point-min))