Link to your previous org dailies

A little background!

I use org roam for dailes (although I am still on Obsidian for most of my notes!). My dailes look scattered, see most of the red nodes!

Org Roam UI showing Connections between nodes

I would like all my dailes to be connected to each other, as a train, however this is harder than it sounds…

Option 1: Naivly link to yesterday’s daily

Every day, link to yesterday’s note, which should be very easily automated in templates (see org templates) with a little bit of elisp. However, this assumes 100% consistency rate with logging dailies! A single missed day will break the chain.

Option 2: Link manually to yesterday’s note each time

Why are you using emacs if you consider this option? Really you do things manually every day? ಠಿ_ಠ

Is it worth the time XKCD

Lets assume you do it daily, and it only takes 5 seconds (You are superfast). You will end up wasting two hours over 5 years!! Why waste 2 hours over 5 years when you can waste them in one go now :)? Jokes aside it won’t take you more than 1 minute to get it working, provided you have a working template.

Option 3: Automate!

I blabbered a lot, where I could have been straight to the point

This little snippet reads current day, and checks if yesterday exists, and links to it!

(let* ((todays-daily (format-time-string "%Y-%m-%d"))
       (dailies (org-roam-dailies--list-files))
       (n -1)
       (dailies-filenames (mapcar 'file-name-base dailies))
       (position
        (or (cl-position-if (lambda (candidate)
                              (string= todays-daily candidate))
                            dailies-filenames)
            (length dailies-filenames)))
       note)
  (pcase n
    ((pred (natnump))
     (when (eq position (- (length dailies) 1))
       (user-error "Already at newest note")))
    ((pred (integerp))
     (when (eq position 0)
       (user-error "Already at oldest note"))))
  (setq note (nth (+ position n) dailies-filenames))
  ;; [[id:UUID][filename!]]
  (or (when-let ((node (org-roam-node-from-title-or-alias note)))
        (concat "[[id:" (org-roam-node-id node) "][" note "]]"))
      ;; roam:2025-03-22
      (concat "roam:" note)))

Include in your org template as follows:

* Meta
- Previous Note: %(let* ... ) ; Include the Snippet here!

I will try to provide with an updated on how my dailies looks like after a few years :)