From cf8eaf89bc133a533deb0e47e69e4dab54287d2c Mon Sep 17 00:00:00 2001 From: Jaden Provost Maxwell-Comfort Date: Wed, 3 Apr 2024 13:02:44 -0700 Subject: [PATCH] Updated jm/org-roam-goto-today to be relative (next/prev) --- .emacs.d/functions.org | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.emacs.d/functions.org b/.emacs.d/functions.org index 8e24bfe..63efb3d 100644 --- a/.emacs.d/functions.org +++ b/.emacs.d/functions.org @@ -7,8 +7,15 @@ As of now, I haven't added anything here, though I do expect to start adding som Shortcut to goto todays org-roam dailies document. #+begin_src emacs-lisp +(defun jm/dailies-file-p () + (let ((file-base (file-name-base (buffer-file-name)))) + (s-matches-p "^[0-9]+-[0-9]+-[0-9]+$" file-base))) + (defun jm/org-roam-goto-day (days) - (let* ((rel-time (time-add (current-time) (days-to-time days))) + (let* ((base-time (if (and (jm/dailies-file-p) (not (eq days 0))) + (date-to-time (file-name-base (buffer-file-name))) + (current-time))) + (rel-time (time-add base-time (days-to-time days))) (path (format-time-string "%Y-%m-%d.org" rel-time)) (full-path (file-name-concat org-roam-directory "daily" path))) (if (file-exists-p full-path)