Skip to content

Instantly share code, notes, and snippets.

@SirensOfTitan
Created July 14, 2021 19:38
Show Gist options
  • Save SirensOfTitan/d7a9f0ec99204d3ee59778a2e847745f to your computer and use it in GitHub Desktop.
Save SirensOfTitan/d7a9f0ec99204d3ee59778a2e847745f to your computer and use it in GitHub Desktop.
Org-roam titles that denote daily
(defun sirensoftitan/org-roam--is-daily-note (path)
"Determine if note at PATH is a daily note."
(when org-roam-dailies-directory
(string-prefix-p
(expand-file-name org-roam-dailies-directory)
(expand-file-name path))))
(defun sirensoftitan/org-roam--map-title (item)
"Map ITEM to a local title name."
(let* ((file-path (nth 1 item))
(title (nth 0 item))
(is-daily-note (sirensoftitan/org-roam--is-daily-note file-path)))
(if is-daily-note (concat title " 📅") title)))
(defun sirensoftitan/org-roam--get-titles ()
"Return all distinct titles and aliases in the org-roam database."
(mapcar #'sirensoftitan/org-roam--map-title (org-roam-db-query [:select [title file]
:from nodes
:union
:select [alias ""]
:from aliases])))
(advice-add #'org-roam--get-titles :override #'sirensoftitan/org-roam--get-titles)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment