update packages
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
;;; org-datetree.el --- Create date entries in a tree -*- lexical-binding: t; -*-
|
||||
|
||||
;; Copyright (C) 2009-2023 Free Software Foundation, Inc.
|
||||
;; Copyright (C) 2009-2025 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Carsten Dominik <carsten.dominik@gmail.com>
|
||||
;; Keywords: outlines, hypermedia, calendar, wp
|
||||
;; Keywords: outlines, hypermedia, calendar, text
|
||||
;; URL: https://orgmode.org
|
||||
;;
|
||||
;; This file is part of GNU Emacs.
|
||||
@@ -99,16 +99,15 @@ If time-period is month, then group entries by month."
|
||||
(month (calendar-extract-month d))
|
||||
(day (calendar-extract-day d)))
|
||||
(org-datetree--find-create
|
||||
"^\\*+[ \t]+\\([12][0-9]\\{3\\}\\)\\(\\s-*?\
|
||||
\\([ \t]:[[:alnum:]:_@#%%]+:\\)?\\s-*$\\)"
|
||||
year)
|
||||
"\\([12][0-9]\\{3\\}\\)"
|
||||
year nil nil nil t)
|
||||
(org-datetree--find-create
|
||||
"^\\*+[ \t]+%d-\\([01][0-9]\\) \\w+$"
|
||||
year month)
|
||||
"%d-\\([01][0-9]\\) \\w+"
|
||||
year month nil nil t)
|
||||
(when (eq time-grouping 'day)
|
||||
(org-datetree--find-create
|
||||
"^\\*+[ \t]+%d-%02d-\\([0123][0-9]\\) \\w+$"
|
||||
year month day)))))
|
||||
"%d-%02d-\\([0123][0-9]\\) \\w+"
|
||||
year month day nil t)))))
|
||||
|
||||
;;;###autoload
|
||||
(defun org-datetree-find-iso-week-create (d &optional keep-restriction)
|
||||
@@ -147,33 +146,51 @@ will be built under the headline at point."
|
||||
(week (nth 0 iso-date)))
|
||||
;; ISO 8601 week format is %G-W%V(-%u)
|
||||
(org-datetree--find-create
|
||||
"^\\*+[ \t]+\\([12][0-9]\\{3\\}\\)\\(\\s-*?\
|
||||
\\([ \t]:[[:alnum:]:_@#%%]+:\\)?\\s-*$\\)"
|
||||
weekyear nil nil
|
||||
(format-time-string "%G" time))
|
||||
"\\([12][0-9]\\{3\\}\\)"
|
||||
weekyear nil nil (format-time-string "%G" time) t)
|
||||
(org-datetree--find-create
|
||||
"^\\*+[ \t]+%d-W\\([0-5][0-9]\\)$"
|
||||
weekyear week nil
|
||||
(format-time-string "%G-W%V" time))
|
||||
"%d-W\\([0-5][0-9]\\)"
|
||||
weekyear week nil (format-time-string "%G-W%V" time) t)
|
||||
;; For the actual day we use the regular date instead of ISO week.
|
||||
(org-datetree--find-create
|
||||
"^\\*+[ \t]+%d-%02d-\\([0123][0-9]\\) \\w+$"
|
||||
year month day))))
|
||||
"%d-%02d-\\([0123][0-9]\\) \\w+" year month day nil t))))
|
||||
|
||||
(defun org-datetree--find-create
|
||||
(regex-template year &optional month day insert)
|
||||
(regex-template year &optional month day insert match-title)
|
||||
"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
|
||||
arguments.
|
||||
|
||||
If MATCH-TITLE is non-nil, REGEX-TEMPLATE is matched against
|
||||
heading title and the exact regexp matched against heading line is:
|
||||
|
||||
(format org-complex-heading-regexp-format
|
||||
(format regex-template year month day))
|
||||
|
||||
If MATCH-TITLE is nil, the regexp matched against heading line is
|
||||
REGEX-TEMPLATE:
|
||||
|
||||
(format regex-template year month day)
|
||||
|
||||
Match group 1 in REGEX-TEMPLATE is compared against the specified date
|
||||
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))
|
||||
;; ensure that the first match group in REGEX-TEMPLATE
|
||||
;; is the first inside `org-complex-heading-regexp-format'
|
||||
(when (and match-title
|
||||
(not (string-match-p "\\\\(\\?1:" regex-template))
|
||||
(string-match "\\\\(" regex-template))
|
||||
(setq regex-template (replace-match "\\(?1:" nil t regex-template)))
|
||||
(let ((re (if match-title
|
||||
(format org-complex-heading-regexp-format
|
||||
(format regex-template year month day))
|
||||
(format regex-template year month day)))
|
||||
match)
|
||||
(goto-char (point-min))
|
||||
(while (and (setq match (re-search-forward re nil t))
|
||||
(goto-char (match-beginning 1))
|
||||
(goto-char (match-beginning 1))
|
||||
(< (string-to-number (match-string 1)) (or day month year))))
|
||||
(cond
|
||||
((not match)
|
||||
@@ -181,9 +198,9 @@ inserted into the buffer."
|
||||
(unless (bolp) (insert "\n"))
|
||||
(org-datetree-insert-line year month day insert))
|
||||
((= (string-to-number (match-string 1)) (or day month year))
|
||||
(beginning-of-line))
|
||||
(forward-line 0))
|
||||
(t
|
||||
(beginning-of-line)
|
||||
(forward-line 0)
|
||||
(org-datetree-insert-line year month day insert)))))
|
||||
|
||||
(defun org-datetree-insert-line (year &optional month day text)
|
||||
@@ -205,11 +222,11 @@ inserted into the buffer."
|
||||
(save-excursion
|
||||
(insert "\n")
|
||||
(org-indent-line)
|
||||
(org-insert-time-stamp
|
||||
(org-insert-timestamp
|
||||
(org-encode-time 0 0 0 day month year)
|
||||
nil
|
||||
(eq org-datetree-add-timestamp 'inactive))))
|
||||
(beginning-of-line))
|
||||
(forward-line 0))
|
||||
|
||||
(defun org-datetree-file-entry-under (txt d)
|
||||
"Insert a node TXT into the date tree under date D."
|
||||
|
||||
Reference in New Issue
Block a user