branch: elpa/cider
commit ae247d88455c79d6c039d9c322347c77ab3ad11b
Author: Bozhidar Batsov <[email protected]>
Commit: Bozhidar Batsov <[email protected]>
Replace moderate-complexity cl-lib usages with built-in equivalents
- cl-case/cl-ecase → pcase (cider-connection, cider-inspector,
cider-repl, nrepl-client)
- cl-multiple-value-bind → pcase-let (cider-repl)
- cl-destructuring-bind → pcase-let (cider-test)
- cl-adjoin → member check + cons (cider-stacktrace)
- cl-loop with cddr stepping → seq-partition + mapcar (nrepl-dict)
- cl-loop collect → mapcar (nrepl-dict)
---
lisp/cider-connection.el | 12 ++++++------
lisp/cider-inspector.el | 7 ++++---
lisp/cider-repl.el | 9 +++++----
lisp/cider-stacktrace.el | 4 +++-
lisp/cider-test.el | 2 +-
lisp/nrepl-client.el | 2 +-
lisp/nrepl-dict.el | 15 +++++++--------
7 files changed, 27 insertions(+), 24 deletions(-)
diff --git a/lisp/cider-connection.el b/lisp/cider-connection.el
index b2d5de9ca4b..68ff044c551 100644
--- a/lisp/cider-connection.el
+++ b/lisp/cider-connection.el
@@ -1068,20 +1068,20 @@ session."
(let ((cur-type (cider-repl-type-for-buffer))
(which-key (or (car-safe which) which))
(required-ops (cdr-safe which)))
- (cl-case which-key
+ (pcase which-key
(:clj-strict (when (eq cur-type 'cljs)
(user-error "Clojure-only operation requested in a
ClojureScript buffer")))
(:cljs-strict (when (eq cur-type 'clj)
(user-error "ClojureScript-only operation requested in a
Clojure buffer"))))
- (let* ((type (cl-case which-key
- ((:clj :clj-strict) 'clj)
- ((:cljs :cljs-strict) 'cljs)
+ (let* ((type (pcase which-key
+ ((or :clj :clj-strict) 'clj)
+ ((or :cljs :cljs-strict) 'cljs)
(:auto (if (eq cur-type 'multi)
'(clj cljs)
cur-type))))
- (ensure (cl-case which-key
+ (ensure (pcase which-key
(:auto nil)
- (t 'ensure)))
+ (_ 'ensure)))
(repls (cider-repls type ensure required-ops)))
(mapcar function repls))))
diff --git a/lisp/cider-inspector.el b/lisp/cider-inspector.el
index 125ab6add4d..c4f6edfe2b3 100644
--- a/lisp/cider-inspector.el
+++ b/lisp/cider-inspector.el
@@ -627,9 +627,10 @@ LIMIT is the maximum or minimum position in the current
buffer.
Return a list of two values: If an object could be found, the
starting position of the found object and T is returned;
otherwise LIMIT and NIL is returned."
- (let ((finder (cl-ecase direction
- (next 'next-single-property-change)
- (prev 'previous-single-property-change))))
+ (let ((finder (pcase direction
+ ('next 'next-single-property-change)
+ ('prev 'previous-single-property-change)
+ (_ (error "Invalid direction: %s" direction)))))
(let ((prop nil) (curpos (point)))
(while (and (not prop) (not (= curpos limit)))
(let ((newpos (funcall finder curpos 'cider-value-idx nil limit)))
diff --git a/lisp/cider-repl.el b/lisp/cider-repl.el
index f42c43a5b62..4f8126d7870 100644
--- a/lisp/cider-repl.el
+++ b/lisp/cider-repl.el
@@ -1145,7 +1145,7 @@ are not balanced."
If REPLACE is non-nil the current input is replaced with the old
input; otherwise the new input is appended. The old input has the
text property `cider-old-input'."
- (cl-multiple-value-bind (beg end) (cider-property-bounds 'cider-old-input)
+ (pcase-let ((`(,beg ,end) (cider-property-bounds 'cider-old-input)))
(let ((old-input (buffer-substring beg end)) ;;preserve
;;properties, they will be removed later
(offset (- (point) beg)))
@@ -1471,9 +1471,10 @@ Empty strings and duplicates are ignored."
Search in DIRECTION for REGEXP.
Return -1 resp the length of the history if no item matches."
;; Loop through the history list looking for a matching line
- (let* ((step (cl-ecase direction
- (forward -1)
- (backward 1)))
+ (let* ((step (pcase direction
+ ('forward -1)
+ ('backward 1)
+ (_ (error "Invalid direction: %s" direction))))
(history cider-repl-input-history)
(len (length history)))
(cl-loop for pos = (+ start-pos step) then (+ pos step)
diff --git a/lisp/cider-stacktrace.el b/lisp/cider-stacktrace.el
index 3f03ca06a7e..3d491658194 100644
--- a/lisp/cider-stacktrace.el
+++ b/lisp/cider-stacktrace.el
@@ -376,7 +376,9 @@ grouped with a suppressed error type."
(defun cider-stacktrace-suppress-error (error-type)
"Destructively add ERROR-TYPE to the `cider-stacktrace-suppressed-errors'
set."
(setq cider-stacktrace-suppressed-errors
- (cl-adjoin error-type cider-stacktrace-suppressed-errors :test
'equal)))
+ (if (member error-type cider-stacktrace-suppressed-errors)
+ cider-stacktrace-suppressed-errors
+ (cons error-type cider-stacktrace-suppressed-errors))))
(defun cider-stacktrace-promote-error (error-type)
"Destructively remove ERROR-TYPE from `cider-stacktrace-suppressed-errors'."
diff --git a/lisp/cider-test.el b/lisp/cider-test.el
index 6d5c346a1e0..4dcdeff91e2 100644
--- a/lisp/cider-test.el
+++ b/lisp/cider-test.el
@@ -451,7 +451,7 @@ If ELAPSED-TIME is provided it will be included in the
summary."
(insert "\n")))
(if diffs
(dolist (d diffs)
- (cl-destructuring-bind (actual (removed added)) d
+ (pcase-let ((`(,actual (,removed ,added)) d))
(insert-label "actual")
(insert-rect actual)
(insert "\n")
diff --git a/lisp/nrepl-client.el b/lisp/nrepl-client.el
index de83091c463..c11e0aade96 100644
--- a/lisp/nrepl-client.el
+++ b/lisp/nrepl-client.el
@@ -1222,7 +1222,7 @@ close any existing client connections."
;; descriptions for signals to "unknown signal". We correct this by
;; resetting it back to its canonical value.
(when (eq (process-status process) 'signal)
- (cl-case (process-exit-status process)
+ (pcase (process-exit-status process)
;; SIGHUP==1 emacs nt/inc/ms-w32.h
(1 (setq event "Hangup"))
;; SIGINT==2 x86_64-w64-mingw32/include/signal.h
diff --git a/lisp/nrepl-dict.el b/lisp/nrepl-dict.el
index 69c055806f9..4c9b6e52ce1 100644
--- a/lisp/nrepl-dict.el
+++ b/lisp/nrepl-dict.el
@@ -96,23 +96,21 @@ Return new dict. Dict is modified by side effects."
(defun nrepl-dict-keys (dict)
"Return all the keys in the nREPL DICT."
(if (nrepl-dict-p dict)
- (cl-loop for l on (cdr dict) by #'cddr
- collect (car l))
+ (mapcar #'car (seq-partition (cdr dict) 2))
(error "Not an nREPL dict object: %s" dict)))
(defun nrepl-dict-vals (dict)
"Return all the values in the nREPL DICT."
(if (nrepl-dict-p dict)
- (cl-loop for l on (cdr dict) by #'cddr
- collect (cadr l))
+ (mapcar #'cadr (seq-partition (cdr dict) 2))
(error "Not an nREPL dict object: %s" dict)))
(defun nrepl-dict-map (fn dict)
"Map FN on nREPL DICT.
FN must accept two arguments key and value."
(if (nrepl-dict-p dict)
- (cl-loop for l on (cdr dict) by #'cddr
- collect (funcall fn (car l) (cadr l)))
+ (mapcar (lambda (pair) (funcall fn (car pair) (cadr pair)))
+ (seq-partition (cdr dict) 2))
(error "Not an nREPL dict object: %s" dict)))
(defun nrepl-dict-merge (dict1 dict2)
@@ -217,8 +215,9 @@ If NO-JOIN is given, return the first non nil dict."
"Destructure an nREPL RESPONSE dict.
Bind the value of the provided KEYS and execute BODY."
(declare (debug (form (&rest symbolp) body)))
- `(let ,(cl-loop for key in keys
- collect `(,key (nrepl-dict-get ,response ,(format "%s"
key))))
+ `(let ,(mapcar (lambda (key)
+ `(,key (nrepl-dict-get ,response ,(format "%s" key))))
+ keys)
,@body))
(put 'nrepl-dbind-response 'lisp-indent-function 2)