emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: No Wayman <iarchivedmywholelife@gmail.com>
To: Kyle Meyer <kyle@kyleam.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: [PATCH] org-get-cursor-date regexp patch
Date: Mon, 10 Aug 2020 01:58:07 -0400	[thread overview]
Message-ID: <87tuxb59g0.fsf@gmail.com> (raw)
In-Reply-To: <87r1sf9jyz.fsf@kyleam.com>

[-- Attachment #1: Type: text/plain, Size: 754 bytes --]


> Makes sense.  IMO it'd be nice to see something along the lines 
> of this
> explanation in the commit message itself.
>
> The function name is missing here:
>
>     * lisp/org.el (org-get-cursor-date): ...

> To my eyes, the new variable doesn't add any clarity over 
> keeping it
> inline.

Addressed in attached patch.

> 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]\\)

Fair enough. My preference for how the regular expression is 
notated does not matter so long as it is the correct expression.
I've inlined your second, stricter regular expression.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: org-get-cursor-date-regexp-revised --]
[-- Type: text/x-patch, Size: 2164 bytes --]

From cad2044829e6d3ff76c2a3504564ed5bfcc36bfb Mon Sep 17 00:00:00 2001
From: Nicholas Vollmer <iarchivedmywholelife@gmail.com>
Date: Sun, 2 Aug 2020 14:42:34 -0400
Subject: [PATCH] org.el: (org-get-cursor-date): Fix regular expression

* lisp/org.el (org-get-cursor-date): Fix regular expression.

Previous regular expression assumed the time grid string will have two
digits in the hour portion of the time string.  However, the time grid
string does not always have two digits.  For example:

" 8:00......"
---
 lisp/org.el | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index ee8be256d..f8dbb6307 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -18731,22 +18731,22 @@ earliest time on the cursor date that Org treats as that date
   (let (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 "\\([0-2]?[0-9]\\):\\([0-5][0-9]\\)" tp))
 	(setq hod (string-to-number (match-string 1 tp))
-	      mod (string-to-number (match-string 2 tp))))
+              mod (string-to-number (match-string 2 tp))))
       (or tp (let ((now (decode-time)))
-	       (setq hod (nth 2 now)
-		     mod (nth 1 now)))))
+               (setq hod (nth 2 now)
+                     mod (nth 1 now)))))
     (cond
      ((eq major-mode 'calendar-mode)
       (setq date (calendar-cursor-to-date)
-	    defd (encode-time 0 (or mod 0) (or hod org-extend-today-until)
-			      (nth 1 date) (nth 0 date) (nth 2 date))))
+            defd (encode-time 0 (or mod 0) (or hod org-extend-today-until)
+                              (nth 1 date) (nth 0 date) (nth 2 date))))
      ((eq major-mode 'org-agenda-mode)
       (setq day (get-text-property (point) 'day))
       (when day
 	(setq date (calendar-gregorian-from-absolute day)
-	      defd (encode-time 0 (or mod 0) (or hod org-extend-today-until)
+              defd (encode-time 0 (or mod 0) (or hod org-extend-today-until)
 				(nth 1 date) (nth 0 date) (nth 2 date))))))
     (or defd (current-time))))
 
-- 
2.28.0


  reply	other threads:[~2020-08-10  5:59 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-02 18:54 [PATCH] org-get-cursor-date regexp patch No Wayman
2020-08-10  4:57 ` Kyle Meyer
2020-08-10  5:58   ` No Wayman [this message]
2020-08-11  0:43     ` Kyle Meyer

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=87tuxb59g0.fsf@gmail.com \
    --to=iarchivedmywholelife@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=kyle@kyleam.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).