emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* doing something yesterday?
@ 2017-01-04 10:13 joakim
  2017-01-04 10:50 ` Marco Wahl
  0 siblings, 1 reply; 2+ messages in thread
From: joakim @ 2017-01-04 10:13 UTC (permalink / raw)
  To: emacs-orgmode

Hello,

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?


-- 
Joakim Verona
joakim@verona.se

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: doing something yesterday?
  2017-01-04 10:13 doing something yesterday? joakim
@ 2017-01-04 10:50 ` Marco Wahl
  0 siblings, 0 replies; 2+ messages in thread
From: Marco Wahl @ 2017-01-04 10:50 UTC (permalink / raw)
  To: emacs-orgmode

Hi!

> 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
research...

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
`org-extend-today-until'.

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))
#+end_src

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

E.g.

;; #+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 ()
    (interactive)
    (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)))
    (freeze-time-unfreeze)
    (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

                       Marco

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-01-04 10:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-04 10:13 doing something yesterday? joakim
2017-01-04 10:50 ` Marco Wahl

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).