progfolio / doct

DOCT: Declarative Org Capture Templates for Emacs
GNU General Public License v3.0
375 stars 8 forks source link

I am lossing the underscore #39

Closed Ypot closed 1 month ago

Ypot commented 1 month ago

Describe the problem

When I use _ before the ‘%\N’ (the text entered at the Nth ‘%^{PROMPT}’) the _ dissapears.

Directions to reproduce

(setopt org-capture-templates
  (doct-add-to org-capture-templates
               `("Project" :keys "j"
                 :type entry
                 :id "2024"
                 :prepend t
                 :immediate-finish t
                 :jump-to-captured t
                 :hook
                 ,(defun +org-capture-captialize-dir-prop ()
                    (save-excursion
                      (goto-char (point-min))
                      (when (re-search-forward "^:DIR:" nil t)
                        (upcase-region (line-beginning-position) (line-end-position)))))
                 :template ("* PROJ %^{1 CLIENT}-_%^{2 OT}_
$Contract_%\\2 := 10000 EUR$))))

Instead of "Contract2 OT" it writes down "Contract2 OT", the `` is missing.

Version information

progfolio commented 1 month ago

I'm unable to reproduce on my end. Doss the issue occur if you evaluate the following in your scratch buffer?

(progn
  (require 'org-capture)
  (let ((org-capture-templates
         '(("t" "test" entry (file "")
          "* %^{1 client}-%^{2 ot}\n$Contract_%\\2"
         :immediate-finish t
         :jump-to-captured t)))) 
    (org-capture nil "t"))) 

Note your example is missing a backslash before the "2". elisp interprets a single backslash as an escape character in a string literal. "\2" vs "\\2".

progfolio commented 1 month ago

I'll consider this closed for now. Feel free to comment if you're still having the issue and you are sure it's related to doct. Thanks.