From 269c5a85bcf65432ad7f9df02a9dc08ebca73956 Mon Sep 17 00:00:00 2001 From: Carsten Dominik Date: Sat, 29 Nov 2008 18:49:30 +0100 Subject: [PATCH] New ways to specify time comparison values in property searches. In addition to "", "", "", and "", there are more special values accepted now in time comparisons in property searches: You may use strings like =<+3d>= or =<-2w>=, with units d, w, m, and y for day, week, month, and year, respectively Thanks to Linday Todd for this proposal. --- ORGWEBPAGE/Changes.org | 10 ++++++++++ doc/ChangeLog | 5 +++++ doc/org.texi | 12 +++++++----- lisp/ChangeLog | 2 ++ lisp/org.el | 20 ++++++++++++++------ 5 files changed, 38 insertions(+), 11 deletions(-) diff --git a/ORGWEBPAGE/Changes.org b/ORGWEBPAGE/Changes.org index d177cc60d..f92634d60 100644 --- a/ORGWEBPAGE/Changes.org +++ b/ORGWEBPAGE/Changes.org @@ -89,6 +89,16 @@ A new option, `org-tags-exclude-from-inheritance', allows to specify an exclusion list for inherited tags. +*** More special values for time comparisons in property searches + + In addition to ==, ==, ==, and + ==, there are more special values accepted now in + time comparisons in property searches: You may use strings + like =<+3d>= or =<-2w>=, with units d, w, m, and y for day, + week, month, and year, respectively + + Thanks to Linday Todd for this proposal. + * Version 6.13 ** Overview diff --git a/doc/ChangeLog b/doc/ChangeLog index ea60e6e20..200735047 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,8 @@ +2008-11-29 Carsten Dominik + + * org.texi (Property searches): Document new special values for + time comparisons. + 2008-11-27 Carsten Dominik * org.texi (Tag inheritance): Refine the description of tag diff --git a/doc/org.texi b/doc/org.texi index a43334715..e3e148564 100644 --- a/doc/org.texi +++ b/doc/org.texi @@ -3903,11 +3903,13 @@ quotes, a string comparison is done, and the same operators are allowed. @item If the comparison value is enclosed in double quotes @emph{and} angular brackets (like @samp{DEADLINE<="<2008-12-24 18:30>"}), both values are -assumed to be date/time specifications in the standard Org way@footnote{The -only special values that will be recognized are @samp{""} for now -(including time), and @samp{""}, @samp{}, and -@samp{} for these days at 0:00 hours, i.e. without a time -specification.}, and the comparison will be done accordingly. +assumed to be date/time specifications in the standard Org way, and the +comparison will be done accordingly. Special values that will be recognized +are @code{""} for now (including time), and @code{""}, and +@code{""} for these days at 0:00 hours, i.e. without a time +specification. Also strings like @code{"<+5d>"} or @code{"<-2m>"} with units +@code{d}, @code{w}, @code{m}, and @code{y} for day, week, month, and year, +respectively, can be used. @item If the comparison value is enclosed in curly braces, a regexp match is performed, with @samp{=} meaning that the diff --git a/lisp/ChangeLog b/lisp/ChangeLog index d69912195..b4ef4b728 100755 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,7 @@ 2008-11-29 Carsten Dominik + * org.el (org-matcher-time): Recognize more special values. + * org-gnus.el (fboundp): Fix defvaralias for XEmacs. 2008-11-27 Carsten Dominik diff --git a/lisp/org.el b/lisp/org.el index 6bb862354..2745ebd51 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -9342,12 +9342,20 @@ epoch to the beginning of today (00:00)." (append '(0 0 0) (nthcdr 3 (decode-time)))))) (defun org-matcher-time (s) - (cond - ((string= s "") (float-time)) - ((string= s "") (org-time-today)) - ((string= s "") (+ 86400.0 (org-time-today))) - ((string= s "") (- (org-time-today) 86400.0)) - (t (org-2ft s)))) + "Interprete a time comparison value." + (save-match-data + (cond + ((string= s "") (float-time)) + ((string= s "") (org-time-today)) + ((string= s "") (+ 86400.0 (org-time-today))) + ((string= s "") (- (org-time-today) 86400.0)) + ((string-match "^<\\([-+][0-9]+\\)\\([dwmy]\\)>$" s) + (+ (org-time-today) + (* (string-to-number (match-string 1 s)) + (cdr (assoc (match-string 2 s) + '(("d" . 86400.0) ("w" . 604800.0) + ("m" . 2678400.0) ("y" . 31557600.0))))))) + (t (org-2ft s))))) (defun org-match-any-p (re list) "Does re match any element of list?"