[Solved] Org-roam-dailies-goto-today as my initial buffer choice?

Hi all, I did some digging into Roam Research and noticed that they have the “daily for today” as the default launch page. I like this idea but am having some trouble reimplementing it in (doom) emacs.

Specifically, I have the following at the end of my config.el:

(require 'org-roam)
(require 'org-roam-dailies)
(setq initial-buffer-choice (lambda () (org-roam-dailies-goto-today)))

But I get the following error:

custom-initialize-reset: Value returned by ‘initial-buffer-choice’ is not a live buffer: nil

Would anyone be tell me how to do this or how to interpret this error message? I am not exactly sure how to fix this.

oh hey! actually, this works! I guess I had to disable my initial dashboard package. One hiccup is that I am always prompted for a template selection, which I would like to default. If someone had pointers here, this would be appreciated.

And again figured out this issue. org-roam-dailies requires an initial template to get the associated file if multiple templates exist. See org-roam-dailes-find-date deviates to "Select a capture template" · Issue #1354 · org-roam/org-roam · GitHub

This PR addresses a larger concern of “how to deal with a dynamic file lookup” but since I am only interested in a static lookup of a specific template, the proposed workaround is a bit of an overkill:

 (defun with-first-dailies-capture-template (dailies-find-function &rest args)
   "Temporarily shadow org-roam-dailies-capture-templates with only
its first entry when calling DAILIES-FIND-FUNCTION to prevent
template-select menu from showing."
   (let ((org-roam-dailies-capture-templates
          (list (car org-roam-dailies-capture-templates))))
     (apply dailies-find-function args)))

 ;; ADD advice to only use first dailies template for all dailies find functions
 (advice-add #'org-roam-dailies-find-today :around #'with-first-dailies-capture-template)
 (advice-add #'org-roam-dailies-find-date :around #'with-first-dailies-capture-template)
 (advice-add #'org-roam-dailies-find-tomorrow :around #'with-first-dailies-capture-template)
 (advice-add #'org-roam-dailies-find-yesterday :around #'with-first-dailies-capture-template)

Although, specifically, I needed to add (advice-add #'org-roam-dailies-goto-today :around #'with-first-dailies-capture-template).

1 Like

@stites
This is great that you have solved your own issue like this.
Building on your solution, it seems to be possible to simplify it like this:

(defun my/daily-today ()
  (interactive)
  (let ((org-roam-dailies-capture-templates
         (list (car org-roam-dailies-capture-templates))))
    (org-roam-dailies-capture-today)))

Lightly tested to work on my end – I don’t use Doom so that may require your way with advice :around.
Just some ideas if you should prefer to avoid advice.

Haha, yeah, I was trying not to overload my own thread, I ended up going with:

  (defun my/initial-buffer-choice ()
    (with-first-dailies-capture-template #'org-roam-dailies-goto-today))

  (setq initial-buffer-choice #'my/initial-buffer-choice)

And just made a note that with-first-dailies-capture-template is directly copied from the PR.

Thank you @nobiot !

1 Like