Ruijie Yu <rui...@netyu.xyz> writes: > Ihor Radchenko <yanta...@posteo.net> writes: > >> (let ((org-time-stamp-formats '("%Y-%m-%d" . "%Y-%m-%d %H:%M"))) >> (org-element-timestamp-interpreter timestamp nil)) > > Thanks for the pointer. I have made this into a macro and redid my > changes accordingly. Please also let me know if more work should be > dedicated to avoid code duplication in tests (I see a lot of duplication > in the portions I touched in testing/lisp/test-org.el).
Thanks! Some comments below. > +(defmacro org-test-with-result (result &rest body) ... > + (_ result)))) > + > +(defmacro org-test-without-dow (result &rest body) > + "Eval BODY skipping day-of-week in timestamps. > +See `org-test-with-result' for RESULT and the return value." > + (declare (indent 1)) > + `(let ((org-time-stamp-formats '("%Y-%m-%d" . "%Y-%m-%d %H:%M"))) > + ;; ,(macroexpand-1 `(org-test-with-result ,result ,@body)) > + (org-test-with-result ,result ,@body))) When reading the test code, this `org-test-without-dow' is quite confusing - the name suggests "day of week"-related, but RESULTS='buffer argument is doing something completely different. IMHO, it would be cleaner to: 1. (let ((org-time-stamp-formats ...)) ...) around the whole test. 2. Use `org-test-with-result' explicitly inside individual test clauses. > +(defconst org-test-day-of-weeks-abbrev > + (apply #'vector > + (seq-map (apply-partially #'format-time-string "%a") > + org-test-day-of-weeks-seconds)) > + "Vector of abbreviated names of days of week. > +See `org-test-day-of-weeks-seconds'.") > + > +(defconst org-test-day-of-weeks-full > + (apply #'vector > + (seq-map (apply-partially #'format-time-string "%A") > + org-test-day-of-weeks-seconds)) > + "Vector of full names for days of week. > +See `org-test-day-of-weeks-seconds'.") These constants make it necessary to write incantations like (sun (aref org-test-day-of-weeks-abbrev 0)) Why not creating a function like (org-test-translate-dow "Mon") or (org-test-translate-dow "Monday") that will do the same? It will be a lot more readable as well. You can then use an alist instead of vectors. -- 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>