* org capture properties from a list of strings?
@ 2017-04-23 14:41 Xebar Saram
2017-04-25 7:45 ` Xebar Saram
0 siblings, 1 reply; 7+ messages in thread
From: Xebar Saram @ 2017-04-23 14:41 UTC (permalink / raw)
To: org mode
[-- Attachment #1: Type: text/plain, Size: 475 bytes --]
Hi all
so i currently have this in my capture templates
:PROPERTIES:
:Time: %^{minutes|-|10|15|30|60}
:Rating: %^{rating?|-|1|2|3|4|5}
:END:
i was wondering if instead of manually putting the values in each line i
can perhaps supply a list like this
(defun returns-a-list-of-strings2
()
(list "1" "2" "3" "4" "5" ))
is that somehow possible where i could have something like this
:Rating: %^{rating?|(returns-a-list-of-strings2)}
is that possible at all?
best
Z
[-- Attachment #2: Type: text/html, Size: 867 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: org capture properties from a list of strings?
2017-04-23 14:41 org capture properties from a list of strings? Xebar Saram
@ 2017-04-25 7:45 ` Xebar Saram
2017-04-25 8:00 ` Nicolas Goaziou
0 siblings, 1 reply; 7+ messages in thread
From: Xebar Saram @ 2017-04-25 7:45 UTC (permalink / raw)
To: org mode
[-- Attachment #1: Type: text/plain, Size: 976 bytes --]
Hi again all
kinda stuck with this and cant find any documentation. would also be glad
to know its not possible so i can perhaps explore another method :)
im basically wondering if instead of manually imputing string separated
with | in the : %^{} capture template i can provide a lisp way to send a
pre defined list of strings ("a" "b" "c") etc.. anyone has any clue?
best
Z
On Sun, Apr 23, 2017 at 5:41 PM, Xebar Saram <zeltakc@gmail.com> wrote:
> Hi all
>
> so i currently have this in my capture templates
>
>
> :PROPERTIES:
> :Time: %^{minutes|-|10|15|30|60}
> :Rating: %^{rating?|-|1|2|3|4|5}
> :END:
>
> i was wondering if instead of manually putting the values in each line i
> can perhaps supply a list like this
>
>
> (defun returns-a-list-of-strings2
> ()
> (list "1" "2" "3" "4" "5" ))
>
> is that somehow possible where i could have something like this
>
>
> :Rating: %^{rating?|(returns-a-list-of-strings2)}
>
> is that possible at all?
>
> best
>
> Z
>
[-- Attachment #2: Type: text/html, Size: 1936 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: org capture properties from a list of strings?
2017-04-25 7:45 ` Xebar Saram
@ 2017-04-25 8:00 ` Nicolas Goaziou
2017-04-25 15:56 ` Xebar Saram
0 siblings, 1 reply; 7+ messages in thread
From: Nicolas Goaziou @ 2017-04-25 8:00 UTC (permalink / raw)
To: Xebar Saram; +Cc: org mode
Hello,
Xebar Saram <zeltakc@gmail.com> writes:
> kinda stuck with this and cant find any documentation. would also be glad
> to know its not possible so i can perhaps explore another method :)
>
> im basically wondering if instead of manually imputing string separated
> with | in the : %^{} capture template i can provide a lisp way to send a
> pre defined list of strings ("a" "b" "c") etc.. anyone has any clue?
Since it is pre-defined, you can do the following during capture
definition
(format "* Headline
:PROPERTIES:
:Time: %%^{minutes|-|%s}
:Rating: %%^{rating?|-|%s}
:END:"
(mapconcat #'number-to-string '(10 15 30 60) "|")
(mapconcat #'number-to-string '(1 2 3 4 5) "|"))
Can't you?
Regards,
--
Nicolas Goaziou
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: org capture properties from a list of strings?
2017-04-25 8:00 ` Nicolas Goaziou
@ 2017-04-25 15:56 ` Xebar Saram
2017-04-25 16:19 ` Nicolas Goaziou
0 siblings, 1 reply; 7+ messages in thread
From: Xebar Saram @ 2017-04-25 15:56 UTC (permalink / raw)
To: Nicolas Goaziou; +Cc: org mode
[-- Attachment #1: Type: text/plain, Size: 1931 bytes --]
thx Nicolas
really appreciate your answer! though im very week in coding so im
struggling to understand. but perhaps an example will help. the following
is a part of my capture:
(add-to-list 'org-capture-templates
'("ff" "Food"
entry
(file+headline (concat pmm "/org/files/agenda/food.org") "Inbox")
"* COOK %^{Recipe Name}
:PROPERTIES:
:ID: %(org-id-uuid)
:Time: %^{minutes|-|10|15|30|60}
:Rating: %^{rating?|-|1|2|3|4|5}
:Source: %x
:Cuisine:
%^{Cuisine?|-|Indian|Thai|Vietnamese|Asian|Chinese|Israeli|Italian|American|EastEuro|Mexican|French|Persian|Austrian}
:Type: %^{Type?|-|main|side|starter|sweets|drinks|sauce|breakfast}
:Main.ing:
%^{main.ing?|-|chicken|beef|potatos|fish|seafood|shrimp|rice|pasta|fruit}
:Serves: %^{Serves?|-|1|2|4|6|8}
:END:
%^{prompt|*** Ingredients}
%?
%^{prompt|*** Preparation}
"
"Capture Template for food recipe"
))
so do i need a separate mapconcat #'number-to-string for each property
value (time,type etc?)
and how dows the %s know which mapconcat command to refer to?
thx alot again
Z
On Tue, Apr 25, 2017 at 11:00 AM, Nicolas Goaziou <mail@nicolasgoaziou.fr>
wrote:
> Hello,
>
> Xebar Saram <zeltakc@gmail.com> writes:
>
> > kinda stuck with this and cant find any documentation. would also be glad
> > to know its not possible so i can perhaps explore another method :)
> >
> > im basically wondering if instead of manually imputing string separated
> > with | in the : %^{} capture template i can provide a lisp way to send a
> > pre defined list of strings ("a" "b" "c") etc.. anyone has any clue?
>
> Since it is pre-defined, you can do the following during capture
> definition
>
> (format "* Headline
> :PROPERTIES:
> :Time: %%^{minutes|-|%s}
> :Rating: %%^{rating?|-|%s}
> :END:"
> (mapconcat #'number-to-string '(10 15 30 60) "|")
> (mapconcat #'number-to-string '(1 2 3 4 5) "|"))
>
> Can't you?
>
> Regards,
>
> --
> Nicolas Goaziou
>
[-- Attachment #2: Type: text/html, Size: 3387 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: org capture properties from a list of strings?
2017-04-25 15:56 ` Xebar Saram
@ 2017-04-25 16:19 ` Nicolas Goaziou
2017-04-26 12:28 ` Xebar Saram
0 siblings, 1 reply; 7+ messages in thread
From: Nicolas Goaziou @ 2017-04-25 16:19 UTC (permalink / raw)
To: Xebar Saram; +Cc: org mode
Hello,
Xebar Saram <zeltakc@gmail.com> writes:
> thx Nicolas
>
> really appreciate your answer! though im very week in coding so im
> struggling to understand. but perhaps an example will help. the following
> is a part of my capture:
>
> (add-to-list 'org-capture-templates
> '("ff" "Food"
> entry
> (file+headline (concat pmm "/org/files/agenda/food.org") "Inbox")
> "* COOK %^{Recipe Name}
> :PROPERTIES:
> :ID: %(org-id-uuid)
> :Time: %^{minutes|-|10|15|30|60}
> :Rating: %^{rating?|-|1|2|3|4|5}
> :Source: %x
> :Cuisine:
> %^{Cuisine?|-|Indian|Thai|Vietnamese|Asian|Chinese|Israeli|Italian|American|EastEuro|Mexican|French|Persian|Austrian}
> :Type: %^{Type?|-|main|side|starter|sweets|drinks|sauce|breakfast}
> :Main.ing:
> %^{main.ing?|-|chicken|beef|potatos|fish|seafood|shrimp|rice|pasta|fruit}
> :Serves: %^{Serves?|-|1|2|4|6|8}
> :END:
>
> %^{prompt|*** Ingredients}
> %?
> %^{prompt|*** Preparation}
>
> "
> "Capture Template for food recipe"
> ))
>
>
> so do i need a separate mapconcat #'number-to-string for each property
> value (time,type etc?)
Yes, you do. However, #'number-to-string is only useful if you're
inserting numbers. I think you can use the more general
#'prin1-to-string everywhere instead, e.g.,
(mapconcat #'prin1-to-string '(Indian Thai Vietnamese Asian Chinese) "|")
or even, using strings
(mapconcat #'identity '("Indian" "Thai" "Vietnamese" "Asian" "Chinese") "|")
> and how dows the %s know which mapconcat command to refer to?
The are processed by order. The first "%s" refers to the first
mapconcat, the second "%s" to the second mapconcat, and so on...
Regards,
--
Nicolas Goaziou 0x80A93738
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: org capture properties from a list of strings?
2017-04-25 16:19 ` Nicolas Goaziou
@ 2017-04-26 12:28 ` Xebar Saram
2017-04-26 14:13 ` Nicolas Goaziou
0 siblings, 1 reply; 7+ messages in thread
From: Xebar Saram @ 2017-04-26 12:28 UTC (permalink / raw)
To: Nicolas Goaziou; +Cc: org mode
[-- Attachment #1: Type: text/plain, Size: 2791 bytes --]
Hi again
once again really appreciate the answer and apologize in advance for my
limited grasp of coding. so i managed i think to follow your example and
now have this as my capture template
(setq org-capture-templates nil)
(setq org-capture-templates-contexts nil)
(add-to-list 'org-capture-templates
'("f" "Food"
entry
(file+headline (concat pmm "/org/files/agenda/food.org") "Inbox")
"* COOK %^{Recipe Name}
:PROPERTIES:
:ID: %(org-id-uuid)
:Time: %^{minutes|%s}
:type: %^{Type?|%s}
:END:
%^{prompt|*** Ingredients}
%?
%^{prompt|*** Preparation}
"
(mapconcat #'identity '("1" "2" "3" "4" "5") "|")
(mapconcat #'identity '("Indian" "Thai" "Vietnamese" "Asian" "Chinese") "|")
"Capture Template for food recipe"
))
yet i only get offered a %s as a option and not the string in my capture
process.
im sure my syntax is way off, can anyone stir me in the right direction?
best
Z
On Tue, Apr 25, 2017 at 7:19 PM, Nicolas Goaziou <mail@nicolasgoaziou.fr>
wrote:
> Hello,
>
> Xebar Saram <zeltakc@gmail.com> writes:
>
> > thx Nicolas
> >
> > really appreciate your answer! though im very week in coding so im
> > struggling to understand. but perhaps an example will help. the following
> > is a part of my capture:
> >
> > (add-to-list 'org-capture-templates
> > '("ff" "Food"
> > entry
> > (file+headline (concat pmm "/org/files/agenda/food.org") "Inbox")
> > "* COOK %^{Recipe Name}
> > :PROPERTIES:
> > :ID: %(org-id-uuid)
> > :Time: %^{minutes|-|10|15|30|60}
> > :Rating: %^{rating?|-|1|2|3|4|5}
> > :Source: %x
> > :Cuisine:
> > %^{Cuisine?|-|Indian|Thai|Vietnamese|Asian|Chinese|
> Israeli|Italian|American|EastEuro|Mexican|French|Persian|Austrian}
> > :Type: %^{Type?|-|main|side|starter|sweets|drinks|sauce|breakfast}
> > :Main.ing:
> > %^{main.ing?|-|chicken|beef|potatos|fish|seafood|shrimp|
> rice|pasta|fruit}
> > :Serves: %^{Serves?|-|1|2|4|6|8}
> > :END:
> >
> > %^{prompt|*** Ingredients}
> > %?
> > %^{prompt|*** Preparation}
> >
> > "
> > "Capture Template for food recipe"
> > ))
> >
> >
> > so do i need a separate mapconcat #'number-to-string for each property
> > value (time,type etc?)
>
> Yes, you do. However, #'number-to-string is only useful if you're
> inserting numbers. I think you can use the more general
> #'prin1-to-string everywhere instead, e.g.,
>
> (mapconcat #'prin1-to-string '(Indian Thai Vietnamese Asian Chinese) "|")
>
> or even, using strings
>
> (mapconcat #'identity '("Indian" "Thai" "Vietnamese" "Asian" "Chinese")
> "|")
>
> > and how dows the %s know which mapconcat command to refer to?
>
> The are processed by order. The first "%s" refers to the first
> mapconcat, the second "%s" to the second mapconcat, and so on...
>
> Regards,
>
> --
> Nicolas Goaziou 0x80A93738
>
[-- Attachment #2: Type: text/html, Size: 4585 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: org capture properties from a list of strings?
2017-04-26 12:28 ` Xebar Saram
@ 2017-04-26 14:13 ` Nicolas Goaziou
0 siblings, 0 replies; 7+ messages in thread
From: Nicolas Goaziou @ 2017-04-26 14:13 UTC (permalink / raw)
To: Xebar Saram; +Cc: org mode
Hello,
Xebar Saram <zeltakc@gmail.com> writes:
> (add-to-list 'org-capture-templates
> '("f" "Food"
It should be `("f" "Food"
> entry
> (file+headline (concat pmm "/org/files/agenda/food.org") "Inbox")
missing comma and `format' function:
,(format "*COOK %%^{Recipe Name}
...
> "* COOK %^{Recipe Name}
> :PROPERTIES:
> :ID: %(org-id-uuid)
> :Time: %^{minutes|%s}
> :type: %^{Type?|%s}
> :END:
>
>
> %^{prompt|*** Ingredients}
> %?
> %^{prompt|*** Preparation}
>
> "
Don't forget to double all percent signs that are not place holders.
Regards,
--
Nicolas Goaziou
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2017-04-26 14:13 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-23 14:41 org capture properties from a list of strings? Xebar Saram
2017-04-25 7:45 ` Xebar Saram
2017-04-25 8:00 ` Nicolas Goaziou
2017-04-25 15:56 ` Xebar Saram
2017-04-25 16:19 ` Nicolas Goaziou
2017-04-26 12:28 ` Xebar Saram
2017-04-26 14:13 ` Nicolas Goaziou
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).