emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Eric Abrahamsen <eric@ericabrahamsen.net>
To: emacs-orgmode@gnu.org
Subject: Re: How to use org-capture with "dynamic ID" targets?
Date: Tue, 29 Jan 2013 13:26:05 +0800	[thread overview]
Message-ID: <871ud4imqa.fsf@ericabrahamsen.net> (raw)
In-Reply-To: 5106be00.0c5e650a.1535.fffff1fa@mx.google.com

Darlan Cavalcante Moreira <darcamo@gmail.com> writes:

> At Thu, 24 Jan 2013 20:01:47 +0100,
> Bastien wrote:
>> Did you tried this?
>> 
>> (setq org-capture-templates
>>  `(("f" "The template description" table-line
>>         (id ,some_variable)
>>         "this is the template content"
>>         :table-line-pos "II-1"
>>         :immediate-finish t)))
 
> This is something I'll have to keep in mind. However, I don't expect this
> to be a problem since I start Emacs everyday. It is enough for me if I can
> set the ID to a variable (before setting org-capture-templates) and it uses
> the variable value as the ID, instead of trying to interpret the variable
> name as the ID. In fact, even if I ever need to change the variable value
> after org-capture-templates was set I'm fine by just reevaluating (setq
> org-capture-templates ...) again so that it sees the new value.


> Exactly. Simple using the value of whatever list object I put there. Be it
> a variable value or a function that provides the. I'm fine if the value
> provided by a variable or a function is only read when
> org-capture-templates is set.

> My lisp knowledge is very limited to what I have seen in my Emacs
> initialization (and a lot of trying and error). But I have never seen "@"
> used in lisp nor I know what terms to search for it..

All this above is pretty much exactly what you're looking for. Check out
the "Backquote" section of the elisp manual for a pretty good
introduction. If you quote using a backtick (`) rather than an
apostrophe ('), you can use the comma (,) later on to evaluate variable
values, see the example at top. I don't believe you need the @ here, but
the manual section I mentioned explains it.

I used to do this in my agenda commands, but it wasn't really practical
because of the "only evaluate once" problem. If you restart emacs every
day, that won't really be an issue for you.

E

  reply	other threads:[~2013-01-29  5:21 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-16 22:38 How to use org-capture with "dynamic ID" targets? Darlan Cavalcante Moreira
2013-01-24 19:01 ` Bastien
2013-01-28 18:05   ` Darlan Cavalcante Moreira
2013-01-29  5:26     ` Eric Abrahamsen [this message]
2013-01-29 14:20       ` Darlan Cavalcante Moreira

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

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=871ud4imqa.fsf@ericabrahamsen.net \
    --to=eric@ericabrahamsen.net \
    --cc=emacs-orgmode@gnu.org \
    /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 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).