summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Guerry <bzg@altern.org>2012-09-26 12:06:19 +0200
committerBastien Guerry <bzg@altern.org>2012-09-26 15:53:06 +0200
commitc4688a14375e75498b79ba3f90e70d73e15566b3 (patch)
tree5507e5b6da4196ea2bd611b47f8e8ce4d0526789
parent91a7e272b36cbdc58825e1a033b4457d70d98106 (diff)
downloadorg-mode-c4688a14375e75498b79ba3f90e70d73e15566b3.tar.gz
Allow to compare times using seconds (not days) when `org-agenda-todo-ignore-*' options are not nil
* org.el (org-days-to-time): Make obsolete. (org-time-stamp-to-now): Rename from `org-days-to-time'. Allow to compare time-stamps based on seconds. * org-agenda.el (org-agenda-todo-ignore-time-comparison-use-seconds): New option to compare time stamps using seconds, not days. (org-agenda-todo-custom-ignore-p) (org-agenda-check-for-timestamp-as-reason-to-ignore-todo-item): Use the new function's name and the new option. This idea came up while reading Jay McCarthy's blog here: http://jeapostrophe.github.com/blog/2012/09/19/omnifocus-and-org-mode/
-rwxr-xr-xlisp/org-agenda.el35
-rw-r--r--lisp/org.el12
2 files changed, 36 insertions, 11 deletions
diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index f9d2396..cd35bf5 100755
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -740,6 +740,20 @@ to make his option also apply to the tags-todo list."
(const :tag "Show all TODOs, even if they have a deadline" nil)
(integer :tag "Ignore if N or more days in past(-) or future(+).")))
+(defcustom org-agenda-todo-ignore-time-comparison-use-seconds nil
+ "Time unit to use when possibly ignoring an agenda item.
+
+See the docstring of various `org-agenda-todo-ignore-*' options.
+The default is to compare time stamps using days. An item is thus
+considered to be in the future if it is at least one day after today.
+Non-nil means to compare time stamps using seconds. An item is then
+considered future if it has a time value later than current time."
+ :group 'org-agenda-skip
+ :group 'org-agenda-todo-list
+ :type '(choice
+ (const :tag "Compare time with days" nil)
+ (const :tag "Compare time with seconds" t)))
+
(defcustom org-agenda-tags-todo-honor-ignore-options nil
"Non-nil means honor todo-list ...ignore options also in tags-todo search.
The variables
@@ -5035,7 +5049,8 @@ the documentation of `org-diary'."
This function is invoked if `org-agenda-todo-ignore-deadlines',
`org-agenda-todo-ignore-scheduled' or
`org-agenda-todo-ignore-timestamp' is set to an integer."
- (let ((days (org-days-to-time time)))
+ (let ((days (org-time-stamp-to-now
+ time org-agenda-todo-ignore-time-comparison-use-seconds)))
(if (>= n 0)
(>= days n)
(<= days n))))
@@ -5056,9 +5071,11 @@ This function is invoked if `org-agenda-todo-ignore-deadlines',
(re-search-forward org-scheduled-time-regexp end t)
(cond
((eq org-agenda-todo-ignore-scheduled 'future)
- (> (org-days-to-time (match-string 1)) 0))
+ (> (org-time-stamp-to-now
+ (match-string 1) org-agenda-todo-ignore-time-comparison-use-seconds) 0))
((eq org-agenda-todo-ignore-scheduled 'past)
- (<= (org-days-to-time (match-string 1)) 0))
+ (<= (org-time-stamp-to-now
+ (match-string 1) org-agenda-todo-ignore-time-comparison-use-seconds) 0))
((numberp org-agenda-todo-ignore-scheduled)
(org-agenda-todo-custom-ignore-p
(match-string 1) org-agenda-todo-ignore-scheduled))
@@ -5070,9 +5087,11 @@ This function is invoked if `org-agenda-todo-ignore-deadlines',
((eq org-agenda-todo-ignore-deadlines 'far)
(not (org-deadline-close (match-string 1))))
((eq org-agenda-todo-ignore-deadlines 'future)
- (> (org-days-to-time (match-string 1)) 0))
+ (> (org-time-stamp-to-now
+ (match-string 1) org-agenda-todo-ignore-time-comparison-use-seconds) 0))
((eq org-agenda-todo-ignore-deadlines 'past)
- (<= (org-days-to-time (match-string 1)) 0))
+ (<= (org-time-stamp-to-now
+ (match-string 1) org-agenda-todo-ignore-time-comparison-use-seconds) 0))
((numberp org-agenda-todo-ignore-deadlines)
(org-agenda-todo-custom-ignore-p
(match-string 1) org-agenda-todo-ignore-deadlines))
@@ -5095,9 +5114,11 @@ This function is invoked if `org-agenda-todo-ignore-deadlines',
(when (re-search-forward org-ts-regexp nil t)
(cond
((eq org-agenda-todo-ignore-timestamp 'future)
- (> (org-days-to-time (match-string 1)) 0))
+ (> (org-time-stamp-to-now
+ (match-string 1) org-agenda-todo-ignore-time-comparison-use-seconds) 0))
((eq org-agenda-todo-ignore-timestamp 'past)
- (<= (org-days-to-time (match-string 1)) 0))
+ (<= (org-time-stamp-to-now
+ (match-string 1) org-agenda-todo-ignore-time-comparison-use-seconds) 0))
((numberp org-agenda-todo-ignore-timestamp)
(org-agenda-todo-custom-ignore-p
(match-string 1) org-agenda-todo-ignore-timestamp))
diff --git a/lisp/org.el b/lisp/org.el
index 9b9b983..1eeb412 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -16024,10 +16024,14 @@ Don't touch the rest."
(let ((n 0))
(mapcar (lambda (x) (if (< (setq n (1+ n)) 7) (or x 0) x)) time)))
-(defun org-days-to-time (timestamp-string)
- "Difference between TIMESTAMP-STRING and now in days."
- (- (time-to-days (org-time-string-to-time timestamp-string))
- (time-to-days (current-time))))
+(define-obsolete-function-alias 'org-days-to-time 'org-time-stamp-to-now "24.3")
+
+(defun org-time-stamp-to-now (timestamp-string &optional seconds)
+ "Difference between TIMESTAMP-STRING and now in days.
+If SECONDS is non-nil, return the difference in seconds."
+ (let ((fdiff (if seconds 'time-to-seconds 'time-to-days)))
+ (- (funcall fdiff (org-time-string-to-time timestamp-string))
+ (funcall fdiff (current-time)))))
(defun org-deadline-close (timestamp-string &optional ndays)
"Is the time in TIMESTAMP-STRING close to the current date?"