From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nathan Neff Subject: Using variables in org-capture-templates Date: Tue, 12 Nov 2019 09:27:31 -0600 Message-ID: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000df8a59059727dfbb" Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:43930) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iUY41-0001H7-Hm for emacs-orgmode@gnu.org; Tue, 12 Nov 2019 10:26:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iUY40-0005fr-DO for emacs-orgmode@gnu.org; Tue, 12 Nov 2019 10:26:41 -0500 Received: from mail-io1-xd2e.google.com ([2607:f8b0:4864:20::d2e]:34128) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iUY40-0005fg-8r for emacs-orgmode@gnu.org; Tue, 12 Nov 2019 10:26:40 -0500 Received: by mail-io1-xd2e.google.com with SMTP id q83so19146535iod.1 for ; Tue, 12 Nov 2019 07:26:39 -0800 (PST) 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 --000000000000df8a59059727dfbb Content-Type: text/plain; charset="UTF-8" Hello all, I'm sure this is a basic elisp thing but I'd like some help: I wanted to abstract the "sprintf-like" formats of the template expansion into readable variables that I can reuse in my templates. However, upon substituting variable for the formats, I am getting "Invalid capture template" for the capture template "T" below -- for comparison the "t" template works. What am I doing wrong? I'm sure it has to do with the '() value of org-capture templates, and the fact that the (concat) is not evaluated. What is the "correct" way to do this in elisp? Here's my code: #+begin_src emacs-lisp (setq org-capture-templates '()) (setq njn-clocked-entry "\nclocked: %K\n") (setq njn-from-entry "\nfrom: %a\n") (setq njn-capture-trailer "\n--\n") (setq org-capture-templates '( ("T" "Todo: Detailed" entry (file+headline "" "Tasks") (concat "* todo %^{Heading}\n%U\n%?" njn-from-entry njn-clocked-entry njn-capture-trailer) :prepend t) ("t" "Todo: Basic" entry (file+headline "" "Tasks") "* todo %^{Heading}\n%U\n%?\nclocked: %K\n" :prepend t))) Thanks, --Nate --000000000000df8a59059727dfbb Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hello all,

<= /div>
I'm sure this is a basic elisp thing but I'd like some he= lp:

I wanted to abstract the "sprintf-like&qu= ot; formats of the template expansion
into readable variables tha= t I can reuse in my templates.=C2=A0 However, upon
substituting v= ariable for the formats, I am getting "Invalid capture template"<= /div>
for the capture template "T" below -- for comparison th= e "t" template works.

What am I doing wr= ong?=C2=A0 I'm sure it has to do with the '() value of org-capture = templates,
and the fact that the (concat) is not evaluated.=C2=A0= What is the "correct" way to do this
in elisp?

Here's my code:
=C2=A0
#+beg= in_src emacs-lisp
(setq org-capture-templates '())
= (setq njn-clocked-entry "\nclocked: %K\n")
(setq njn-fr= om-entry "\nfrom: %a\n")
(setq njn-capture-trailer &quo= t;\n--\n")

(setq org-capture-templates &= #39;(
=C2=A0 =C2=A0 ("T" "Todo: Detailed" ent= ry (file+headline "" "Tasks")
=C2=A0 =C2=A0 = =C2=A0 =C2=A0 (concat "* todo %^{Heading}\n%U\n%?" njn-from-entry= njn-clocked-entry njn-capture-trailer) :prepend t)
=C2=A0 =C2=A0= ("t" "Todo: Basic" entry (file+headline "" &= quot;Tasks") "* todo %^{Heading}\n%U\n%?\nclocked: %K\n" :pr= epend t)))

Thanks,
--Nate

--000000000000df8a59059727dfbb--