From: Ihor Radchenko <yantar92@posteo.net>
To: Nafiz Islam <nafiz.islam1000@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: [PATCH] function and symbol for headline and olp for org-capture-templates
Date: Sun, 09 Jun 2024 17:03:14 +0000 [thread overview]
Message-ID: <877cey2gml.fsf@localhost> (raw)
In-Reply-To: <f700cfcd-c453-4212-8abd-3d1ebbb43d32@gmail.com>
Nafiz Islam <nafiz.islam1000@gmail.com> writes:
>> I tried to run make test with your patch, and it is failing:
>
> On my side it passes on main branch at commit 6c862699a6db3f6b76391c05380d92d9f1b3838f with patch.
> passed 444/1207 test-org-capture/entry (0.099791 sec)
> ...
> passed 447/1207 test-org-capture/org-capture-expand-olp (0.001104 sec)
>
> Apparently, you get
> `"* A\n** B\n*** 1970\n**** 1970-01 January\n***** 1970-01-01 Thursday\n****** H1 Capture text\n** C\n"'
>
> Whereas I get the expected result of
> `"* A\n** B\n*** 1969\n**** 1969-12 December\n***** 1969-12-31 Wednesday\n****** H1 Capture text\n** C\n"'
>
> What do you get if you evaluate `(calendar-gregorian-from-absolute (time-to-days 0))'? I get `(12 31 1969)'.
> I set `org-overriding-default-time' to `0' for testing with datetree.
I get (1 1 1970).
It is probably more reliable to use `org-test-at-time' macro.
>>> I don't have to additionally test for whether the lambda (as a target)
>>> is actually called while visiting the file right?
>> May you elaborate what you mean?
>
> So I've written a test for lambda-based target.
>
> (should
> (equal
> "* A\n* B\n** H1 Capture text\n* C\n"
> (org-test-with-temp-text-in-file "* A\n* B\n* C\n"
> (let* ((file (buffer-file-name))
> (org-capture-templates
> `(("t" "Todo" entry (file+headline ,file ,(lambda () "B")) "** H1 %?"))))
> (org-capture nil "t")
> (insert "Capture text")
> (org-capture-finalize))
> (buffer-string))))
>
> But it does not verify that the lambda `(lambda () "B")' is actually being called while
> visiting the file which would allow reading the file to compute or generate a headline.
> So I'm wondering if I should write a test for that too. Maybe for each new lambda target?
You can. Maybe even as a part of the above test (and similar):
`(("t" "Todo"
entry
(file+headline
,file
(lambda ()
(should (equal ,file (buffer-file-name)))
"B"))
"** H1 %?"))
--
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>
next prev parent reply other threads:[~2024-06-09 17:02 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-01 16:38 [PATCH] function and symbol for headline and olp for org-capture-templates Nafiz Islam
2024-06-05 9:09 ` Ihor Radchenko
2024-06-05 21:16 ` Bastien Guerry
[not found] ` <f2b85669-a0fc-40c6-891a-1319d0582fe0@gmail.com>
[not found] ` <87frtpgj2w.fsf@localhost>
2024-06-09 14:59 ` Nafiz Islam
2024-06-09 17:03 ` Ihor Radchenko [this message]
[not found] ` <3508dbb0-a8ee-4217-af21-a9fc3ac46eb9@gmail.com>
[not found] ` <874ja4ak0q.fsf@localhost>
2024-06-15 21:45 ` Nafiz Islam
2024-06-16 12:20 ` Ihor Radchenko
[not found] ` <c98ba108-c07e-4c17-a806-524444367d9d@gmail.com>
[not found] ` <87plsfa2nt.fsf@localhost>
2024-06-18 12:05 ` Nafiz Islam
2024-06-18 12:36 ` Ihor Radchenko
-- strict thread matches above, loose matches on Subject: below --
2024-05-19 23:34 Nafiz Islam
2024-05-19 23:43 ` Nafiz Islam
2024-05-20 10:53 ` Ihor Radchenko
2024-05-21 21:00 ` Nafiz Islam
2024-05-22 11:11 ` Nafiz Islam
2024-05-22 11:15 ` Ihor Radchenko
2024-05-13 22:53 Nafiz Islam
2024-05-13 23:08 ` Nafiz Islam
2024-05-17 12:48 ` Ihor Radchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=877cey2gml.fsf@localhost \
--to=yantar92@posteo.net \
--cc=emacs-orgmode@gnu.org \
--cc=nafiz.islam1000@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.