Ver Fonte

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 <steuer@unibw-hamburg.de>
<http://permalink.gmane.org/gmane.emacs.orgmode/112111>
Nicolas Goaziou há 8 anos atrás
pai
commit
add0be3093
1 ficheiros alterados com 7 adições e 5 exclusões
  1. 7 5
      lisp/org-duration.el

+ 7 - 5
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)))