From 3f3396f1877c6027a5516856030888fee97bfa69 Mon Sep 17 00:00:00 2001 From: Christian Cunningham Date: Fri, 14 Jun 2024 16:33:23 -0700 Subject: Consolidate Button Layouts --- elchemy-functions.el | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'elchemy-functions.el') 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 . ) (: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) -- cgit v1.2.1