branch: elpa/magit
commit 2d49dae6722005c4880c77f85fecb2bb0727d8e2
Author: Jonas Bernoulli <jo...@bernoul.li>
Commit: Jonas Bernoulli <jo...@bernoul.li>

    Use ## and seq-find instead of --first
    
    In one case use lambda and in another pcase-lambda, not ##.
---
 lisp/magit-base.el     |  2 +-
 lisp/magit-bisect.el   |  2 +-
 lisp/magit-blame.el    |  6 +++---
 lisp/magit-commit.el   |  8 ++++----
 lisp/magit-diff.el     | 14 +++++++-------
 lisp/magit-git.el      |  6 +++---
 lisp/magit-log.el      | 27 +++++++++++++--------------
 lisp/magit-mode.el     | 16 ++++++++--------
 lisp/magit-notes.el    |  4 ++--
 lisp/magit-process.el  | 21 +++++++++++----------
 lisp/magit-section.el  |  2 +-
 lisp/magit-sequence.el |  8 ++++----
 lisp/magit-subtree.el  |  4 ++--
 test/magit-tests.el    |  6 +++---
 14 files changed, 63 insertions(+), 63 deletions(-)

diff --git a/lisp/magit-base.el b/lisp/magit-base.el
index b58f3dc7d77..00633367368 100644
--- a/lisp/magit-base.el
+++ b/lisp/magit-base.el
@@ -1158,7 +1158,7 @@ See <https://github.com/raxod502/straight.el/issues/520>."
 Like `message', except that if the users configured option
 `magit-no-message' to prevent the message corresponding to
 FORMAT-STRING to be displayed, then don't."
-  (unless (--first (string-prefix-p it format-string) magit-no-message)
+  (unless (seq-find (##string-prefix-p % format-string) magit-no-message)
     (apply #'message format-string args)))
 
 (defun magit-msg (format-string &rest args)
diff --git a/lisp/magit-bisect.el b/lisp/magit-bisect.el
index 475d2575006..5f077641b51 100644
--- a/lisp/magit-bisect.el
+++ b/lisp/magit-bisect.el
@@ -256,7 +256,7 @@ bisect run'."
            (done-re "^\\([a-z0-9]\\{40,\\}\\) is the first bad commit$")
            (bad-line (or (and (string-match done-re (car lines))
                               (pop lines))
-                         (--first (string-match done-re it) lines))))
+                         (seq-find (##string-match done-re %) lines))))
       (magit-insert-section ((eval (if bad-line 'commit 'bisect-output))
                              (and bad-line (match-string 1 bad-line)))
         (magit-insert-heading
diff --git a/lisp/magit-blame.el b/lisp/magit-blame.el
index 42e8f28b350..7278173208e 100644
--- a/lisp/magit-blame.el
+++ b/lisp/magit-blame.el
@@ -283,9 +283,9 @@ Also see option `magit-blame-styles'."
 (defun magit-blame--overlay-at (&optional pos key)
   (unless pos
     (setq pos (point)))
-  (--first (overlay-get it (or key 'magit-blame-chunk))
-           (nconc (overlays-at pos)
-                  (overlays-in pos pos))))
+  (seq-find (##overlay-get % (or key 'magit-blame-chunk))
+            (nconc (overlays-at pos)
+                   (overlays-in pos pos))))
 
 ;;; Keymaps
 
diff --git a/lisp/magit-commit.el b/lisp/magit-commit.el
index b796298cc34..6c46cc4ef0c 100644
--- a/lisp/magit-commit.el
+++ b/lisp/magit-commit.el
@@ -743,10 +743,10 @@ See `magit-commit-absorb' for an alternative 
implementation."
 (defun magit-commit-message-buffer ()
   (let* ((find-file-visit-truename t) ; git uses truename of COMMIT_EDITMSG
          (topdir (magit-toplevel)))
-    (--first (equal topdir (with-current-buffer it
-                             (and git-commit-mode (magit-toplevel))))
-             (append (buffer-list (selected-frame))
-                     (buffer-list)))))
+    (seq-find (##equal topdir (with-current-buffer %
+                                (and git-commit-mode (magit-toplevel))))
+              (append (buffer-list (selected-frame))
+                      (buffer-list)))))
 
 (defvar magit-commit-add-log-insert-function #'magit-commit-add-log-insert
   "Used by `magit-commit-add-log' to insert a single entry.")
diff --git a/lisp/magit-diff.el b/lisp/magit-diff.el
index 2e6a40a790c..1bc7385dd42 100644
--- a/lisp/magit-diff.el
+++ b/lisp/magit-diff.el
@@ -1526,7 +1526,7 @@ instead."
                   (string-to-number context)
                 3))
          (val magit-buffer-diff-args)
-         (arg (--first (string-match "^-U\\([0-9]+\\)?$" it) val))
+         (arg (seq-find (##string-match "^-U\\([0-9]+\\)?$" %) val))
          (num (if-let ((str (and arg (match-string 1 arg))))
                   (string-to-number str)
                 def))
@@ -1538,8 +1538,8 @@ instead."
   (magit-refresh))
 
 (defun magit-diff-context-p ()
-  (if-let ((arg (--first (string-match "^-U\\([0-9]+\\)$" it)
-                         magit-buffer-diff-args)))
+  (if-let ((arg (seq-find (##string-match "^-U\\([0-9]+\\)$" %)
+                          magit-buffer-diff-args)))
       (not (equal arg "-U0"))
     t))
 
@@ -3418,10 +3418,10 @@ are highlighted."
                magit-diff-highlight-indentation
              (setq-local
               magit-diff-highlight-indentation
-              (cdr (--first (string-match-p (car it) default-directory)
-                            (nreverse
-                             (default-value
-                              'magit-diff-highlight-indentation))))))))
+              (cdr (seq-find (##string-match-p (car %) default-directory)
+                             (nreverse
+                              (default-value
+                               'magit-diff-highlight-indentation))))))))
       (when (and magit-diff-highlight-trailing
                  (looking-at (concat prefix ".*?\\([ \t]+\\)
?$")))
         (let ((ov (make-overlay (match-beginning 1) (match-end 1) nil t)))
diff --git a/lisp/magit-git.el b/lisp/magit-git.el
index c05ddae17b0..2ea9f8768e4 100644
--- a/lisp/magit-git.el
+++ b/lisp/magit-git.el
@@ -2308,8 +2308,8 @@ and this option only controls what face is used.")
                  ", " t))
           state head upstream tags branches remotes other combined)
       (dolist (ref refs)
-        (let* ((face (cdr (--first (string-match (car it) ref)
-                                   magit-ref-namespaces)))
+        (let* ((face (cdr (seq-find (##string-match (car %) ref)
+                                    magit-ref-namespaces)))
                (name (match-string 1 ref))
                (name (if (and name
                               (not (string-prefix-p "refs/tags/" ref))
@@ -2720,7 +2720,7 @@ and this option only controls what face is used.")
                            (or (magit-section-value-if 'branch)
                                atpoint
                                (and (not (cdr atrev)) (car atrev))
-                               (--first (not (equal it current)) atrev)
+                               (seq-find (##not (equal % current)) atrev)
                                (magit-get-previous-branch)
                                (car atrev)))))
 
diff --git a/lisp/magit-log.el b/lisp/magit-log.el
index ac17b7b2c5e..fe03f9b402e 100644
--- a/lisp/magit-log.el
+++ b/lisp/magit-log.el
@@ -883,7 +883,7 @@ limit.  Otherwise set it to 256."
 
 (defun magit-log-set-commit-limit (fn)
   (let* ((val magit-buffer-log-args)
-         (arg (--first (string-match "^-n\\([0-9]+\\)?$" it) val))
+         (arg (seq-find (##string-match "^-n\\([0-9]+\\)?$" %) val))
          (num (and arg (string-to-number (match-string 1 arg))))
          (num (if num (funcall fn num 2) 256)))
     (setq val (remove arg val))
@@ -894,8 +894,8 @@ limit.  Otherwise set it to 256."
   (magit-refresh))
 
 (defun magit-log-get-commit-limit (&optional args)
-  (and-let* ((str (--first (string-match "^-n\\([0-9]+\\)?$" it)
-                           (or args magit-buffer-log-args))))
+  (and-let* ((str (seq-find (##string-match "^-n\\([0-9]+\\)?$" %)
+                            (or args magit-buffer-log-args))))
     (string-to-number (match-string 1 str))))
 
 ;;;; Mode Commands
@@ -925,9 +925,8 @@ is displayed in the current frame."
     (let* ((section (magit-current-section))
            (parent-rev (format "%s^%s" (oref section value) (or n 1))))
       (if-let ((parent-hash (magit-rev-parse "--short" parent-rev)))
-          (if-let ((parent (--first (equal (oref it value)
-                                           parent-hash)
-                                    (magit-section-siblings section 'next))))
+          (if-let ((parent (seq-find (##equal (oref % value) parent-hash)
+                                     (magit-section-siblings section 'next))))
               (magit-section-goto parent)
             (user-error
              (substitute-command-keys
@@ -1191,8 +1190,8 @@ Do not add this to a hook variable."
                     (concat "\n" magit-log-revision-headers-format "\n"))
                 ""))
       (progn
-        (when-let ((order (--first (string-match "^\\+\\+order=\\(.+\\)$" it)
-                                   args)))
+        (when-let ((order (seq-find (##string-match "^\\+\\+order=\\(.+\\)$" %)
+                                    args)))
           (setq args (cons (format "--%s-order" (match-string 1 order))
                            (remove order args))))
         (when (member "--decorate" args)
@@ -1518,10 +1517,10 @@ If there is no blob buffer in the same frame, then do 
nothing."
 
 (defun magit--maybe-update-blob-buffer ()
   (when-let* ((commit (magit-section-value-if 'commit))
-              (buffer (--first (with-current-buffer it
-                                 (eq revert-buffer-function
-                                     'magit-revert-rev-file-buffer))
-                               (mapcar #'window-buffer (window-list)))))
+              (buffer (seq-find (##with-current-buffer %
+                                  (eq revert-buffer-function
+                                      'magit-revert-rev-file-buffer))
+                                (mapcar #'window-buffer (window-list)))))
     (if magit--update-blob-buffer
         (setq magit--update-blob-buffer (list commit buffer))
       (setq magit--update-blob-buffer (list commit buffer))
@@ -1540,8 +1539,8 @@ If there is no blob buffer in the same frame, then do 
nothing."
 
 (defun magit-log-goto-commit-section (rev)
   (let ((abbrev (magit-rev-format "%h" rev)))
-    (when-let ((section (--first (equal (oref it value) abbrev)
-                                 (oref magit-root-section children))))
+    (when-let ((section (seq-find (##equal (oref % value) abbrev)
+                                  (oref magit-root-section children))))
       (goto-char (oref section start)))))
 
 (defun magit-log-goto-same-commit ()
diff --git a/lisp/magit-mode.el b/lisp/magit-mode.el
index 13709ab1336..efa8e6fa410 100644
--- a/lisp/magit-mode.el
+++ b/lisp/magit-mode.el
@@ -983,14 +983,14 @@ current buffer is the last remaining Magit buffer that was
 ever displayed in the selected window, then delete that
 window."
   (if (or (one-window-p)
-          (--first (let ((buffer (car it)))
-                     (and (not (eq buffer (current-buffer)))
-                          (buffer-live-p buffer)
-                          (or (not (window-parameter nil 'magit-dedicated))
-                              (with-current-buffer buffer
-                                (derived-mode-p 'magit-mode
-                                                'magit-process-mode)))))
-                   (window-prev-buffers)))
+          (seq-find (pcase-lambda (`(,buffer))
+                      (and (not (eq buffer (current-buffer)))
+                           (buffer-live-p buffer)
+                           (or (not (window-parameter nil 'magit-dedicated))
+                               (with-current-buffer buffer
+                                 (derived-mode-p 'magit-mode
+                                                 'magit-process-mode)))))
+                    (window-prev-buffers)))
       (quit-window kill-buffer)
     (let ((window (selected-window)))
       (quit-window kill-buffer)
diff --git a/lisp/magit-notes.el b/lisp/magit-notes.el
index 64bf977aa64..0b262158e71 100644
--- a/lisp/magit-notes.el
+++ b/lisp/magit-notes.el
@@ -192,8 +192,8 @@ Also see `magit-notes-merge'."
 
 (defun magit-notes-read-args (prompt)
   (list (magit-read-branch-or-commit prompt (magit-stash-at-point))
-        (and-let* ((str (--first (string-match "^--ref=\\(.+\\)" it)
-                                 (transient-args 'magit-notes))))
+        (and-let* ((str (seq-find (##string-match "^--ref=\\(.+\\)" %)
+                                  (transient-args 'magit-notes))))
           (match-string 1 str))))
 
 ;;; _
diff --git a/lisp/magit-process.el b/lisp/magit-process.el
index 915eb81f65e..296b4aa2239 100644
--- a/lisp/magit-process.el
+++ b/lisp/magit-process.el
@@ -335,10 +335,10 @@ optional NODISPLAY is non-nil also display it."
           (while (not (equal topdir prev))
             (setq prev topdir)
             (setq topdir (file-name-directory (directory-file-name 
topdir)))))))
-    (let ((buffer (or (--first (with-current-buffer it
-                                 (and (eq major-mode 'magit-process-mode)
-                                      (equal default-directory topdir)))
-                               (buffer-list))
+    (let ((buffer (or (seq-find (##with-current-buffer %
+                                  (and (eq major-mode 'magit-process-mode)
+                                       (equal default-directory topdir)))
+                                (buffer-list))
                       (magit-generate-new-buffer 'magit-process-mode
                                                  nil topdir))))
       (with-current-buffer buffer
@@ -1030,12 +1030,13 @@ as argument."
               (memq magit-credential-cache-daemon-process
                     (list-system-processes)))
     (setq magit-credential-cache-daemon-process
-          (or (--first (let* ((attr (process-attributes it))
-                              (comm (cdr (assq 'comm attr)))
-                              (user (cdr (assq 'user attr))))
-                         (and (string= comm "git-credential-cache--daemon")
-                              (string= user user-login-name)))
-                       (list-system-processes))
+          (or (seq-find (lambda (process)
+                          (let* ((attr (process-attributes process))
+                                 (comm (cdr (assq 'comm attr)))
+                                 (user (cdr (assq 'user attr))))
+                            (and (string= comm "git-credential-cache--daemon")
+                                 (string= user user-login-name))))
+                        (list-system-processes))
               (condition-case nil
                   (start-process "git-credential-cache--daemon"
                                  " *git-credential-cache--daemon*"
diff --git a/lisp/magit-section.el b/lisp/magit-section.el
index 76255c9e576..b8a5673cab0 100644
--- a/lisp/magit-section.el
+++ b/lisp/magit-section.el
@@ -1266,7 +1266,7 @@ of course you want to be that precise."
   (cl-assert condition)
   (and section
        (if (listp condition)
-           (--first (magit-section-match-1 it section) condition)
+           (seq-find (##magit-section-match-1 % section) condition)
          (magit-section-match-2 (if (symbolp condition)
                                     (list condition)
                                   (cl-coerce condition 'list))
diff --git a/lisp/magit-sequence.el b/lisp/magit-sequence.el
index 2dc40fb2b69..9a3469535d0 100644
--- a/lisp/magit-sequence.el
+++ b/lisp/magit-sequence.el
@@ -347,7 +347,7 @@ the process manually."
         ((cl-set-difference commits merges :test #'equal)
          (user-error "Cannot %s merge and non-merge commits at once"
                      command))
-        ((--first (string-prefix-p "--mainline=" it) args)
+        ((seq-find (##string-prefix-p "--mainline=" %) args)
          args)
         (t
          (cons (format "--mainline=%s"
@@ -1056,10 +1056,10 @@ status buffer (i.e., the reverse of how they will be 
applied)."
     (setq done (magit-git-lines "log" "--format=%H" (concat onto "..HEAD")))
     (when (and stop (not (member (magit-rev-parse stop) done)))
       (let ((id (magit-patch-id stop)))
-        (if-let ((matched (--first (equal (magit-patch-id it) id) done)))
+        (if-let ((matched (seq-find (##equal (magit-patch-id %) id) done)))
             (setq stop matched)
           (cond
-           ((--first (magit-rev-equal it stop) done)
+           ((seq-find (##magit-rev-equal % stop) done)
             ;; The commit's testament has been executed.
             (magit-sequence-insert-commit "void" stop 'magit-sequence-drop))
            ;; The faith of the commit is still undecided...
@@ -1085,7 +1085,7 @@ status buffer (i.e., the reverse of how they will be 
applied)."
                 (t "work")))
              stop 'magit-sequence-part))
            ;; The commit is definitely gone...
-           ((--first (magit-rev-equal it stop) done)
+           ((seq-find (##magit-rev-equal % stop) done)
             ;; ...but all of its changes are still in effect.
             (magit-sequence-insert-commit "poof" stop 'magit-sequence-drop))
            (t
diff --git a/lisp/magit-subtree.el b/lisp/magit-subtree.el
index c8758f3145b..3db80fe9b40 100644
--- a/lisp/magit-subtree.el
+++ b/lisp/magit-subtree.el
@@ -107,8 +107,8 @@
   :reader #'magit-transient-read-revision)
 
 (defun magit-subtree-prefix (transient prompt)
-  (if-let ((arg (--first (string-prefix-p "--prefix=" it)
-                         (transient-args transient))))
+  (if-let ((arg (seq-find (##string-prefix-p "--prefix=" %)
+                          (transient-args transient))))
       (substring arg 9)
     (magit-subtree-read-prefix prompt)))
 
diff --git a/test/magit-tests.el b/test/magit-tests.el
index bb7f661541c..a67b53ca0f5 100644
--- a/test/magit-tests.el
+++ b/test/magit-tests.el
@@ -427,9 +427,9 @@ Enter passphrase for key '/home/user/.ssh/id_rsa': "
 (defun magit-test-get-section (list file)
   (magit-status-setup-buffer default-directory)
   (magit-section-show-level-4-all)
-  (--first (equal (oref it value) file)
-           (oref (magit-get-section `(,list (status)))
-                 children)))
+  (seq-find (##equal (oref % value) file)
+            (oref (magit-get-section `(,list (status)))
+                  children)))
 
 (ert-deftest magit-status:file-sections ()
   (magit-with-test-repository

Reply via email to