Closed Ypot closed 1 year ago
Could it be possible, in org-capture, to capitalize the text entered from a previous prompt?
It's certainly possible. You'd need to write a hook function to manipulate the text after entering it. This isn't really DOCT specific, but DOCT makes it much easier to manage these types of hooks. e.g.
(doct `("test" :keys "t"
:file "/tmp/test.org"
: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 ("* %^{CLIENT} _%^{Project}_ /%^{Description}/"
":PROPERTIES:"
":DIR: z:/! 2023/%\\1-%\\2-%\\3"
":END:")))
Testing below:
(progn
(require 'org-capture)
(let ((org-capture-templates
(doct `("test" :keys "t"
:file "/tmp/test.org"
: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 ("* %^{CLIENT} _%^{Project}_ /%^{Description}/"
":PROPERTIES:"
":DIR: z:/! 2023/%\\1-%\\2-%\\3"
":END:")))))
(org-capture nil "t")))
Filling out the template prompts with "testing" "one" "two" results in:
* testing _one_ /two/
:PROPERTIES:
:DIR: Z:/! 2023/TESTING-ONE-TWO
:END:
Hope that helps.
If you're having trouble (it looks like you deleted your comment, so maybe not) please be specific about how it doesn't work.
Firstly, was I used doct '(
insted of doct `(
Then, I have tried to mix existing org-capture-templates with the new doct template.
Now I am trying:
(setopt org-capture-templates
(doct-add-to org-capture-templates
`("Proyecto" :keys "y"
:type entry
:id "2023-02-09T12:06:10,23"
: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 ("* PROY %^{CLIENTE} _%^{OT}_ /%^{Descripción}/
:PROPERTIES:
:DIR: z:/! 2023/COMERCIAL/OFERTAS/%\\1-%\\2-%\\3
:END:
** Gestión del Proyecto
*** Contacto
*** Datos de partida
*** Reunión %\\1
*** SIG. Ofertar
*** T-AD Facturar")
'append)))
But it is unrelated with the opened issue.
Hi
I have been referred to this doct package, from de orgmode mail list.
I have read the documentation, but still I don't know how to achieve what I am trying: (I am not a programmer).
Could it be possible, in org-capture, to capitalize the text entered from a previous prompt?
Example: I have this part of an org-capture template:
I would like to know if it could be possible to “capitalize” the used data that I entered before. For example, instead of this:
I want to get this: (The 3rd line is “capitalized”)
Best regards