summaryrefslogtreecommitdiff
path: root/elchemy-functions.el
diff options
context:
space:
mode:
authorChristian Cunningham <cc@localhost>2024-06-14 16:33:23 -0700
committerChristian Cunningham <cc@localhost>2024-06-14 16:33:23 -0700
commit3f3396f1877c6027a5516856030888fee97bfa69 (patch)
treec4482e02218b796abc040a759d8978469587cdbb /elchemy-functions.el
parent6cb373a2c1d60fadfd4589b247ca324148ca105b (diff)
Consolidate Button Layouts
Diffstat (limited to 'elchemy-functions.el')
-rw-r--r--elchemy-functions.el24
1 files changed, 22 insertions, 2 deletions
diff --git a/elchemy-functions.el b/elchemy-functions.el
index 7a27356..57663b2 100644
--- a/elchemy-functions.el
+++ b/elchemy-functions.el
@@ -91,7 +91,27 @@ Returns '((:raw-value . <Heading Text>) (:level <Org Heading Level>) (:priority
"Format a processed agenda to a string:
[PRIORITY] TODO-KEYWORD: HEADING ~ SCHEDULED"
(apply #'concat (mapcar #'(lambda (x)
- (concat (format "[%c] " (elchemy/format-priority (cdr (assoc :priority x)))) (cdr (assoc :todo-keyword x)) ": " (cdr (assoc :raw-value x)) " ~ " (cdr (assoc :scheduled x)) "\n"))
- agenda-list)))
+ (concat (format "[%c] " (elchemy/format-priority (cdr (assoc :priority x)))) (cdr (assoc :todo-keyword x)) ": " (cdr (assoc :raw-value x)) " ~ " (cdr (assoc :scheduled x)) "\n"))
+ agenda-list)))
+
+(defun elchemy/display-tabular-button-alist (ALIST &optional columns padding)
+ "Display a Button Alist as a Table"
+ (unless columns
+ (setq columns 1))
+ (unless padding
+ (setq padding 0))
+ (let* ((colwidth (+ padding (apply 'max (mapcar #'(lambda (x) (length (car x))) ALIST)))))
+ (dotimes (i (length ALIST))
+ (let* ((elem (nth i ALIST))
+ (name (car elem))
+ (callback (cdr elem)))
+ (insert (buttonize name callback))
+ (message "%s\n" columns)
+ (if (eq (% (+ i 1) columns) 0)
+ (insert "\n")
+ (insert (format (concat "%" (format "%ds" (- colwidth (length name)))) " ")))
+ ))
+ (unless (eq (% (length ALIST) columns) 0)
+ (insert "\n"))))
(provide 'elchemy-functions)