From add0be30935412d37934d9ac4fa7315da17ced58 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Tue, 14 Feb 2017 09:58:26 +0100 Subject: [PATCH] org-duration: Tolerate leading and trailing blanks in durations * lisp/org-duration.el (org-duration--h:mm-re): (org-duration--h:mm:ss-re): Tolerate leading in trailing blanks. Change into a defconst. (org-duration-set-regexps): Tolerate leading in trailing blanks. Reported-by: Detlef Steuer --- lisp/org-duration.el | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lisp/org-duration.el b/lisp/org-duration.el index 6ac7b4f4f..5874a1011 100644 --- a/lisp/org-duration.el +++ b/lisp/org-duration.el @@ -198,12 +198,14 @@ than a day uses \"h\" unit instead." ;;; Internal variables and functions -(defvar org-duration--h:mm-re "\\`[0-9]+\\(?::[0-9]\\{2\\}\\)\\{1,2\\}\\'" +(defconst org-duration--h:mm-re + "\\`[ \t]*[0-9]+\\(?::[0-9]\\{2\\}\\)\\{1,2\\}[ \t]*\\'" "Regexp matching a duration expressed with H:MM or H:MM:SS format. See `org-duration--h:mm:ss-re' to only match the latter. Hours can use any number of digits.") -(defvar org-duration--h:mm:ss-re "\\`[0-9]+\\(?::[0-9]\\{2\\}\\)\\{2\\}\\'" +(defconst org-duration--h:mm:ss-re + "\\`[ \t]*[0-9]+\\(?::[0-9]\\{2\\}\\)\\{2\\}[ \t]*\\'" "Regexp matching a duration expressed H:MM:SS format. See `org-duration--h:mm-re' to also support H:MM format. Hours can use any number of digits.") @@ -249,12 +251,12 @@ When optional argument CANONICAL is non-nil, refer to org-duration-units)) t))) (setq org-duration--full-re - (format "\\`%s\\(?:[ \t]+%s\\)*\\'" + (format "\\`[ \t]*%s\\(?:[ \t]+%s\\)*[ \t]*\\'" org-duration--unit-re org-duration--unit-re)) (setq org-duration--mixed-re - (format "\\`\\(?1:%s\\(?:[ \t]+%s\\)*\\)[ \t]+\ -\\(?2:[0-9]+\\(?::[0-9][0-9]\\)\\{1,2\\}\\)\\'" + (format "\\`[ \t]*\\(?1:%s\\(?:[ \t]+%s\\)*\\)[ \t]+\ +\\(?2:[0-9]+\\(?::[0-9][0-9]\\)\\{1,2\\}\\)[ \t]*\\'" org-duration--unit-re org-duration--unit-re))) -- 2.11.4.GIT