emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* org-capture: question about function to create template
@ 2021-03-15 15:42 Joost Kremers
  2021-03-16  2:30 ` Ihor Radchenko
  0 siblings, 1 reply; 4+ messages in thread
From: Joost Kremers @ 2021-03-15 15:42 UTC (permalink / raw)
  To: emacs-orgmode

Hi list,

I've been looking at the =org-capture= mechanism a bit more closely recently and
noticed that in =org-capture-templates=, the template can also be a function.
This looks like a potentially useful feature, but I was wondering if there's any
way for this function to access the state of the ongoing capture process.
Specifically, it would be useful for me if the function can find out the key of
the template that the user selected.

Of course I could have a different function for each template that I want to
create dynamically, or use a lambda that calls my function with an appropriate
argument, but that wouldn't be as useful to me.

TIA

Joost


-- 
Joost Kremers
Life has its moments


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

* Re: org-capture: question about function to create template
  2021-03-15 15:42 org-capture: question about function to create template Joost Kremers
@ 2021-03-16  2:30 ` Ihor Radchenko
  2021-03-16  9:36   ` Joost Kremers
  0 siblings, 1 reply; 4+ messages in thread
From: Ihor Radchenko @ 2021-03-16  2:30 UTC (permalink / raw)
  To: Joost Kremers, emacs-orgmode

Joost Kremers <joostkremers@fastmail.fm> writes:

> ... I was wondering if there's any
> way for this function to access the state of the ongoing capture process.
> Specifically, it would be useful for me if the function can find out the key of
> the template that the user selected.

See org-capture-plist.

Also, you might find https://github.com/progfolio/doct useful.

Best,
Ihor


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

* Re: org-capture: question about function to create template
  2021-03-16  2:30 ` Ihor Radchenko
@ 2021-03-16  9:36   ` Joost Kremers
  0 siblings, 0 replies; 4+ messages in thread
From: Joost Kremers @ 2021-03-16  9:36 UTC (permalink / raw)
  To: Ihor Radchenko, No Wayman; +Cc: emacs-orgmode

Hi Ihor & No Wayman,

Thanks for your replies.

On Tue, Mar 16 2021, Ihor Radchenko wrote:
> Joost Kremers <joostkremers@fastmail.fm> writes:
>
>> ... I was wondering if there's any
>> way for this function to access the state of the ongoing capture process.
>> Specifically, it would be useful for me if the function can find out the key of
>> the template that the user selected.
>
> See org-capture-plist.

Yes, I thought that might be it, but I wasn't sure.

On Mon, Mar 15 2021, No Wayman wrote:
>> From: Joost Kremers <joostkremers@fastmail.fm>
>> Specifically, it would be useful for me if the function can find out the key
>> of the template that the user selected.
>
> This is stored on the above plist as :key.
>
> There are some corner cases to consider if you have overlapping 
> capture processes.
> You'll want to look into `org-capture-get' and 
> `org-capture-current-plist' as well.

Thanks for the pointers. I'll dive in a little and see what's best for my use
case.



-- 
Joost Kremers
Life has its moments


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

* Re: org-capture: question about function to create template
       [not found] <mailman.51.1615824031.880.emacs-orgmode@gnu.org>
@ 2021-03-15 16:57 ` No Wayman
  0 siblings, 0 replies; 4+ messages in thread
From: No Wayman @ 2021-03-15 16:57 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: emacs-orgmode-request


> From: Joost Kremers <joostkremers@fastmail.fm>
> To: emacs-orgmode@gnu.org
> Subject: org-capture: question about function to create template
> Message-ID: <87eeggh0r5.fsf@fastmail.fm>
> Content-Type: text/plain
>
> Hi list,
>
> I've been looking at the =org-capture= mechanism a bit more 
> closely recently and
> noticed that in =org-capture-templates=, the template can also 
> be a function.
> This looks like a potentially useful feature, but I was 
> wondering if there's any
> way for this function to access the state of the ongoing capture 
> process.

The metadata for the template is stored in the `org-capture-plist' 
variable.


> Specifically, it would be useful for me if the function can find 
> out the key of
> the template that the user selected.

This is stored on the above plist as :key.

There are some corner cases to consider if you have overlapping 
capture processes.
You'll want to look into `org-capture-get' and 
`org-capture-current-plist' as well.

Depending on your needs you may find DOCT useful:

https://www.github.com/progfolio/doct





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

end of thread, other threads:[~2021-03-16  9:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-15 15:42 org-capture: question about function to create template Joost Kremers
2021-03-16  2:30 ` Ihor Radchenko
2021-03-16  9:36   ` Joost Kremers
     [not found] <mailman.51.1615824031.880.emacs-orgmode@gnu.org>
2021-03-15 16:57 ` No Wayman

Code repositories for project(s) associated with this 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).