From: Karl Voit <devnull@Karl-Voit.at>
To: emacs-orgmode@gnu.org
Subject: Advanced capture template using Elisp functions: void-function/void-variable
Date: Mon, 9 May 2016 15:40:52 +0200 [thread overview]
Message-ID: <2016-05-09T15-13-42@devnull.Karl-Voit.at> (raw)
Hi!
I came across this great blog post[1] that introduced me to the idea
of including Elisp functions to capture templates. With this trick,
it is possible to re-use some user-entry.
So far so good. However, when I am using this capture definition, I end up with
lots of "void-function" and "void-variable". Probably I have an escaping issue.
Do you have an idea how to fix my error(s)?
The whole story: (sorry for some long lines)
I took David's code and renamed according my name schema:
,----
| (defvar my-capture-promt-history nil
| "History of prompt answers for org capture.")
| (defun my-capture-prompt (prompt variable)
| "PROMPT for string, save it to VARIABLE and insert it."
| (make-local-variable variable)
| (set variable (read-string (concat prompt ": ") nil my-capture-promt-history)))
| (defun my-capture-insert (variable)
| "Insert content of VARIABLE."
| (symbol-value variable))
| (defun my-capture-optional (what text)
| "Ask user to include WHAT. If user agrees return TEXT."
| (when (y-or-n-p (concat "Include " what "?"))
| text))
`----
Then I created a variable holding the complex template string:
,----
| (setq my-capture-template-r6story "** TODO [[IPD:%(my-capture-promt \"IPD number\" 'my-ipd)]] %(my-capture-promt \"Story title\" 'my-title) [1/11] :US_%(my-capture-promt \"Short title\" 'my-short-title):
| :PROPERTIES:
| :CREATED: [%(format-time-string \"%Y-%m-%d %a %H:%M\")]
| :ID: %(format-time-string \"%Y-%m-%d\")-Story-%(my-capture-insert 'my-short-title)
| :END:
|
| | *IPD* | *Confluence* | *Champ* |
| | [[IPD:%(my-capture-insert 'my-ipd)][%(my-capture-insert 'my-ipd)]] | %(my-capture-insert 'my-title) | |
|
| [...]
| ")
|
`----
,----[ my capture template definition ]
| (setq org-capture-templates
| `(
| ("u" "Userstory" entry (file+headline "~/stories.org" "New Stories")
| ,my-capture-template-r6story :empty-lines 1)
| ))
`----
So far so good. However, when I am using this capture definition, I end up with
lots of "void-function" and "void-variable":
,----
| * TODO [[IPD:%![Error: (void-function my-capture-promt)]]] %![Error: (void-function my-capture-promt)] [1/11] :US_%![Error: (void-function my-capture-promt)]:
| :PROPERTIES:
| :CREATED: [2016-05-09 [[file:c:/Users/karl/org/project.org::*2del][2del]] 15:27]
| :ID: 2016-05-09-Story-%![Error: (void-variable my-short-title)]
| :END:
|
| | *IPD* | *Confluence* | *Champ* |
| | [[IPD:%![Error: (void-variable my-ipd)]][%![Error: (void-variable my-ipd)]]] | %![Error: (void-variable my-title)] | |
|
| [...]
`----
Note that "2del" is the current super-heading, 15:27 is current time, and
c:/Users/karl/org/project.org is the current Org-mode file. None of them are
supposed to be in my Org-mode file. They are interpreted by org-capture instead
of the Elisp function. I tend to think that this is a hint that I've got an
issue with wrong escaping.
Bonus for everybody who read so far and is still interested to read more:
So far, I was using yasnippet but unfortunately, I've got severe issues with
yasnippet and Emacs endless-loops/crashes. Since I was not able to fix
yasnippet even with posting in Newsgroups, I want to replace my complex
yasnippet templates with capture+Elisp. Isn't it awesome funny, how
yasnippet is printed four times in a row according to my alignment on pure
coincidence? ;-)
[1] http://storax.github.io/blog/2016/05/02/org-capture-tricks/
--
mail|git|SVN|photos|postings|SMS|phonecalls|RSS|CSV|XML to Org-mode:
> get Memacs from https://github.com/novoid/Memacs <
https://github.com/novoid/extract_pdf_annotations_to_orgmode + more on github
next reply other threads:[~2016-05-09 13:41 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-09 13:40 Karl Voit [this message]
2016-05-09 15:24 ` Advanced capture template using Elisp functions: void-function/void-variable Karl Voit
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2016-05-09T15-13-42@devnull.Karl-Voit.at \
--to=devnull@karl-voit.at \
--cc=emacs-orgmode@gnu.org \
--cc=news1142@Karl-Voit.at \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.