From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id 4HXAIDUbt2PKdQEAbAwnHQ (envelope-from ) for ; Thu, 05 Jan 2023 19:47:17 +0100 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id eHPlHzUbt2OlQwAAG6o9tA (envelope-from ) for ; Thu, 05 Jan 2023 19:47:17 +0100 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 19461D129 for ; Thu, 5 Jan 2023 19:47:17 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pDVFa-0004uI-7X; Thu, 05 Jan 2023 13:46:02 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pDVFN-0004p9-Vz for emacs-orgmode@gnu.org; Thu, 05 Jan 2023 13:45:54 -0500 Received: from mail-lf1-x129.google.com ([2a00:1450:4864:20::129]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pDVFL-0007DA-5g for emacs-orgmode@gnu.org; Thu, 05 Jan 2023 13:45:49 -0500 Received: by mail-lf1-x129.google.com with SMTP id b3so56282078lfv.2 for ; Thu, 05 Jan 2023 10:45:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:message-id:in-reply-to:date:subject:cc:to:from :user-agent:references:from:to:cc:subject:date:message-id:reply-to; bh=zHvp1WXBjqlrdNkbwKFOJ4cdb4inUyODr4eAw8cvC2c=; b=FyRWjolGoPK4fwlmhCl+3GjKIIO8QFg8mT/lsrnpJKxY7cFyzUDOaXXe8ULl9kg4YG ih+R77j+s1NFS+1dpP5WV8FZfq3j2b28hdSibRGDxgRxCzT5NNWUi1cjGDBNDQdobHg1 bdURVGqsXDJs1WTVYwPUweu8PP7kLEbDttQV9TSS/Pui8Oo89orb94gR28XOgVh2Riip 2dEKcR85Jvyb8TvSvun255ZkZXGKLXxMRZR6LxOKmPEsUgwXzTnLeXB2EQ5iCnhPhgrZ HjP3b1zSUbU6eB6iI74P6moMc0jO8RAFMhzKyJ5vtod2J5RxknM1CcLxlhy4ieQlnqb1 bSNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:message-id:in-reply-to:date:subject:cc:to:from :user-agent:references:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=zHvp1WXBjqlrdNkbwKFOJ4cdb4inUyODr4eAw8cvC2c=; b=BXMCpWvrjGnyEJ2t53ScjZ9waGGbSDzUDgQovHPNNtnzFCWSKUxgYoareUUKKIAG8l coh6fU8lainP8LD/Nqp7/3cFSKHf17PNqRR5vFWHkNnHwcfN3p2VJS8lpNmQRy3dVuVw SKKxC1snaY608QO30OEJB3Hb/xduXS4yyWl73V0xe83/iJ490jsnYbmyc1dO/W9BNzU/ 670/VJfUvLOjs9KSkUSc0FG8TCsrazS+4pYBT6LzUFpPOWsLw+4JkbRxw8E9P6j8liH5 C0rdGTXL68Z6wqza+xTHhLFcLqxeuedxT7uMPCunYog9E0mgjvBZaF8uhoPtVj3xeOEv LK8g== X-Gm-Message-State: AFqh2ko7u+/8XyhtNuNSv60I3F/+2iOyfF41EuZiF1M3OXUOQFDqQqBC FMNn+TVxYExForaabOSCeg7TlY+qQJGDRQ== X-Google-Smtp-Source: AMrXdXs/mvZEY4QqWVHf/sQJ3Cgiv23CvmYE659GvWidYOjNJtZtE0MTWyAptylfSngHG8qvHIanlg== X-Received: by 2002:a05:6512:3085:b0:4b4:f9df:c6ab with SMTP id z5-20020a056512308500b004b4f9dfc6abmr17077870lfd.60.1672944345088; Thu, 05 Jan 2023 10:45:45 -0800 (PST) Received: from laptop ([95.182.105.145]) by smtp.gmail.com with ESMTPSA id y16-20020ac255b0000000b004cb0242704asm4589355lfg.255.2023.01.05.10.45.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Jan 2023 10:45:44 -0800 (PST) References: <87zgaxfgi3.fsf@localhost> User-agent: mu4e 1.8.13; emacs 30.0.50 From: Ilya Chernyshov To: Ihor Radchenko Cc: emacs-orgmode@gnu.org Subject: Re: [PATCH] org-datetree.el: Allow datetrees with TODO, priority, tags Date: Fri, 06 Jan 2023 00:40:16 +0600 In-reply-to: <87zgaxfgi3.fsf@localhost> Message-ID: <87pmbsrfak.fsf@gmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2a00:1450:4864:20::129; envelope-from=ichernyshovvv@gmail.com; helo=mail-lf1-x129.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN ARC-Seal: i=1; s=key1; d=yhetil.org; t=1672944437; a=rsa-sha256; cv=none; b=Z8i4b4jX9It0PFXA6zeV1TYZ8frQV0cRZF7lJ01+oiuw70554jhFXOqPSwj4zw886cMknZ WIUO7IW7d0+kbmG3trR8xuOxKWb1YillCsyTXJWKViYlMAVB33P2Kywhe5ZQZzOI2HrnQD HKCqzqFJRlwurkYTFUjlkxIH4+sKpE10WWAtUqGMzu8U0bDwlCbzmWSRWAsZd/26c7ntSn dVJVhi8X/FRr+DvkymKmBDc00MqzCC5K4UWGwfeN+P7a85U8T3DtneudOnYS9cMBaAM++o BtRcUrZUV70FNY5Hdo23r2qC+u9lXdPrcyc/k6Qx/u07yTM1JHrQc/gC1vubSQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=FyRWjolG; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1672944437; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=zHvp1WXBjqlrdNkbwKFOJ4cdb4inUyODr4eAw8cvC2c=; b=kfTJB97eFf/Pt6KfYe1fcsKiv9ppZjxAlLKZQZoZx75A5xbk6xUrIH2WNBC3W+aGhoy4oe +63OZ8HfkjQUPQBUgRuYIzojxzzUeJuJE5PHmGQQPIL/bVq2uSor2PSE6zi0nO5S73uaEx npDAgXaLybVdA+5yTqIklJoNqLpEFJ3yAts0nf7krYce/A/56z7Y++B1vfAwG+IPHescHl fevR8QkbCImi3vYxXyq2Vd5/zCz8c1XCXjMgNEct8ETtEHIQTF0I3AN8uUdJ9nIQBfHGn3 Q5DIFCpHpkzlMdtn0fd52Khiu2smr1mvlmrzEPPaDiEgQ2J3uAnUjsxge+rPYg== X-Spam-Score: -9.47 X-Migadu-Queue-Id: 19461D129 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=FyRWjolG; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=gmail.com X-Migadu-Scanner: scn0.migadu.com X-Migadu-Spam-Score: -9.47 X-TUID: WZsdYN2ruhKw --=-=-= Content-Type: text/plain; format=flowed > Thanks! > Instead of manually constructing the regexp, you can use > `org-complex-heading-regexp-format'. Thanks for the tip. Applied changes in the new patch. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-lisp-org-datetree.el-Allow-datetrees-with-TODO-prior.patch >From 8a32385ae2ccbbc0caa35eda9a8184c165e3afcd Mon Sep 17 00:00:00 2001 From: Ilya Chernyshov Date: Thu, 15 Dec 2022 02:08:15 +0600 Subject: [PATCH] lisp/org-datetree.el: Allow datetrees with TODO, priority, tags * org-datetree.el (org-datetree--find-create, org-datetree--find-create-group, org-datetree-find-iso-week-create): Allow finding a datetree with TODO state, priority, tags, statistics cookies, or COMMENT keyword. * testing/lisp/test-org-datetree.el (test-org-datetree/find-date-create, test-org-datetree/find-iso-week-create): Add tests for a datetree with tags, TODO or priority keywords. * etc/ORG-NEWS (Datetree structure headlines can now be complex): Document the change. * doc/org-manual.org: Update datetree definition. --- doc/org-manual.org | 3 ++- etc/ORG-NEWS | 7 +++++++ lisp/org-datetree.el | 23 +++++++++++------------ testing/lisp/test-org-datetree.el | 16 ++++++++++++++++ 4 files changed, 36 insertions(+), 13 deletions(-) diff --git a/doc/org-manual.org b/doc/org-manual.org index f3b77ebad..f816f8725 100644 --- a/doc/org-manual.org +++ b/doc/org-manual.org @@ -22507,7 +22507,8 @@ level. ,*** 2022-10-08 Saturday #+end_example -Tags are allowed in the tree structure. +TODO state, priority, tags, statistics cookies, and COMMENT keywords +are allowed in the tree structure. [fn:31] This is always the other, not the user. See the variable ~org-link-from-user-regexp~. diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index c5d9bdf6e..0c9c7bf91 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -55,6 +55,13 @@ document header: ,#+LATEX_HEADER: \DefineVerbatimEnvironment{lstlisting}{Verbatim}{...whatever...} #+END_src +** New features +*** Datetree structure headlines can now be complex + +~org-datetree--find-create~ function can now find datetree +headlines with TODO state, priority, tags, statistics cookies, or +COMMENT keyword + * Version 9.6 ** Important announcements and breaking changes diff --git a/lisp/org-datetree.el b/lisp/org-datetree.el index 035ef047a..cebb4e279 100644 --- a/lisp/org-datetree.el +++ b/lisp/org-datetree.el @@ -99,15 +99,14 @@ 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-*$\\)" + "\\([12][0-9]\\{3\\}\\)" year) (org-datetree--find-create - "^\\*+[ \t]+%d-\\([01][0-9]\\) \\w+$" + "%d-\\([01][0-9]\\) \\w+" year month) (when (eq time-grouping 'day) (org-datetree--find-create - "^\\*+[ \t]+%d-%02d-\\([0123][0-9]\\) \\w+$" + "%d-%02d-\\([0123][0-9]\\) \\w+" year month day))))) ;;;###autoload @@ -147,17 +146,16 @@ 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-*$\\)" + "\\([12][0-9]\\{3\\}\\)" weekyear nil nil (format-time-string "%G" time)) (org-datetree--find-create - "^\\*+[ \t]+%d-W\\([0-5][0-9]\\)$" + "%d-W\\([0-5][0-9]\\)" weekyear week nil (format-time-string "%G-W%V" time)) ;; For the actual day we use the regular date instead of ISO week. (org-datetree--find-create - "^\\*+[ \t]+%d-%02d-\\([0123][0-9]\\) \\w+$" + "%d-%02d-\\([0123][0-9]\\) \\w+" year month day)))) (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))) match) (goto-char (point-min)) (while (and (setq match (re-search-forward re nil t)) - (goto-char (match-beginning 1)) - (< (string-to-number (match-string 1)) (or day month year)))) + (goto-char (match-beginning 5)) + (< (string-to-number (match-string 5)) (or day month year)))) (cond ((not match) (goto-char (point-max)) (unless (bolp) (insert "\n")) (org-datetree-insert-line year month day insert)) - ((= (string-to-number (match-string 1)) (or day month year)) + ((= (string-to-number (match-string 5)) (or day month year)) (beginning-of-line)) (t (beginning-of-line) diff --git a/testing/lisp/test-org-datetree.el b/testing/lisp/test-org-datetree.el index 59ef8c33b..bd06462f2 100644 --- a/testing/lisp/test-org-datetree.el +++ b/testing/lisp/test-org-datetree.el @@ -58,6 +58,14 @@ (let ((org-datetree-add-timestamp nil)) (org-datetree-find-date-create '(3 29 2012))) (org-trim (buffer-string))))) + ;; Do not create new day node when one exists. + (should + (string-match + "\\`\\* DONE 2012 :tag1:tag2:\n\n\\*\\* TODO 2012-03 .*\n\n\\*\\*\\* \\[#A\\] 2012-03-29 .*\\'" + (org-test-with-temp-text "* DONE 2012 :tag1:tag2:\n\n** TODO 2012-03 month\n\n*** [#A] 2012-03-29 day :tag3:" + (let ((org-datetree-add-timestamp nil)) + (org-datetree-find-date-create '(3 29 2012))) + (org-trim (buffer-string))))) ;; Sort new entry in right place. (should (string-match @@ -163,6 +171,14 @@ (let ((org-datetree-add-timestamp nil)) (org-datetree-find-iso-week-create '(12 31 2014))) (org-trim (buffer-string))))) + ;; Do not create new day node when one exists. + (should + (string-match + "\\`\\* TODO \\[#B\\] 2015\n\n\\*\\* 2015-W01 :tag1:\n\n\\*\\*\\* 2014-12-31 .*\\'" + (org-test-with-temp-text "* TODO [#B] 2015\n\n** 2015-W01 :tag1:\n\n*** 2014-12-31 day" + (let ((org-datetree-add-timestamp nil)) + (org-datetree-find-iso-week-create '(12 31 2014))) + (org-trim (buffer-string))))) ;; Sort new entry in right place. (should (string-match -- 2.39.0 --=-=-= Content-Type: text/plain; format=flowed -- Best, Ilya --=-=-=--