From: Ihor Radchenko <yantar92@posteo.net>
To: Jack Kamm <jackkamm@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: Month-week and quarter-week datetrees (RFC and package announcement)
Date: Sun, 29 Dec 2024 10:33:14 +0000 [thread overview]
Message-ID: <871pxqhj85.fsf@localhost> (raw)
In-Reply-To: <87ttametje.fsf@gmail.com>
Jack Kamm <jackkamm@gmail.com> writes:
> I attach a pair of patches for this.
Thanks! See my comments inline.
> +(defun org-datetree-find-create-entry
> + (time-grouping d &optional keep-restriction)
> + "Find or create an entry for date D.
> +TIME-GROUPING specifies the grouping levels of the datetree, and
> +should be a subset of `(year quarter month week day)'. Weeks are
> +assigned to years according to ISO-8601. If TIME-GROUPING
> +contains both `month' and `week', then weeks are assigned to the
> +month containing Thursday, for consistency with the ISO-8601
> +year-week rule. If TIME-GROUPING contains `quarter' and `week'
> +but not `month', quarters are defined as 13-week periods;
> +otherwise they are defined as 3-month periods.
>
> -If MATCH-TITLE is non-nil, REGEX-TEMPLATE is matched against
> -heading title and the exact regexp matched against heading line is:
> +If KEEP-RESTRICTION is non-nil, do not widen the buffer. When it
> +is nil, the buffer will be widened to make sure an existing date
> +tree can be found. If it is the symbol `subtree-at-point', then
> +the tree will be built under the headline at point."
Please also document how `org-datetree-add-timestamp' affects this function.
> + ;; Support the old way of tree placement, using a property
> + (cond
> + ((seq-set-equal-p time-grouping '(year month day))
> + "DATE_TREE")
> + ((seq-set-equal-p time-grouping '(year month))
> + "DATE_TREE")
> + ((seq-set-equal-p time-grouping '(year week day))
> + "WEEK_TREE")))
It would be a good idea to add a few tests for this scenario.
To make sure that refactoring did not break things.
> + ;; Support the old way of tree placement, using a property
> + (let ((prop (and legacy-prop (org-find-property legacy-prop))))
> + (if prop
> + (progn
> + (goto-char prop)
> + (org-narrow-to-subtree)
> + (setq tree (car (org-element-contents (org-element-parse-buffer 'headline)))))
> + (setq tree (org-element-parse-buffer)))))
Why do you need object granularity by default (second call to
`org-element-parse-buffer')?
Also, more importantly, do you have to run the full parsing here? Maybe
utilize `org-element-cache-map' instead? Full parsing is going to be
much slower.
> + (cl-loop
> + for pair in hier-pairs
> + do
> + (setq tree
> + (org-datetree--find-create-subheading
> + (cadr pair) (car pair) tree)))
It is undocumented in the `org-datetree--find-create-subheading'
docstring that it returns something.
--
Ihor Radchenko // yantar92,
Org mode maintainer,
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-12-29 10:32 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-30 19:41 Month-week and quarter-week datetrees (RFC and package announcement) Jack Kamm
2023-12-31 14:50 ` Ihor Radchenko
2023-12-31 18:16 ` Jack Kamm
2024-12-16 18:49 ` Ihor Radchenko
2024-12-28 6:09 ` Jack Kamm
2024-12-29 9:18 ` Jack Kamm
2024-12-29 10:33 ` Ihor Radchenko [this message]
2024-12-30 16:20 ` Jack Kamm
2024-12-30 17:11 ` Ihor Radchenko
2024-12-31 1:56 ` Jack Kamm
2025-01-01 9:14 ` 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
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=871pxqhj85.fsf@localhost \
--to=yantar92@posteo.net \
--cc=emacs-orgmode@gnu.org \
--cc=jackkamm@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 public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).