diff --git a/config.org b/config.org index 97efc29..1095bc9 100644 --- a/config.org +++ b/config.org @@ -2983,10 +2983,25 @@ My attention span being what it is, I often forget to update TODO entries in my If nil, then use the current time.") -(defadvice! ~/org-override-time (old-fn) +;; HACK: Why does Emacs have so many independently defined time functions +(defadvice! ~/org-override-time (old-fn &rest args) "Use `org-todo-time' as the current time if it is specified." - :around #'org-current-time - (or org-todo-time (funcall old-fn))) + :around (list #'org-current-time #'org-auto-repeat-maybe) + (if org-todo-time + (cl-letf (((symbol-function #'current-time) + (lambda (&rest _) org-todo-time)) + (float-time-old (symbol-function #'float-time)) + ((symbol-function #'float-time) + (lambda (&optional time) (funcall float-time-old (or time org-todo-time)))) + (time-subtract-old (symbol-function #'time-subtract)) + ((symbol-function #'time-subtract) + (lambda (a b) (funcall time-subtract-old (or a org-todo-time) (or b org-todo-time)))) + (decode-time-old (symbol-function #'decode-time)) + ((symbol-function #'decode-time) + (lambda (&optional time &rest args) + (apply decode-time-old (or time org-todo-time) args)))) + (apply old-fn args)) + (apply old-fn args))) #+end_src We can then define and bind alternate versions of ~org-todo~ and ~org-agenda-todo~ that allow us to pick the time to set.