From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id cNgJL8XTMF+OewAA0tVLHw (envelope-from ) for ; Mon, 10 Aug 2020 04:57:41 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id qFMqKsXTMF9pKwAAbx9fmQ (envelope-from ) for ; Mon, 10 Aug 2020 04:57:41 +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 AD8C59402CB for ; Mon, 10 Aug 2020 04:57:40 +0000 (UTC) Received: from localhost ([::1]:56366 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k4zsQ-0000uv-F9 for larch@yhetil.org; Mon, 10 Aug 2020 00:57:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59510) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k4zs4-0000uT-HV for emacs-orgmode@gnu.org; Mon, 10 Aug 2020 00:57:16 -0400 Received: from pb-smtp2.pobox.com ([64.147.108.71]:53603) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k4zs2-0001gL-8a for emacs-orgmode@gnu.org; Mon, 10 Aug 2020 00:57:15 -0400 Received: from pb-smtp2.pobox.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id EE3087FE32; Mon, 10 Aug 2020 00:57:10 -0400 (EDT) (envelope-from kyle@kyleam.com) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:in-reply-to:references:date:message-id:mime-version :content-type; s=sasl; bh=cItFAB4+7z/8NfuXjq48R9jPg0E=; b=e3UsY/ CXeJ5z/Ov5ttLKch6HPv/5o1LkRycqW5wdLWsX7KWqiSlEgbRUthBRPkkkFMDLgq LLMhhbzNXk4fG+wGu5pc8Lnvo1g7fmlXbuWEBzDznxxNECMkN7Vi4qyRzuiCwh+I P98tyn7zJRLdlfJymUdjEGHquOTtbcCv912mk= Received: from pb-smtp2.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id E64BE7FE31; Mon, 10 Aug 2020 00:57:10 -0400 (EDT) (envelope-from kyle@kyleam.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=kyleam.com; h=from:to:cc:subject:in-reply-to:references:date:message-id:mime-version:content-type; s=mesmtp; bh=F5/w4kTSZHTcd3sfvbsCC54D8U4hvvJa4aKhiI6U53s=; b=fVkTqstI1l6OWuACV7fYzChGoP47VFj/vw4dQglonLGFads2yXB5XSibQMW2PGEP6Po1MiuRL7IO3BCzc+7khpXwmDEXFxIjKd6qmHx+BYDTwF+FiuHgBhiIXaLEAygIzWAaEJhIpneucRRL79NEwpnPNmRjqas0oVMwvLRz91c= Received: from localhost (unknown [45.33.91.115]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp2.pobox.com (Postfix) with ESMTPSA id 704827FE30; Mon, 10 Aug 2020 00:57:10 -0400 (EDT) (envelope-from kyle@kyleam.com) From: Kyle Meyer To: No Wayman Subject: Re: [PATCH] org-get-cursor-date regexp patch In-Reply-To: <87tuxkc1zp.fsf@gmail.com> References: <87tuxkc1zp.fsf@gmail.com> Date: Mon, 10 Aug 2020 00:57:08 -0400 Message-ID: <87r1sf9jyz.fsf@kyleam.com> MIME-Version: 1.0 Content-Type: text/plain X-Pobox-Relay-ID: F2C6CB8E-DAC5-11EA-A2DC-2F5D23BA3BAF-24757444!pb-smtp2.pobox.com Received-SPF: pass client-ip=64.147.108.71; envelope-from=kyle@kyleam.com; helo=pb-smtp2.pobox.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/10 00:57:11 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=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: , Cc: emacs-orgmode@gnu.org Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=pobox.com header.s=sasl header.b=e3UsY/ C; dkim=pass header.d=kyleam.com header.s=mesmtp header.b=fVkTqstI; dmarc=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-Spam-Score: -1.21 X-TUID: zDR2IO388QIz Thanks for the patch. No Wayman writes: > The regular expression in `org-get-cursor-date' assumes the time > grid string will have two digits in the hour portion of the time > strng. > However, the grid time string does not always have two digits. For > example: > > " 8:00......" Makes sense. IMO it'd be nice to see something along the lines of this explanation in the commit message itself. > The attached patch accounts for this and uses the rx macro to > communicate the intent of the regular expression more clearly. > > From 4724b4cc5e9600da60b465c4c2f1968b75c7c31d Mon Sep 17 00:00:00 2001 > From: Nicholas Vollmer > Date: Sun, 2 Aug 2020 14:42:34 -0400 > Subject: [PATCH] org.el: (org-get-cursor-date): Fix regular expression > > * lisp/org.el Fix regular expression. The function name is missing here: * lisp/org.el (org-get-cursor-date): ... > --- > lisp/org.el | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/lisp/org.el b/lisp/org.el > index ee8be256d..37136cc48 100644 > --- a/lisp/org.el > +++ b/lisp/org.el > @@ -18728,10 +18728,11 @@ If WITH-TIME is non-nil, returns the time of the event at point (in > the agenda) or the current time of the day; otherwise returns the > earliest time on the cursor date that Org treats as that date > (bearing in mind `org-extend-today-until')." > - (let (date day defd tp hod mod) > + (let ((hhmm-regexp (rx (seq (group (** 1 2 digit)) ":" (group (= 2 digit))))) > + date day defd tp hod mod) > (when with-time > (setq tp (get-text-property (point) 'time)) > - (when (and tp (string-match "\\([0-9][0-9]\\):\\([0-9][0-9]\\)" tp)) > + (when (and tp (string-match hhmm-regexp tp)) > (setq hod (string-to-number (match-string 1 tp)) > mod (string-to-number (match-string 2 tp)))) > (or tp (let ((now (decode-time))) To my eyes, the new variable doesn't add any clarity over keeping it inline. Also, I very much like rx and I'm okay if you want to stick with it here, but in this particular case I find it less readable than \\([0-9]?[0-9]\\):\\([0-9][0-9]\\) or the stricter \\([0-2]?[0-9]\\):\\([0-5][0-9]\\) If you do keep the rx change, the outer seq is superfluous: (equal (rx (seq (group (** 1 2 digit)) ":" (group (= 2 digit)))) (rx (group (** 1 2 digit)) ":" (group (= 2 digit)))) ;; => t