From mboxrd@z Thu Jan 1 00:00:00 1970 From: Karl Voit Subject: Advanced capture template using Elisp functions: void-function/void-variable Date: Mon, 9 May 2016 15:40:52 +0200 Message-ID: <2016-05-09T15-13-42@devnull.Karl-Voit.at> Reply-To: Karl Voit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:59008) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1azlR2-0004PP-99 for emacs-orgmode@gnu.org; Mon, 09 May 2016 09:41:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1azlQx-0006yg-Qm for emacs-orgmode@gnu.org; Mon, 09 May 2016 09:41:19 -0400 Received: from plane.gmane.org ([80.91.229.3]:37583) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1azlQx-0006yZ-GN for emacs-orgmode@gnu.org; Mon, 09 May 2016 09:41:15 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1azlQq-000568-9X for emacs-orgmode@gnu.org; Mon, 09 May 2016 15:41:08 +0200 Received: from friends.grml.info ([136.243.234.19]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 09 May 2016 15:41:08 +0200 Received: from news1142 by friends.grml.info with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 09 May 2016 15:41:08 +0200 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: emacs-orgmode@gnu.org 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