From: Marco Wahl <marcowahlsoft@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Re: doing something yesterday?
Date: Wed, 04 Jan 2017 11:50:24 +0100 [thread overview]
Message-ID: <844m1fumj3.fsf@gmail.com> (raw)
In-Reply-To: m3fukzdteh.fsf@chopper
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
prev parent reply other threads:[~2017-01-04 10:50 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-04 10:13 doing something yesterday? joakim
2017-01-04 10:50 ` Marco Wahl [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=844m1fumj3.fsf@gmail.com \
--to=marcowahlsoft@gmail.com \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.