nobiot / md-roam

Use Org-roam with markdown files by adding Md-roam as a plug-in. Mix org and markdown files in a single Org-roam database.
GNU General Public License v3.0
333 stars 15 forks source link

Cursor placed at the start of the last header line prevents use of templates #67

Closed iod-ine closed 2 years ago

iod-ine commented 2 years ago

When a new note is created, the cursor is placed at the beginning of the line with the last entry in the YAML header. With the default config for a template markdown note, which in my Doom setup looks like

(setq org-roam-capture-templates
      '(("d" "default" plain
         ""
         :target (file+head "${slug}.md"
                            "---\ntitle: ${title}\nid: %<%Y-%m-%dT%H%M%S>\ncategory: #draft\n---\n")
         :immediate-finish t
         :unnarrowed t)))

the new note is opened like this:

Screen Shot 2022-07-07 at 21 02 12

When I try to use a template instead of an empty string either using a single string

(setq org-roam-capture-templates
      '(("d" "default" plain
         "- `Relevant notes`\n\n# ${title}\n\n%?\n\n*Reference (Author, Date)*"
         :target (file+head "${slug}.md"
                            "---\ntitle: ${title}\nid: %<%Y-%m-%dT%H%M%S>\ncategory: #draft\n---\n")
         :immediate-finish t
         :unnarrowed t)))

or a template file with the same content as that string

(setq org-roam-capture-templates
      '(("d" "default" plain
         (file "~/Documents/Slip-box/Templates/Zettel.md") 
         :target (file+head "${slug}.md"
                            "---\ntitle: ${title}\nid: %<%Y-%m-%dT%H%M%S>\ncategory: #draft\n---\n")
         :immediate-finish t
         :unnarrowed t)))

the content is inserted at this cursor position like this:

Screen Shot 2022-07-07 at 20 31 37

Note how within this incorrectly inserted template the cursor is positioned as expected at the %?.

With plain org-roam templates defined like this work fine. Sorry if this is a misconfiguration on my part, I am very new to Emacs.

iod-ine commented 2 years ago

I have just realized that the problem is in the :immediate-finish t.

nobiot commented 2 years ago

So problem solved for you? It’s not part of Md-roam and I don’t have a problem. Not sure what I can do to help you…

iod-ine commented 2 years ago

@nobiot It's not, but I've opted to change my workflow to exclude the situations where it can occur. And it's 100% not on the md-roam side, so I'll close this. Sorry and thank you!