emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* org-capture-template: How to correctly capture email addresses?
@ 2011-11-06 10:49 Marius Hofert
  2011-11-08 21:04 ` Marius Hofert
  0 siblings, 1 reply; 3+ messages in thread
From: Marius Hofert @ 2011-11-06 10:49 UTC (permalink / raw)
  To: Emacs help

Hi,

I would like to capture contacts (name, email,..) with org-mode and thus setup the following in .emacs:

(setq org-capture-templates
      '(("t" "TODO in ~/org/agenda.org -> Tasks" entry (file+headline "~/org/agenda.org" "Tasks")
         "* TODO %?\nSCHEDULED: %^t\n%U %a")
        ("c" "Contact in ~/org/contacts.org -> Contact" entry (file+headline "~/org/contacts.org" "Contact")
         "* %?%(org-contacts-template-name) %^g
:PROPERTIES:
:EMAIL: %(org-contacts-template-email)
:URL:
:WORK:
:HOME:
:MOBILE:
:LOCATION:
:BIRTHDAY: 
:NOTE:
:END:")))

I can easily capture contacts with C-c c c, it prompts for the name, a tag, and the email address. However, instead of an output like 

* My contact                         :my.tag:
  :PROPERTIES:
  :EMAIL: my.contact@my.mail.com
  :URL:
  :WORK:
  :HOME:
  :MOBILE:
  :LOCATION:
  :BIRTHDAY: 
  :NOTE:
  :END:

I obtain:

* My contact                         :my.tag:
  :PROPERTIES:
  :EMAIL:
  :URL:
  :WORK:
  :HOME:
  :MOBILE:
  :LOCATION:
  :BIRTHDAY: 
  :NOTE:
  :EMAIL: my.contact@my.mail.com
  :END:

So the problem is that the first :EMAIL: is ignored and instead a second :EMAIL: is inserted before :END:. How can I obtain the correct output (as described above)?

Cheers,

Marius

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: org-capture-template: How to correctly capture email addresses?
  2011-11-06 10:49 org-capture-template: How to correctly capture email addresses? Marius Hofert
@ 2011-11-08 21:04 ` Marius Hofert
  2011-11-09  9:34   ` Christian Moe
  0 siblings, 1 reply; 3+ messages in thread
From: Marius Hofert @ 2011-11-08 21:04 UTC (permalink / raw)
  To: Emacs help

see here: http://stackoverflow.com/questions/8037953/org-mode-how-to-correctly-capture-email-addresses


On 2011-11-06, at 11:49 , Marius Hofert wrote:

> Hi,
> 
> I would like to capture contacts (name, email,..) with org-mode and thus setup the following in .emacs:
> 
> (setq org-capture-templates
>      '(("t" "TODO in ~/org/agenda.org -> Tasks" entry (file+headline "~/org/agenda.org" "Tasks")
>         "* TODO %?\nSCHEDULED: %^t\n%U %a")
>        ("c" "Contact in ~/org/contacts.org -> Contact" entry (file+headline "~/org/contacts.org" "Contact")
>         "* %?%(org-contacts-template-name) %^g
> :PROPERTIES:
> :EMAIL: %(org-contacts-template-email)
> :URL:
> :WORK:
> :HOME:
> :MOBILE:
> :LOCATION:
> :BIRTHDAY: 
> :NOTE:
> :END:")))
> 
> I can easily capture contacts with C-c c c, it prompts for the name, a tag, and the email address. However, instead of an output like 
> 
> * My contact                         :my.tag:
>  :PROPERTIES:
>  :EMAIL: my.contact@my.mail.com
>  :URL:
>  :WORK:
>  :HOME:
>  :MOBILE:
>  :LOCATION:
>  :BIRTHDAY: 
>  :NOTE:
>  :END:
> 
> I obtain:
> 
> * My contact                         :my.tag:
>  :PROPERTIES:
>  :EMAIL:
>  :URL:
>  :WORK:
>  :HOME:
>  :MOBILE:
>  :LOCATION:
>  :BIRTHDAY: 
>  :NOTE:
>  :EMAIL: my.contact@my.mail.com
>  :END:
> 
> So the problem is that the first :EMAIL: is ignored and instead a second :EMAIL: is inserted before :END:. How can I obtain the correct output (as described above)?
> 
> Cheers,
> 
> Marius

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: org-capture-template: How to correctly capture email addresses?
  2011-11-08 21:04 ` Marius Hofert
@ 2011-11-09  9:34   ` Christian Moe
  0 siblings, 0 replies; 3+ messages in thread
From: Christian Moe @ 2011-11-09  9:34 UTC (permalink / raw)
  To: Marius Hofert; +Cc: Emacs help

Hi,

If org-contacts-template-email doesn't find an address, it doesn't 
insert a simple text prompt, it inserts a property prompt, which sets 
the property. A property prompt does not need to be positioned in an 
explicit property drawer in the template -- in fact, it looks like 
that will not work.

Removing the EMAIL property and moving the 
"%(org-contacts-template-email)" field out of the property drawer works:

(setq org-capture-templates
      '(("t" "TODO in ~/org/agenda.org -> Tasks" entry (file+headline 
"~/org/agenda.org" "Tasks")
         "* TODO %?\nSCHEDULED: %^t\n%U %a")
        ("c" "Contact in ~/org/contacts.org -> Contact" entry 
(file+headline "~/org/contacts.org" "Contact")
         "* %?%(org-contacts-template-name) %^g 
%(org-contacts-template-email)
:PROPERTIES:
:URL:
:WORK:
:HOME:
:MOBILE:
:LOCATION:
:BIRTHDAY:
:NOTE:
:END:")))

You still get EMAIL at the end of the property drawer, but the order 
is arbitrary anyway. You could replace the whole properties drawer 
with property prompts:


(setq org-capture-templates
      '(("t" "TODO in ~/org/agenda.org -> Tasks" entry (file+headline 
"~/org/agenda.org" "Tasks")
         "* TODO %?\nSCHEDULED: %^t\n%U %a")
        ("c" "Contact in ~/org/contacts.org -> Contact" entry 
(file+headline "~/org/contacts.org" "Contact")
         "* %?%(org-contacts-template-name) %^g
%(org-contacts-template-email)
%^{URL}p %^{WORK}p %^{HOME}p %^{MOBILE}p
%^{LOCATION}p %^{BIRTHDAY}p %^{NOTE}p")))

...but then you'd be prompted for everything, each time; you may not 
want that.


Yours,
Christian

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-11-09  9:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-06 10:49 org-capture-template: How to correctly capture email addresses? Marius Hofert
2011-11-08 21:04 ` Marius Hofert
2011-11-09  9:34   ` Christian Moe

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).