If you are in a buffer: 2022-12-28.org, how you’re going to switch to day 2022-12-27.org or to day 2022-12-29.org? I used org-roam-dailies-goto-date to do such a switch, but the default selection is based on the current date, not the buffer the user is currently visiting.

The following snippet can help you to navigate through yesterday’s or tomorrow based on the current daily note.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
(defun wr/org-roam-dailies-capture-current-daily-date-yesterday (&optional goto keys)
  ""
  (interactive "P")
  (if (org-roam-dailies--daily-note-p)
      (let* ((ts-default-format "%Y-%m-%d")
             (current-date-for-this-buffer (buffer-file-name))
             (yesterday-date (ts-format (ts-adjust 'day -1 (ts-parse (file-name-sans-extension
                                                                      (file-name-nondirectory current-date-for-this-buffer)))))))
        (org-roam-dailies--capture (time-convert  (ts-unix (ts-parse yesterday-date))) t keys))
    (message "Not in a daily buffer")))

(defun wr/org-roam-dailies-capture-current-daily-date-tomorrow (&optional goto keys)
  ""
  (interactive "P")
  (if (org-roam-dailies--daily-note-p)
      (let* ((ts-default-format "%Y-%m-%d")
             (current-date-for-this-buffer (buffer-file-name))
             (tomorrow-date (ts-format (ts-adjust 'day +1 (ts-parse (file-name-sans-extension
                                                                      (file-name-nondirectory current-date-for-this-buffer)))))))
        (org-roam-dailies--capture (time-convert  (ts-unix (ts-parse tomorrow-date))) t keys))
    (message "Not in a daily buffer")))