[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] doing something yesterday?

From: Marco Wahl
Subject: Re: [O] doing something yesterday?
Date: Wed, 04 Jan 2017 11:50:24 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux)


> I have a number of habits I keep track of in Org, with repeat TODO:s.
> They should be done every day.
> Quite often I want to change the "DONE" date from today to yesterday.
> As it is now, I manually change the done date and the next date.
> Can I achive this automatically somehow, by advicing some function
> perhaps?

There has been a similar question a few days ago and I did some

There is already `org-todo-yesterday'.  Unfortunately the function does
not care about property LAST_REPEAT which is relevant for tracking
habits.  Further note that `org-todo-yesterday' relies on variable

Another approach is to advice `current-time' to use a certain time.
This looks promising AFAICS.

The setting of property LAST_REPEAT is not dependend on `current-time'
yet, though.  This coulb be changed in the Org sources e.g. like:

#+begin_src diff
modified   lisp/org.el
@@ -13220,7 +13220,8 @@ This function is run automatically after each state 
change to a DONE state."
        (org-todo to-state))
       (when (or org-log-repeat (org-entry-get nil "CLOCK"))
        (org-entry-put nil "LAST_REPEAT" (format-time-string
-                                         (org-time-stamp-format t t))))
+                                         (org-time-stamp-format t t)
+                                         (current-time))))
       (when org-log-repeat
        (if (or (memq 'org-add-log-note (default-value 'post-command-hook))
                (memq 'org-add-log-note post-command-hook))

The interface could be set and unset the advice for `current-time'.


;; #+BEGIN_SRC emacs-lisp
(let (freeze-time-day)
  (defun freeze-time-adviser (x)
    (append (date-to-time (concat freeze-time-day " 11:55")) (list 0 0)))

  (defun freeze-time-unfreeze ()
    (if (advice-member-p #'freeze-time-adviser #'current-time)
        (advice-remove #'current-time #'freeze-time-adviser)))

  (defun freeze-time-to (yyyy-mm-dd-date-string)
    "Advice `current-time' to return time YYYY-MM-DD-DATE-STRING at 11:55am."
    (interactive (list (org-read-date)))
    (setf freeze-time-day yyyy-mm-dd-date-string)
    (advice-add #'current-time :filter-return #'freeze-time-adviser)))
;; #+END_SRC

(From https://github.com/marcowahl/little-helpers/blob/master/little-helpers.el)

Does this sound reasonable?

Best regards


reply via email to

[Prev in Thread] Current Thread [Next in Thread]