From dafe93397ae082eff584fd27762fbc0556067af6 Mon Sep 17 00:00:00 2001 From: Christian Cunningham Date: Wed, 12 Jun 2024 21:36:46 -0700 Subject: Generate Heading Table --- elchemy-personal.el | 64 ++++++++++++++++++++++++++++++++--------------------- 1 file changed, 39 insertions(+), 25 deletions(-) diff --git a/elchemy-personal.el b/elchemy-personal.el index 8d13bdd..ac99314 100644 --- a/elchemy-personal.el +++ b/elchemy-personal.el @@ -92,6 +92,23 @@ (other-window 1) (term TERM)) +(setq elchemy/dashboard/heading-columns 3 + elchemy/dashboard/heading-buttons '( + ("Open Local TODO" . (lambda (x) (elchemy/find-file "~/org/todo.org"))) + ("Open Remote TODO" . (lambda (x) (elchemy/find-file "/ssh:onid:todo.org"))) + ("Open Local Notes" . (lambda (x) (elchemy/find-file "~/org/notes.org"))) + ("Open Remote Notes" . (lambda (x) (elchemy/find-file "/ssh:onid:knowledge.org"))) + ("Open Terminal" . (lambda (x) (elchemy/term "/bin/zsh"))) + ("Open Scratch" . (lambda (x) + (when (one-window-p) + (split-window-right)) + (other-window 1) + (scratch-buffer))) + ("Testing" . (lambda (x) (elchemy/find-file "/ssh:onid:test.el"))) + ) + elchemy/dashboard/heading-max-length (apply #'max (mapcar #'(lambda (x) (length (car x))) elchemy/dashboard/heading-buttons)) + elchemy/dashboard/heading-padding 4) + (defun elchemy/create-dashboard () "Create the user dashboard" (interactive) @@ -106,21 +123,17 @@ (add-text-properties start (point) '(face (:height 4.0)))) (insert "\n\n") - (insert - (buttonize "Open Local TODO" (lambda (x) (elchemy/find-file "~/org/todo.org")))) - (insert " ") - (insert - (buttonize "Open Remote TODO" (lambda (x) (elchemy/find-file "/ssh:onid:todo.org")))) + (dotimes (i (length elchemy/dashboard/heading-buttons)) + (let* ((button (nth i elchemy/dashboard/heading-buttons)) + (title (car button)) + (callback (cdr button))) + (insert (buttonize title callback)) + (if (eq (% (+ i 1) elchemy/dashboard/heading-columns) 0) + (insert "\n") + (insert (format (concat "%-" (format "%d" (+ (- elchemy/dashboard/heading-max-length (length title)) elchemy/dashboard/heading-padding)) "s") " "))))) + (unless (eq (% (length elchemy/dashboard/heading-buttons) elchemy/dashboard/heading-columns) 0) + (insert "\n")) (insert "\n") - (insert - (buttonize "Open Local Notes" (lambda (x) (elchemy/find-file "~/org/notes.org")))) - (insert " ") - (insert - (buttonize "Open Remote Notes" (lambda (x) (elchemy/find-file "/ssh:onid:knowledge.org")))) - (insert "\n\n") - (insert - (buttonize "Open Terminal (zsh)" (lambda (x) (elchemy/term "/bin/zsh")))) - (insert "\n\n") (insert (buttonize "Open Personal Configuration" (lambda (x) (elchemy/find-file "~/.elchemy/elchemy-personal.el")))) (insert "\n\n") @@ -148,7 +161,7 @@ (insert "F3 ~ Record Macro\n") (insert "F4 ~ Play Macro\n") (insert "M-0 F4 ~ Play Macro until failure\n") - (insert "M-l ~ Locwercase following word\n") + (insert "M-l ~ Lowercase following word\n") (insert "M-u ~ Uppercase following word\n") (insert "M-c ~ Capitalize following word\n") (insert "M-g w ~ Jump to word\n") @@ -158,6 +171,7 @@ (insert "C-M-n ~ Move forward one balanced expression\n") (insert "C-M-p ~ Move forward one balanced expression\n") (setq header-line-format nil) + (button-mode +1) (read-only-mode +1)))) (elchemy/create-dashboard) @@ -173,16 +187,16 @@ (add-to-list 'face-remapping-alist '(default (:background "gray90"))))) (setq-default header-line-format '( - (:propertize "♥︎" face (:foreground "red")) - " " - (:propertize "ELCHEMY" face (:weight bold)) - " " - (:propertize "♦︎" face (:foreground "red")) - " " - (:propertize "%b" face (:slant italic)) - " ♣︎ " - (:eval mode-name) - " ♠︎")) + (:propertize "♥︎" face (:foreground "red")) + " " + (:propertize "ELCHEMY" face (:weight bold)) + " " + (:propertize "♦︎" face (:foreground "red")) + " " + (:propertize "%b" face (:slant italic)) + " ♣︎ " + (:eval mode-name) + " ♠︎")) (load "extras/guile-interaction.el") (require 'guile-interaction) -- cgit v1.2.1