emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/taxy 8757b52 10/42: Add: (taxy-magit-section-format-hea


From: ELPA Syncer
Subject: [elpa] externals/taxy 8757b52 10/42: Add: (taxy-magit-section-format-header)
Date: Wed, 15 Sep 2021 12:57:27 -0400 (EDT)

branch: externals/taxy
commit 8757b529025eb0eee876889620da36214c61b6b0
Author: Adam Porter <adam@alphapapa.net>
Commit: Adam Porter <adam@alphapapa.net>

    Add: (taxy-magit-section-format-header)
---
 taxy-magit-section.el | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/taxy-magit-section.el b/taxy-magit-section.el
index 85af4d3..3e7c57a 100644
--- a/taxy-magit-section.el
+++ b/taxy-magit-section.el
@@ -291,6 +291,27 @@ the items' values for each column."
                  table)
         (cons table column-sizes)))))
 
+(defun taxy-magit-section-format-header (column-sizes formatters)
+  "Return header string for COLUMN-SIZES and FORMATTERS.
+COLUMN-SIZES should be the CDR of the cell returned by
+`taxy-magit-section-format-items'.  FORMATTERS should be the
+variable passed to that function, which see."
+  (let* ((first-column-name (caar column-sizes))
+        (first-column-alist (alist-get first-column-name formatters nil nil 
#'equal))
+        (first-column-align (pcase-exhaustive (alist-get 'align 
first-column-alist)
+                              ((or `nil 'left) "-")
+                              ('right ""))))
+    (concat (format (format " %%%s%ss"
+                           first-column-align (cdar column-sizes))
+                   (caar column-sizes))
+           (cl-loop for (name . size) in (cdr column-sizes)
+                    for column-alist = (alist-get name formatters nil nil 
#'equal)
+                    for align = (pcase-exhaustive (alist-get 'align 
column-alist)
+                                  ((or `nil 'left) "-")
+                                  ('right ""))
+                    for spec = (format " %%%s%ss" align size)
+                    concat (format spec name)))))
+
 ;;;; Footer
 
 (provide 'taxy-magit-section)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]