* How to programmatically use/edit data provided on capture
@ 2014-08-03 1:03 Marcin Antczak
2014-08-03 6:55 ` Richard Lawrence
0 siblings, 1 reply; 2+ messages in thread
From: Marcin Antczak @ 2014-08-03 1:03 UTC (permalink / raw)
To: emacs orgmode-mailinglist
Hi all!
I got capture template with prompts to collect some properties:
#+BEGIN_SRC
* TODO %\1 / Some task description
:PROPERTIES:
:NAME: %^{NAME}
:END:
#+END_SRC
My question is: How to get information on user input data to transform
this data before capture finalize.
For example: I got variable NAME and would like to use function like
(s-dashed-words string) from s.el to make sure that my NAME is valid and
converted to dashed syntax.
Let's say that my input is: New random project
I would like to have:
#+begin_src
* TODO new-random-project / Some task description
:PROPERTIES:
:NAME: "New random project"
:END:
#+end_src
While currently I got:
#+begin_src
* TODO New random project / Some task description
:PROPERTIES:
:NAME: "New random project"
:END:
#+end_src
I have been trying:
#+BEGIN_SRC
* TODO %(custom-dashify-function %\1) / Some task description
:PROPERTIES:
:NAME: %^{NAME}
:END:
#+END_SRC
or
#+BEGIN_SRC
* TODO %(custom-dashify-function %\\1) / Some task description
:PROPERTIES:
:NAME: %^{NAME}
:END:
#+END_SRC
But apparently function is executed before %\1 is replaced by my data
and it dodesn't work.
Could someone help me to write function that would get data I provided
for property NAME, convert using s-dashed-words and return to template
before finalize?
Marcin
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: How to programmatically use/edit data provided on capture
2014-08-03 1:03 How to programmatically use/edit data provided on capture Marcin Antczak
@ 2014-08-03 6:55 ` Richard Lawrence
0 siblings, 0 replies; 2+ messages in thread
From: Richard Lawrence @ 2014-08-03 6:55 UTC (permalink / raw)
To: emacs-orgmode
Hi Marcin,
Marcin Antczak <marcin.antczak@neutrico-themes.pl> writes:
> I got capture template with prompts to collect some properties:
>
> #+BEGIN_SRC
> * TODO %\1 / Some task description
> :PROPERTIES:
> :NAME: %^{NAME}
> :END:
> #+END_SRC
>
> My question is: How to get information on user input data to transform
> this data before capture finalize.
I too have wanted to do something like this, but I am not sure that it
is possible without hacking org-capture, because I don't think you can
hook into the template processing at an arbitrary point.
Is it really important that you transform the data *before* capture
finalize? If not, I think you could do this *during* capture finalize
by replacing, say, a pre-determined string "PUT-NAME-HERE" with the value of
(custom-dashify-function (org-entry-get (point) "NAME"))
You could do that from org-capture-prepare-finalize-hook, maybe. Would
that work for you? It has some limitations:
- it's only easy to recover data that was entered as properties or tags, not
arbitrary strings
- you can't continue to edit the capture buffer after doing this
processing, since the hook will only be called after you start
finalization
If you come up with a better solution, I'd like to hear about it! I
have scratched my head about this several times before, but I've never
come up with a satisfactory solution.
Good luck!
Best,
Richard
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-08-03 6:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-03 1:03 How to programmatically use/edit data provided on capture Marcin Antczak
2014-08-03 6:55 ` Richard Lawrence
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).