branch: externals/vc-jj
commit 8a90a912632ca71a4492f3643c208430d9ee00f5
Author: Rudi Schlatte <r...@constantly.at>
Commit: Wojciech Siewierski <vi...@noreply.codeberg.org>

    Refactor vc-jj-dir-extra-headers
    
    Eliminate two layers of nesting: fold one seq-let and one let* into a
    top-level pcase-let*
---
 vc-jj.el | 34 +++++++++++++++++-----------------
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/vc-jj.el b/vc-jj.el
index eb39aaca81..bb79c1daf9 100644
--- a/vc-jj.el
+++ b/vc-jj.el
@@ -106,9 +106,11 @@ If the current change is conflicted, divergent or hidden, 
also
 add a Status header.  (We do not check for emptiness of the
 current change since the user can see that via the list of files
 below the headers anyway.)"
-  (let* ((default-directory dir)
-         (info (process-lines "jj" "log" "--no-graph" "-r" "@" "-T"
-                              "concat(
+  (pcase-let* ((default-directory dir)
+               (`( ,change-id ,change-id-short ,commit-id ,commit-id-short
+                   ,description ,bookmarks ,conflict ,divergent ,hidden)
+                (process-lines "jj" "log" "--no-graph" "-r" "@" "-T"
+                               "concat(
 self.change_id().short(), \"\\n\",
 self.change_id().shortest(), \"\\n\",
 self.commit_id().short(), \"\\n\",
@@ -118,24 +120,21 @@ bookmarks.join(\",\"), \"\\n\",
 self.conflict(), \"\\n\",
 self.divergent(), \"\\n\",
 self.hidden(), \"\\n\"
-)")))
-    (seq-let [change-id change-id-short commit-id commit-id-short
-                        description bookmarks conflict divergent hidden]
-        info
-      (cl-flet ((fmt (key value &optional prefix)
+)"))
+               (status (concat
+                        (when (string= conflict "true") "(conflict)")
+                        (when (string= divergent "true") "(divergent)")
+                        (when (string= hidden "true") "(hidden)")))
+               (change-id-suffix (substring change-id (length 
change-id-short)))
+               (commit-id-suffix (substring commit-id (length 
commit-id-short))))
+    (cl-flet ((fmt (key value &optional prefix)
                   (concat
                    (propertize (format "% -11s: " key) 'face 'vc-dir-header)
                    ;; there is no header value emphasis face, so we
                    ;; use vc-dir-status-up-to-date for the prefix.
                    (when prefix (propertize prefix 'face 
'vc-dir-status-up-to-date))
                    (propertize value 'face 'vc-dir-header-value))))
-        (let ((status (concat
-                       (when (string= conflict "true") "(conflict)")
-                       (when (string= divergent "true") "(divergent)")
-                       (when (string= hidden "true") "(hidden)")))
-              (change-id-suffix (substring change-id (length change-id-short)))
-              (commit-id-suffix (substring commit-id (length 
commit-id-short))))
-          (string-join (seq-remove
+      (string-join (seq-remove
                         #'null
                         (list
                          (fmt "Description" (if (string= description "") "(no 
description set)" description))
@@ -143,11 +142,12 @@ self.hidden(), \"\\n\"
                          (fmt "Commit" commit-id-suffix commit-id-short)
                          (unless (string= bookmarks "") (fmt "Bookmarks" 
bookmarks))
                          (unless (string= status "")
-                           ;; open-code this line instead of adding a face 
parameter to `fmt'
+                           ;; open-code this line instead of adding a
+                           ;; `face' parameter to `fmt'
                            (concat
                             (propertize (format "% -11s: " "Status") 'face 
'vc-dir-header)
                             (propertize status 'face 
'vc-dir-status-warning)))))
-                       "\n"))))))
+                       "\n"))))
 
 (defun vc-jj-working-revision (file)
   (when-let ((default-directory (vc-jj-root file)))

Reply via email to