No Prompt for Templates using `org-roam-node-find`

Hello all. I’m trying to use org-roam templates and have the following configuration, but I cannot get org-roam-node-find to prompt for the different templates. I’ve tried some other individuals’ templates, in case I made an error, and have part of the SystemCrafters example in right now. I also tried adding in:

:init
(setq org-roam-v2-ack t)

but that did nothing. I was thinking maybe it needed to be specified, but I should already be using the latest org-roam. Creating a node works, but does the default without prompting for the other templates. There are no messages or warnings.

Could my templates not be working due to the org-roam-directory setup I have or is there something else that I have missed? The closest issue I could find to mine was this: Reddit - Dive into anything, but they were using Doom Emacs and I am using vanilla, so slightly different issue. I’ve also been trying to learn from similar setups from the following sources:
Where are templates defined
Capturing Notes Efficiently with Org Roam - System Crafters
Org-roam User Manual

Any help is much appreciated!

Current config:

(use-package org-roam
  :bind (("C-c n l" . org-roam-buffer-toggle)
         ("C-c n f" . org-roam-node-find)
         ("C-c n i" . org-roam-node-insert)
         :map org-mode-map
         ("C-M-i" . completion-at-point))
  :custom 
  (setq org-roam-complete-everywhere t) 
  (setq org-roam-capture-templates 
      '( 
          ("d" "default" plain "%?" 
          :if-new (file+head "%<%Y%m%d%H%M%S>-${slug}.org"
	  "#+title: ${title}\n")
	  :unnarrowed t)
          ("b" "book notes" plain
	  "\n* Source\n\nAuthor: %^{Author}\nTitle: ${title}\nYear: %^{Year}\n\n* Summary\n\n%?"
	  :if-new (file+head "%<%Y%m%d%H%M%S>-${slug}.org" "#+title: ${title}\n")
	  :unnarrowed t)
	  ("p" "project" plain "* Goals\n\n%?\n\n* Tasks\n\n** TODO Add initial tasks\n\n* Dates\n\n"
          :if-new (file+head "%<%Y%m%d%H%M%S>-${slug}.org" "#+title: ${title}\n#+filetags: Project")
          :unnarrowed t)
      ) 
  ) 
  :config
;; Change path for PC
  (cond ((string-equal (system-name) "weda")
	 (setq org-roam-directory "~/Syncthing/org-roam/"))
        ((string-equal (system-name) "tyr")
	 (setq org-roam-directory "~/Syncthing/org-roam/"))
        ((string-equal (system-name) "DESKTOP-FIS3P5B")
	 (setq org-roam-directory "c:/Users/Church/Documents/Syncthing/org-roam/"))) 

  (cond ((string-equal (system-name) "weda")
	 (setq org-roam-db-location "~/Syncthing/org-roam/org-roam.db"))
        ((string-equal (system-name) "tyr")
	 (setq org-roam-db-location "~/Syncthing/org-roam/org-roam.db"))
        ((string-equal (system-name) "DESKTOP-FIS3P5B")
	 (setq org-roam-db-location "c:/Users/Church/Documents/Syncthing/org-roam/org-roam.db"))) 
  
  (org-roam-setup))

Review the syntax of :custom of use-package. You cannot use setq there.

1 Like

A couple of terms I have learned, that others may run into in the future-

Source: GitHub - jwiegley/use-package: A use-package declaration for simplifying your .emacs

:config can be used to execute code after a package is loaded. This execution is deferred until after the autoload occurs.
:bind can be used to bind a key to that command.
:custom keyword allows customization of package custom variables.
Similar to :bind , you can use :mode and :interpreter to establish a deferred binding within the auto-mode-alist and interpreter-mode-alist variables. The specifier to either keyword can be a cons cell, a list of cons cells, or a string or regexp:

But a lot of the programming terminology is above my head right now.

I ended up haphazardly copying and pasting as follows:

(...

:config
 (setq org-roam-capture-templates 
      '( 
          ("d" "default" plain "%?" 
          :if-new (file+head "%<%Y%m%d%H%M%S>-${slug}.org"
	  "#+title: ${title}\n")
	  :unnarrowed t)
          ("b" "book notes" plain
	  "\n* Source\n\nAuthor: %^{Author}\nTitle: ${title}\nYear: %^{Year}\n\n* Summary\n\n%?"
	  :if-new (file+head "%<%Y%m%d%H%M%S>-${slug}.org" "#+title: ${title}\n")
	  :unnarrowed t)
	  ("p" "project" plain "* Goals\n\n%?\n\n* Tasks\n\n** TODO Add initial tasks\n\n* Dates\n\n"
          :if-new (file+head "%<%Y%m%d%H%M%S>-${slug}.org" "#+title: ${title}\n#+filetags: Project")
          :unnarrowed t)
      ) 
  ) 

(org-roam-setup))

and am now prompted to choose a template. I thought I knew why, but to be honest, I’m a bit confused as to why this works in my init.el under :config vs. Capturing Notes Efficiently with Org Roam - System Crafters, where they have added the template section under :custom.

I have found this post, which may explain it somewhat, at least the setq portion, but I will have to revisit later as I do not fully comprehend at the moment.

Thanks for your help again @nobiot.

If you look carefully at what System Crafters does for :custom, you will see that setq is not used. That’s the syntax.

From functional perspective, if you stick to note-taking with Org-roam, you can safely ignore the difference between :custom and :config. There is difference, and not relevant for Org-roam. Personally, I only learned the difference once I started to develop my own Emacs packages and took me a long time.

Thanks for the explanation. The thing that confused me, was that I tried both with and without the setq under :custom. But, like your own experience, it is probably just a matter of time and learning to pick up on these nuances.

I was able to create a somewhat complex template today that will help me with my workflow, so I very much appreciate your help.

1 Like