mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2025-01-05 11:45:52 +00:00
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/
This commit is contained in:
parent
91a7e272b3
commit
c4688a1437
@ -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))
|
||||
|
12
lisp/org.el
12
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?"
|
||||
|
Loading…
Reference in New Issue
Block a user