I want to be able to write a cons with some of the cells being placeholders for later evaluation. I know I can use backquote constructs, but it tries to evaluate the cons immediately.
To clarify, provided I have a variable my-value
, I could do:
(setq my-cons `(my-key ,my-value))
But this won't satisfy my needs, as it's evaluated immediately. I can't use my-cons, without knowing about its structure, to create another cons like '(my-key "another-value")
. I need to be able to provide the structure as a variable, and fill it with real data later.
Think about format
function: We define a string, with some placeholders, and then use format
to inject our data into the string. What I need, is analogous to a format string, but for cons.
Detailed use-case: I want to convert a org-mode todo entry to a Jira ticket. org-jira and ejira, both have a shortcoming: they only read some basic data (project, ticket type summary). Since Jira is customizable, each project could have its different set of required fields. A useful org-todo-to-jira would allow you to define a mapping between org properties, and Jira fields. I want my org DEADLINE to be interpreted as
{
duedate: "deadline-value-here"
}
and my :estimation: to be interpreted as
{
estimation: {
originalEstimation: "estimation-value-here"
}
}
But a user might want another mapping. The cleanest thing that I thought of, was an alist defined by defcustom: the car of each cell being a property, and the cdr being another cons, defining the structure for that field: telling us how that field should be converted to a json. The car lets me know where to find that property in org todo entry, and the cdr lets me know where should I put that value in my json.
my-value
is bound or set is something else - do that any way and any place you like. – Drew Aug 28 '21 at 17:00