emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: No Wayman <iarchivedmywholelife@gmail.com>
To: emacs-orgmode@gnu.org, No Wayman <iarchivedmywholelife@gmail.com>
Subject: [PATCH] org-get-cursor-date regexp patch
Date: Sun, 02 Aug 2020 14:54:34 -0400	[thread overview]
Message-ID: <87tuxkc1zp.fsf@gmail.com> (raw)

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


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......"

The attached patch accounts for this and uses the rx macro to 
communicate the intent of the regular expression more clearly.


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

From 4724b4cc5e9600da60b465c4c2f1968b75c7c31d 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 Fix regular expression.
---
 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)))
-- 
2.27.0


             reply	other threads:[~2020-08-02 18:55 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-02 18:54 No Wayman [this message]
2020-08-10  4:57 ` [PATCH] org-get-cursor-date regexp patch Kyle Meyer
2020-08-10  5:58   ` No Wayman
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=87tuxkc1zp.fsf@gmail.com \
    --to=iarchivedmywholelife@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /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).