emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] org-datetree.el: Allow datetrees with TODO, priority, tags


From: Ilya Chernyshov
Subject: Re: [PATCH] org-datetree.el: Allow datetrees with TODO, priority, tags
Date: Fri, 13 Jan 2023 17:29:24 +0600
User-agent: mu4e 1.8.13; emacs 30.0.50


Ihor Radchenko <yantar92@posteo.net> writes:

Ilya Chernyshov <ichernyshovvv@gmail.com> 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?

Attachment: 0001-lisp-org-datetree.el-Allow-datetrees-with-TODO-prior.patch
Description: Text Data


--
Best,
Ilya

reply via email to

[Prev in Thread] Current Thread [Next in Thread]