progfolio / doct

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

I am lossing the underscore #39

Closed Ypot closed 4 months ago

Ypot commented 4 months 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 4 months 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 4 months 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.