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

    Replace more cl-lib functions with built-in and seq.el equivalents
    
    - cl-find/cl-remove/cl-sort with :key → seq-find/seq-remove/sort with 
lambdas
    - cl-loop → seq-find or dolist for simple cases
    - cl-pushnew with :key → unless + push
    - cl-reduce with :initial-value → seq-reduce
    - cl-destructuring-bind → pcase-let for simple cases
---
 lisp/cider-connection.el |  8 ++++----
 lisp/cider-debug.el      | 10 +++++-----
 lisp/cider-docstring.el  | 20 ++++++++++----------
 lisp/cider-selector.el   | 43 ++++++++++++++++++++++---------------------
 4 files changed, 41 insertions(+), 40 deletions(-)

diff --git a/lisp/cider-connection.el b/lisp/cider-connection.el
index 6c22881c3ea..b2d5de9ca4b 100644
--- a/lisp/cider-connection.el
+++ b/lisp/cider-connection.el
@@ -1006,10 +1006,10 @@ Returns a list of the form ((session1 host1) (session2 
host2) ...)."
 
 (defun cider--extract-connections (sessions)
   "Returns a flattened list of all session buffers in SESSIONS."
-  (cl-reduce (lambda (x y)
-               (append x (cdr y)))
-             sessions
-             :initial-value '()))
+  (seq-reduce (lambda (x y)
+                (append x (cdr y)))
+              sessions
+              '()))
 
 (defun cider-repls (&optional type ensure required-ops)
   "Return cider REPLs of TYPE from the current session.
diff --git a/lisp/cider-debug.el b/lisp/cider-debug.el
index 76307466455..87487b6b5e6 100644
--- a/lisp/cider-debug.el
+++ b/lisp/cider-debug.el
@@ -228,7 +228,7 @@ Each element of LOCALS should be a list of at least two 
elements."
 (defun cider--debug-propertize-prompt-commands ()
   "In-place format the command display names for the `cider-debug-prompt' 
overlay."
   (mapc (lambda (spec)
-          (cl-destructuring-bind (char _cmd disp-name) spec
+          (pcase-let ((`(,char ,_cmd ,disp-name) spec))
             (when-let* ((pos (seq-position disp-name char)))
               (put-text-property pos (1+ pos) 'face 'cider-debug-prompt-face 
disp-name))))
         cider-debug-prompt-commands))
@@ -238,14 +238,14 @@ Each element of LOCALS should be a list of at least two 
elements."
   ;; Force `default' face, otherwise the overlay "inherits" the face of the 
text
   ;; after it.
   (format (propertize "%s\n" 'face 'default)
-          (cl-reduce
+          (seq-reduce
            (lambda (prompt spec)
-             (cl-destructuring-bind (_char cmd disp) spec
-               (if (and disp (cl-find cmd commands :test 'string=))
+             (pcase-let ((`(,_char ,cmd ,disp) spec))
+               (if (and disp (seq-find (lambda (c) (string= cmd c)) commands))
                    (concat prompt " " disp)
                  prompt)))
            cider-debug-prompt-commands
-           :initial-value "")))
+           "")))
 
 (defvar-local cider--debug-prompt-overlay nil)
 
diff --git a/lisp/cider-docstring.el b/lisp/cider-docstring.el
index 18ff958b39d..c50b4cc76f1 100644
--- a/lisp/cider-docstring.el
+++ b/lisp/cider-docstring.el
@@ -67,16 +67,16 @@ otherwise, it's included as-is."
   (when (and fragments
              (> (length fragments)
                 0))
-    (string-trim (cl-reduce (lambda (new-s fragment)
-                              (let* ((html? (equal "html" (nrepl-dict-get 
fragment "type")))
-                                     (v (nrepl-dict-get fragment "content")))
-                                (concat new-s (if html?
-                                                  (let ((shr-use-fonts nil)
-                                                        
(shr-external-rendering-functions '((pre . cider--render-pre))))
-                                                    
(cider--html-to-propertized-string v))
-                                                v))))
-                            fragments
-                            :initial-value ""))))
+    (string-trim (seq-reduce (lambda (new-s fragment)
+                               (let* ((html? (equal "html" (nrepl-dict-get 
fragment "type")))
+                                      (v (nrepl-dict-get fragment "content")))
+                                 (concat new-s (if html?
+                                                   (let ((shr-use-fonts nil)
+                                                         
(shr-external-rendering-functions '((pre . cider--render-pre))))
+                                                     
(cider--html-to-propertized-string v))
+                                                 v))))
+                             fragments
+                             ""))))
 
 (defcustom cider-docstring-max-lines 20
   "The maximum number of docstring lines that will be rendered in a UI widget 
(or the echo area).
diff --git a/lisp/cider-selector.el b/lisp/cider-selector.el
index c23d209a4b7..facf5bbecb1 100644
--- a/lisp/cider-selector.el
+++ b/lisp/cider-selector.el
@@ -55,19 +55,19 @@ CONSIDER-VISIBLE-P will allow handling of visible windows 
as well.
 First pass only considers buffers that are not already visible.
 Second pass will attempt one of visible ones for scenarios where the window
 is visible, but not focused."
-  (cl-loop for buffer in (buffer-list)
-           when (and (with-current-buffer buffer
-                       (apply #'derived-mode-p (if (listp modes)
-                                                   modes
-                                                 (list modes))))
-                     ;; names starting with space are considered hidden by 
Emacs
-                     (not (string-match-p "^ " (buffer-name buffer)))
-                     (or consider-visible-p
-                         (null (get-buffer-window buffer 'visible))))
-           return buffer
-           finally (if consider-visible-p
-                       (error "Can't find unshown buffer in %S" modes)
-                     (cider-selector--recently-visited-buffer modes t))))
+  (or (seq-find (lambda (buffer)
+                  (and (with-current-buffer buffer
+                         (apply #'derived-mode-p (if (listp modes)
+                                                     modes
+                                                   (list modes))))
+                       ;; names starting with space are considered hidden by 
Emacs
+                       (not (string-match-p "^ " (buffer-name buffer)))
+                       (or consider-visible-p
+                           (null (get-buffer-window buffer 'visible)))))
+                (buffer-list))
+      (if consider-visible-p
+          (error "Can't find unshown buffer in %S" modes)
+        (cider-selector--recently-visited-buffer modes t))))
 
 ;;;###autoload
 (defun cider-selector (&optional other-window)
@@ -83,7 +83,7 @@ See `def-cider-selector-method' for defining new methods."
          (ch (save-window-excursion
                (select-window (minibuffer-window))
                (read-char)))
-         (method (cl-find ch cider-selector-methods :key #'car)))
+         (method (seq-find (lambda (m) (eql ch (car m))) 
cider-selector-methods)))
     (cond (method
            (funcall (caddr method)))
           (t
@@ -116,24 +116,25 @@ is chosen.  The returned buffer is selected with
                            (t
                             (switch-to-buffer buffer)))))))
     `(setq cider-selector-methods
-           (cl-sort (cons (list ,key ,description ,method)
-                          (cl-remove ,key cider-selector-methods :key #'car))
-                    #'< :key #'car))))
+           (sort (cons (list ,key ,description ,method)
+                       (seq-remove (lambda (m) (eql ,key (car m))) 
cider-selector-methods))
+                 (lambda (a b) (< (car a) (car b)))))))
 
 (def-cider-selector-method ?? "Selector help buffer."
   (ignore-errors (kill-buffer cider-selector-help-buffer))
   (with-current-buffer (get-buffer-create cider-selector-help-buffer)
     (insert "CIDER Selector Methods:\n\n")
-    (cl-loop for (key line nil) in cider-selector-methods
-             do (insert (format "%c:\t%s\n" key line)))
+    (dolist (entry cider-selector-methods)
+      (insert (format "%c:\t%s\n" (car entry) (cadr entry))))
     (goto-char (point-min))
     (help-mode)
     (display-buffer (current-buffer) t))
   (cider-selector)
   (current-buffer))
 
-(cl-pushnew (list ?4 "Select in other window" (lambda () (cider-selector t)))
-            cider-selector-methods :key #'car)
+(unless (seq-find (lambda (m) (eql ?4 (car m))) cider-selector-methods)
+  (push (list ?4 "Select in other window" (lambda () (cider-selector t)))
+        cider-selector-methods))
 
 (def-cider-selector-method ?c
   "Most recently visited clojure-mode buffer."

Reply via email to