From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marco Wahl Subject: Re: doing something yesterday? Date: Wed, 04 Jan 2017 11:50:24 +0100 Message-ID: <844m1fumj3.fsf@gmail.com> References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:45354) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cOj9e-0003pO-OT for emacs-orgmode@gnu.org; Wed, 04 Jan 2017 05:50:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cOj9a-0007CX-16 for emacs-orgmode@gnu.org; Wed, 04 Jan 2017 05:50:50 -0500 Received: from [195.159.176.226] (port=39532 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cOj9Z-0007CN-LT for emacs-orgmode@gnu.org; Wed, 04 Jan 2017 05:50:45 -0500 Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1cOj9P-0003rT-2h for emacs-orgmode@gnu.org; Wed, 04 Jan 2017 11:50:35 +0100 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: emacs-orgmode@gnu.org 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