From 12ea68ab72a34daf0f554a73867207f51cdbd1e6 Mon Sep 17 00:00:00 2001 From: Christian Cunningham Date: Sat, 8 Jun 2024 16:18:40 -0700 Subject: Renewed Dashboard Create a dashboard with Elisp buttons rather than an org-buffer. --- elchemy-personal.el | 84 +++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 78 insertions(+), 6 deletions(-) (limited to 'elchemy-personal.el') diff --git a/elchemy-personal.el b/elchemy-personal.el index cddaaa0..b609a8d 100644 --- a/elchemy-personal.el +++ b/elchemy-personal.el @@ -62,12 +62,84 @@ (setq sentence-end-double-space nil) -(setq nm/dashboard-file nil) -(setq nm/dashboard-file "~/.elchemy/dashboard.org") -(when nm/dashboard-file - (find-file-read-only nm/dashboard-file) - (switch-to-buffer (file-name-nondirectory nm/dashboard-file)) - (rename-buffer "*Dashboard*")) +(defun elchemy/read-alist-file (file-path) + "Read a file where each line is an alist of the form (name . location), returning a list of these pairs." + (interactive "fEnter file path: ") + (let (result) + (with-temp-buffer + (insert-file-contents file-path) + (goto-char (point-min)) + (while (not (eobp)) + (let ((line (buffer-substring-no-properties (line-beginning-position) (line-end-position)))) + (when (not (string-blank-p line)) + (let ((pair (car (read-from-string line)))) + (push pair result)))) + (forward-line 1))) + (reverse result))) +(defun elchemy/create-dashboard () + "Create the user dashboard" + (interactive) + (let ((buffer (get-buffer-create "*Dashboard*"))) + (switch-to-buffer buffer) + (unless buffer-read-only + (when (file-exists-p "~/.elchemy/assets/splash.png") + (insert-image (create-image "~/.elchemy/assets/splash.png" nil nil :scale 0.5)) + (insert "\n")) + (let ((start (point))) + (insert "Elchemy Dashboard") + (add-text-properties start (point) + '(face (:height 4.0)))) + (insert "\n\n") + (insert + (buttonize "Open Local TODO" (lambda (x) (find-file "~/org/todo.org")))) + (insert " ") + (insert + (buttonize "Open Remote TODO" (lambda (x) (find-file "/ssh:onid:todo.org")))) + (insert "\n") + (insert + (buttonize "Open Local Notes" (lambda (x) (find-file "~/org/notes.org")))) + (insert " ") + (insert + (buttonize "Open Remote Notes" (lambda (x) (find-file "/ssh:onid:knowledge.org")))) + (insert "\n\n") + (insert + (buttonize "Open Terminal (zsh)" (lambda (x) (term "/bin/zsh")))) + (insert "\n\n") + (insert + (buttonize "Open Personal Configuration" (lambda (x) (find-file "~/.elchemy/elchemy-personal.el")))) + (insert "\n\n") + (when (file-exists-p "~/.elchemy/projects") + (let ((start (point))) + (insert "Projects") + (add-text-properties start (point) + '(face (:height 1.5)))) + (insert "\n") + (mapcar #'(lambda (x) (insert (buttonize (car x) (lambda (y) (find-file (cdr x)))) "\n")) (elchemy/read-alist-file "~/.elchemy/projects")) + (insert "\n")) + (let ((start (point))) + (insert "Command Reference") + (add-text-properties start (point) + '(face (:height 1.5)))) + (insert "\n") + (insert "C-/ ~ Undo\n") + (insert "C-x n n ~ Narrow\n") + (insert "C-x n w ~ Widen\n") + (insert "M-% ~ Query Replace\n") + (insert "C-M-s ~ Regex Search\n") + (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-u ~ Uppercase following word\n") + (insert "M-c ~ Capitalize following word\n") + (insert "M-g w ~ Jump to word\n") + (insert "M-g l ~ Jump to line\n") + (insert "C-x C-l ~ Lowercase Region\n") + (insert "C-x C-u ~ Uppercase Region\n") + (insert "C-M-n ~ Move forward one balanced expression\n") + (insert "C-M-p ~ Move forward one balanced expression\n") + (read-only-mode +1)))) +(elchemy/create-dashboard) (add-to-list 'org-agenda-files "/ssh:onid:todo.org") (add-to-list 'org-capture-templates '("o" "OSU Todo" entry (file+headline "/ssh:onid:todo.org" "Imported") -- cgit v1.2.1