Nafiz Islam <nafiz.islam1...@gmail.com> writes:

> So far I have written this code...
>
> (defun org-capture-expand-headline (headline)
>   "Expand functions, symbols and strings for HEADLINE.
>
>
> When HEADLINE is a function, call it.  When it is a form, evaluate
> it.  When it is a variable, return its value.  When it is a string,
> treat it as a headline title. When it is `t', select existing headline
> title or enter a new one.  In any other case, raise an error."

Let's not add "t" variant yet. It is going beyond what
`org-capture-expand-file' does.

>                                ((functionp headline) (funcall headline
> headlines))

Let's not over-complicate things. Just (funcall headline) will do,
making sure that it is called in the right context - current buffer
being selected according to file part of the capture target.

> What I am concerned about is the amount of tests I might have to write or
> update for `org-capture'.
>
> testing/lisp/test-org-capture.el
> ...
> 144:             `(("t" "Todo" entry (file+headline ,file2 "A")
> ...
> How do you think it should be tested if the headline can be 4 different
> types?

It is enough to make sure that basic entry type works correctly,
expanding the HEADLINE part of the template definition. Other tests you
listed are really not testing this; they are checking the logic of
inserting the right entry/item/table/etc.

Also, since we are adding more flexible HEADLINE expansion, may as well
allow functions for OLP in file+olp and file+olp+datetree.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>

Reply via email to