Ihor Radchenko writes: > Ilya Chernyshov writes: > >> (defun org-datetree--find-create >> @@ -169,18 +167,19 @@ component. If INSERT is non-nil and >> there is no match then it is >> inserted into the buffer." >> (when (or month day) >> (org-narrow-to-subtree)) >> - (let ((re (format regex-template year month day)) >> + (let ((re (format org-complex-heading-regexp-format >> + (format regex-template year month day))) > > These changes make the docstring for `org-datetree--find-create' > incorrect: > > (defun org-datetree--find-create > (regex-template year &optional month day insert) > "Find the datetree matched by REGEX-TEMPLATE for YEAR, > MONTH, or DAY. > REGEX-TEMPLATE is passed to `format' with YEAR, MONTH, and > DAY as > arguments. Match group 1 is compared against the specified > date > component. If INSERT is non-nil and there is no match then > it is > inserted into the buffer." > > Please update the docstring to reflect the new behaviour. Hi! Since the last patch, I've made the following changes, thanks to your recommendations in Matrix chat: 1. Added a new optional argument MATCH-TITLE to `org-datetree--find-create' that controls whether to match REGEX-TEMPLATE against heading title inside complex heading (the match is done via `org-complex-heading-regexp-format') or to match REGEX-TEMPLATE against the whole heading line(old behavior). That way, we won't break old calls to the function. 2. Added `replace-match' call that renames the first implicitly numbered match group inside REGEX-TEMPLATE to first explicitly numbered one. The replace is performed only if MATCH-TITLE is non-nil(that is, `org-complex-heading-regexp-format' is used). That way we ensure that even if in the future `org-complex-heading-regexp-format' will be changed (the number of match groups will be different), we can get access to the right group matching a date component without modifying the source code of the function. Is there a better way to ensure that?