2024-07-10 08:34:45 +00:00
|
|
|
;;
|
|
|
|
;; Helper functions for the dashboard
|
|
|
|
;;
|
|
|
|
|
2024-07-12 23:32:01 +00:00
|
|
|
(defun whomp/dashboard-insert-logo-title (banner)
|
2024-07-10 08:52:22 +00:00
|
|
|
"Insert BANNER into the dashboard buffer.
|
|
|
|
BANNER can be a single string, which will be centered, or a list of strings,
|
|
|
|
which will be displayed with line breaks between them."
|
2024-07-10 08:34:45 +00:00
|
|
|
(insert "\n")
|
|
|
|
;; if banner is a single string, display it in the center
|
|
|
|
;; else if it is a list of strings, display them with line breaks
|
|
|
|
(if (stringp banner)
|
|
|
|
(insert (propertize banner 'face 'dashboard-banner-logo-title))
|
|
|
|
(dolist (line banner)
|
|
|
|
(insert (propertize line 'face 'dashboard-banner-logo-title))
|
|
|
|
(insert "\n"))))
|
|
|
|
|
2024-07-12 23:32:01 +00:00
|
|
|
(defun whomp/dashboard-build-logo-title (lst)
|
2024-07-10 08:52:22 +00:00
|
|
|
"Build a list of strings from LST to display as the banner.
|
|
|
|
LST is reversed and concatenated into a single string with line breaks."
|
2024-07-10 08:34:45 +00:00
|
|
|
(mapconcat 'identity (reverse lst) "\n"))
|
|
|
|
|
2024-07-12 23:32:01 +00:00
|
|
|
(defun whomp/random-string-from-list (strings)
|
2024-07-10 08:52:22 +00:00
|
|
|
"Return a random string from STRINGS."
|
2024-07-10 08:34:45 +00:00
|
|
|
(let ((index (random (length strings))))
|
|
|
|
(nth index strings)))
|
|
|
|
|
|
|
|
;;
|
|
|
|
;; Helper functions for general use
|
|
|
|
;;
|
|
|
|
|
2024-07-10 08:52:22 +00:00
|
|
|
;; Function to create a directory if it doesn't exist
|
2024-07-12 23:32:01 +00:00
|
|
|
(defun whomp/ensure-directory-exists (dir)
|
2024-07-10 08:52:22 +00:00
|
|
|
"Ensure the directory DIR exists. If not, create it."
|
|
|
|
(unless (file-directory-p dir)
|
2024-07-10 09:33:56 +00:00
|
|
|
(message "Creating missing directory: %s" dir)
|
2024-07-10 08:52:22 +00:00
|
|
|
(make-directory dir t)))
|
|
|
|
|
2024-07-10 08:34:45 +00:00
|
|
|
;; Function to list all files in a directory with a given extension
|
2024-07-12 23:32:01 +00:00
|
|
|
(defun whomp/list-files-with-extension (dir extension)
|
2024-07-10 08:34:45 +00:00
|
|
|
"Recursively list all files in DIR with the given EXTENSION, suitable for org-agenda-files."
|
|
|
|
(let ((files '()))
|
|
|
|
(dolist (file (directory-files-recursively dir (concat "\\." extension "\\'")))
|
|
|
|
(push file files))
|
|
|
|
(nreverse files)))
|
|
|
|
|
|
|
|
;;
|
|
|
|
;; Helper functions for org mode
|
|
|
|
;;
|
|
|
|
|
|
|
|
;; Function to get a unique filename for Org-capture
|
2024-07-12 23:32:01 +00:00
|
|
|
(defun whomp/org-capture-get-unique-filename ()
|
2024-07-10 08:34:45 +00:00
|
|
|
"Generate a unique filename for Org-capture."
|
|
|
|
(let ((filename (format "~/.org-agenda/syncup__issue__%s.org" (format-time-string "%Y%m%d%H%M%S"))))
|
|
|
|
(message "Inside function: Generated filename: %s" filename)
|
|
|
|
filename))
|
|
|
|
|
|
|
|
;; Function to update org-agenda-files
|
2024-07-12 23:32:01 +00:00
|
|
|
(defun whomp/org-agenda-files-update ()
|
2024-07-10 08:52:22 +00:00
|
|
|
"Update the `org-agenda-files` variable.
|
|
|
|
This function sets `org-agenda-files` and `org-timeblock-files` to the list of
|
|
|
|
all `.org` files in the `~/.org-agenda` directory, and sets
|
2024-12-04 12:47:35 +00:00
|
|
|
`org-timeblock-inbox-file` to `~/org/agenda.org`."
|
|
|
|
(setq org-agenda-files (whomp/list-files-with-extension "~/org" "org"))
|
|
|
|
(setq org-timeblock-files (whomp/list-files-with-extension "~/org" "org"))
|
|
|
|
(setq org-timeblock-inbox-file "~/org/agenda.org"))
|
2024-07-10 08:34:45 +00:00
|
|
|
|
2024-07-15 21:06:52 +00:00
|
|
|
;; Function to provide for creating files
|
|
|
|
(defun whomp/ensure-file-exists (file-path)
|
|
|
|
"Touch a file to existence."
|
|
|
|
(shell-command (concat "touch " file-path)))
|
|
|
|
|
2024-07-10 08:34:45 +00:00
|
|
|
|
2024-07-12 23:32:01 +00:00
|
|
|
(message "W.H.O.M.P. Loaded helper function library.")
|
|
|
|
(provide 'whomp-helpers)
|
|
|
|
;;; whomp-helpers.el ends here
|