Org-roam and org-journal integration - auto recording of inserted link to new entry

Heya org-roamers,

I’m currently leaning into v2 after being off emacs for a while and deciding I needed it back.

I use both the org-roam-dailies (for my daily log file) but also org-journal for my private morning pages every day (cause perfer it private and ecnrpyted.). At the moment, I’ve got this triggering via the org-journal new entry function, buutttttttt… what i want is:

  1. triggers an insert link in roam and then that…
  2. Fires off the org-journal-new-entry
  3. so that I get a link to the new journal entry in org-roam under my “Morning Pages” daily template where I fired it off from

I have not been able to puzzle out how to do this (mostly due to poor lisp-fu) but imagine this is a trivial for the better emacs-er/lisp-ers.

Can anyone give me an idea of how that needs to be done to make the two programs work more seamlessly.
(so, I accmplish the same right now… manually… by copying the link to the headline in the org-journal file and then pasting that back in under the Morning Pages, but this should of course be automated.

Would love some help with this.
thanks!
Daryl.

If this is the reason, why not use only org-roam-dailies? Or org-journal only. Why combine?

I think I explained poorly. I use them for two separate concerns.

I use the roam functions to have a /dailies directory where I have a standard log template for each day. combining work and personal stuff, meeting notes, some meta data about the day etc.

Within that template I have a section that I would prefer to have a link to the encrypted yearly org-journal file which is basically my daily journal. What I am trying to do is somehow have an auto link inserted (as if it was org-roam-insert but have it fire off org journal new entry and create a heading (and standard format) for my private journal/morning pages etc.

Does that make a bit more sense? Apologies if I was unclear.

Thanks. I see.

You may not get a ready-to-paste code sample in this forum – your case is an intersection of org-roam-dailies and org-journal, and the person needs to be able to code and to engage in this forum… I don’t know how many are in this small intersection.

I use neither, so I can think of only something generic.

Idea 1

I would assume that your journal file name and heading title can be derived easily from today’s date – e.g. file name: “2022-journal.org”, heading title “2021-02-28”.
If this is the case, I believe you can use your dailies template and directly insert a link as part of the template:

;; Chaniging lines for readability
"#+title: %<%Y-%m-%d>/n
* journal /n
[[%<%Y-journal.org>*%<%Y%m%d>][Link to journal entry]]
"

Then you could create a custom interactive function that simply calls (org-journal-new-entry nil) and (org-roam-dailies-capture-capture) (or the command that you use) in sequence. They don’t need to be “integrated” by passing values from one to the other in the program.

Idea 2

If you cannot easily derive the file name and heading title from the date, you might like looking into org-journal-after-entry-create-hook. As org-journal-new-entry should move your cursor (point) to the journal buffer and the heading created, you should be able to get the file name (buffer-file-name) and the heading (e.g. org-heading-components) or point (point), and then construct a link.

Embarrassingly, I should have thought of Idea 1 as a simple hack around to what I wanted to get (as I have new journal entries hotkeyed), so I have templated my normal daily log format (as you cleverly pointed out) and then just trigger the daily entry with the keypress I was using before and it’s auto hooked up. Nice one.

I’ll work a little longer on the idea of having it create the link, trigger the new journal entry when I get a chance to do some lisp-fu.

Thanks for the very thougthtful answers. Appreciate it!

ciao and thanks for the help!
Daryl.