0

I have following config for my org-roam:

(use-package org-roam
  :ensure t
  :init
  (setq org-roam-v2-ack t)
  :custom
  (org-roam-directory "~/roamnotes")
  (org-roam-completion-everywhere t)
  
  (org-roam-capture-templates
   '(("d" "Default" plain
      "%?"
      :if-new (file+head
               "%<%Y%m%d%H%M%S>-${slug}.org" 
               "#+title: ${title}\n#+filetags: :nohtmlexport:\n#+date: %U\n#+auto_tangle: nil") ;; I want to split this long line
      :unnarrowed t)
     ))
  :config
  (org-roam-setup)
  (require 'org-roam-dailies)
  (org-roam-db-autosync-mode)
  )

What I want to do: To split long line: "#+title: ${title}\n#+filetags: :nohtmlexport:\n#+date: %U\n#+auto_tangle: nil".


What I've tried so far I: This works without an error, but stylistically looks very bad. (Just bad indent)

  ...
  ...
  (org-roam-capture-templates
   '(("d" "Default" plain
      "%?"
      :if-new (file+head
               "%<%Y%m%d%H%M%S>-${slug}.org"
               "#+title: ${title}
#+filetags: :nohtmlexport:
#+date: %U
#+auto_tangle: nil")
      :unnarrowed t)
     ))
  ...
  ...
  )

What I've tried so far II: This stylistically desirable, but this gets an error:

  (org-roam-capture-templates
   '(("d" "Default" plain
      "%?"
      :if-new (file+head
               "%<%Y%m%d%H%M%S>-${slug}.org"
               (concat
                "#+title: ${title}\n"
                "#+filetags: :nohtmlexport:\n"
                "#+date: %U\n"
                "#+auto_tangle: nil"
                )
               )
      :unnarrowed t)
     ))

org-roam-capture--fill-template: Wrong type argument: char-or-string-p, (concat "#+title: ${title}
" "#+filetags: :nohtmlexport:
" "#+date: %U
" "#+auto_tangle: nil")

Question:

  • Why I can't use concat inside org-roam-capture-templates as written in above?
  • If it's possible to use concat (or anything else), how to implement it?
Garid
  • 545
  • 1
  • 13
  • 1
    This is a (frequent) duplicate and the answer is: Use `backquote` and `comma` to evaluate part of the (now completely unevaluated because it is quoted) expression. – NickD May 02 '23 at 12:28
  • Did you mean `\`(file+head "...org" ,(concat "line1\n" "line2\n" "line3\n"))` ? Am I doing correct? This produces error `org-roam-capture--prepare-buffer: Wrong type argument: integer-or-marker-p, nil` – Garid May 02 '23 at 12:43
  • 1
    No, actually: the backquote should replace the quote in front of the whole list. The comma is correctly placed. The quote says: don't evaluate anything in the following expression; the backquote says: don't evaluate anything in the following expression except evaluate any expression that is preceded by a comma. There is an additional "advanced" wrinkle with `,@` which you can read about in the Emacs Lisp Ref doc. – NickD May 02 '23 at 13:37
  • Could you tell me where should I put backquote? I still couldn't manage it to put correct place, I've tried many possible to positions – Garid May 02 '23 at 17:16
  • 1
    Just replace the quote: `...'(("d" "Default" plain ...` with a backquote: ``...`(("d" "Default" plain ...``. – NickD May 02 '23 at 18:05
  • 1
    Ohhhhhhh thanks – Garid May 02 '23 at 18:57

0 Answers0