[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [FR] Support headline as a function for file+headline target for org
From: |
Ihor Radchenko |
Subject: |
Re: [FR] Support headline as a function for file+headline target for org-capture-templates |
Date: |
Sat, 04 May 2024 12:08:25 +0000 |
Nafiz Islam <nafiz.islam1001@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>
- Re: [FR] Support headline as a function for file+headline target for org-capture-templates, Ihor Radchenko, 2024/05/01
- Re: [FR] Support headline as a function for file+headline target for org-capture-templates, Nafiz Islam, 2024/05/01
- Re: [FR] Support headline as a function for file+headline target for org-capture-templates, Ihor Radchenko, 2024/05/01
- Re: [FR] Support headline as a function for file+headline target for org-capture-templates, Nafiz Islam, 2024/05/01
- Re: [FR] Support headline as a function for file+headline target for org-capture-templates, Ihor Radchenko, 2024/05/02
- Message not available
- Re: [FR] Support headline as a function for file+headline target for org-capture-templates, Nafiz Islam, 2024/05/02
- Re: [FR] Support headline as a function for file+headline target for org-capture-templates, Ihor Radchenko, 2024/05/03
- Re: [FR] Support headline as a function for file+headline target for org-capture-templates, Nafiz Islam, 2024/05/03
- Re: [FR] Support headline as a function for file+headline target for org-capture-templates,
Ihor Radchenko <=
- Re: [FR] Support headline as a function for file+headline target for org-capture-templates, Nafiz Islam, 2024/05/11
- Re: [FR] Support headline as a function for file+headline target for org-capture-templates, Ihor Radchenko, 2024/05/11