From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id CJlQCb2381+aHAAA0tVLHw (envelope-from ) for ; Tue, 05 Jan 2021 00:50:05 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id WIkjBb2381/qFQAA1q6Kng (envelope-from ) for ; Tue, 05 Jan 2021 00:50:05 +0000 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 8F0439404C4 for ; Tue, 5 Jan 2021 00:50:04 +0000 (UTC) Received: from localhost ([::1]:36886 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kwaXz-0002x7-Hd for larch@yhetil.org; Mon, 04 Jan 2021 19:50:03 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38922) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kwaX6-0002vN-9F for emacs-orgmode@gnu.org; Mon, 04 Jan 2021 19:49:08 -0500 Received: from janet.servers.dxld.at ([2a01:4f8:201:89f4::1]:43422) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kwaX4-0005Sd-AR for emacs-orgmode@gnu.org; Mon, 04 Jan 2021 19:49:07 -0500 Received: janet.servers.dxld.at; Tue, 05 Jan 2021 01:48:57 +0100 From: =?UTF-8?q?Daniel=20Gr=C3=B6ber?= To: emacs-orgmode@gnu.org Subject: [PATCH] org-macs: Allow specifying relative time in hours Date: Tue, 5 Jan 2021 01:48:55 +0100 Message-Id: <20210105004855.4315-1-dxld@darkboxed.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-bar: - Received-SPF: pass client-ip=2a01:4f8:201:89f4::1; envelope-from=dxld@darkboxed.org; helo=janet.servers.dxld.at X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, 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.23 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" X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: 2.77 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=darkboxed.org (policy=none); spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Queue-Id: 8F0439404C4 X-Spam-Score: 2.77 X-Migadu-Scanner: scn1.migadu.com X-TUID: RPksAIw/+qiD This adds support for date expressions such as +12h to org-matcher-time. The regexp this function uses to parse such relative expressions already includes the "h" character but doesn't actually handle that case. AFAICT org-mode commit ec921a2a68 ("Support hourly repeat cookies") neglected to add support here. --- doc/org-manual.org | 14 ++++++++------ lisp/org-macs.el | 5 +++-- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/doc/org-manual.org b/doc/org-manual.org index b015b502c..740549cf5 100644 --- a/doc/org-manual.org +++ b/doc/org-manual.org @@ -6052,15 +6052,17 @@ various inputs are interpreted, the items filled in by Org mode are in | =2012-w04-5= | \rArr{} Same as above | Furthermore you can specify a relative date by giving, as the /first/ -thing in the input: a plus/minus sign, a number and a letter---=d=, -=w=, =m= or =y=---to indicate change in days, weeks, months, or -years. With a single plus or minus, the date is always relative to -today. With a double plus or minus, it is relative to the default -date. If instead of a single letter, you use the abbreviation of day -name, the date is the Nth such day, e.g.: +thing in the input: a plus/minus sign, a number and a letter---=h=, +=d=, =w=, =m= or =y=---to indicate a change in hours, days, weeks, +months, or years. With =h= the date is relative to the current time, +with the other letters and a single plus or minus, the date is +relative to today at 00:00. With a double plus or minus, it is +relative to the default date. If instead of a single letter, you use +the abbreviation of day name, the date is the Nth such day, e.g.: | =+0= | \rArr{} today | | =.= | \rArr{} today | +| =+2h= | \rArr{} two hours from now | | =+4d= | \rArr{} four days from today | | =+4= | \rArr{} same as +4d | | =+2w= | \rArr{} two weeks from today | diff --git a/lisp/org-macs.el b/lisp/org-macs.el index 56afdf6ef..d40ed1a04 100644 --- a/lisp/org-macs.el +++ b/lisp/org-macs.el @@ -1228,10 +1228,11 @@ Return 0. if S is not recognized as a valid value." ((string= s "") (+ 86400.0 today)) ((string= s "") (- today 86400.0)) ((string-match "\\`<\\([-+][0-9]+\\)\\([hdwmy]\\)>\\'" s) - (+ today + (+ (if (string= (match-string 2 s) "h") (float-time) today) (* (string-to-number (match-string 1 s)) (cdr (assoc (match-string 2 s) - '(("d" . 86400.0) ("w" . 604800.0) + '(("h" . 3600.0) + ("d" . 86400.0) ("w" . 604800.0) ("m" . 2678400.0) ("y" . 31557600.0))))))) ((string-match org-ts-regexp0 s) (org-2ft s)) (t 0.))))) -- 2.20.1