emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* mark as done on a previous date?
@ 2016-12-29 13:12 Stig Brautaset
  2016-12-30 12:14 ` Marco Wahl
  0 siblings, 1 reply; 4+ messages in thread
From: Stig Brautaset @ 2016-12-29 13:12 UTC (permalink / raw)
  To: Orgmode Mailing List


I'm trying to use org-habit to track my habits and sometimes I don't
get around to mark stuff as done on the day I do them. I've found two
different functions for marking stuff as done in the past, but I can't
get either of them to work.

Here are the two different approaches I found. The first was at
https://www.emacswiki.org/emacs/OrgMode#toc22 and is the most general:

#+BEGIN_SRC emacs-lisp
  (defun org-todo-at-date (date)
    (interactive (list (org-time-string-to-time (org-read-date))))
    (cl-flet ((org-current-effective-time (&rest r) date)
              (org-today (&rest r) (time-to-days date)))
      (org-todo)))
#+END_SRC

The second is from
https://joelmccracken.github.io/entries/emacs-hack-set-todo-done-yesterday/
and looks like this:

#+BEGIN_SRC emacs-lisp
  (defun org-todo-toggle-yesterday ()
    (interactive)
    (let ((time-in-question (decode-time))) 
      (decf (nth 3 time-in-question))
      (setq time-in-question (apply 'encode-time time-in-question))
      (flet ((current-time () time-in-question))
        (org-todo))))
#+END_SRC

Unfortunately, I haven't been able to get either to work. I've tested
with Org 9, and with =emacs -Q= (which gives me Org 8.2) but can't get
it to work in either. Perhaps the tricks employed do not work in Emacs
25?

FWIW:

: GNU Emacs 25.1.1 (x86_64-apple-darwin13.4.0, NS appkit-1265.21 Version 10.9.5 (Build 13F1911)) of 2016-09-21
: Org mode version 9.0.3 (9.0.3-elpaplus @ /Users/stig/.emacs.d/elpa/org-plus-contrib-20161224/)

Stig

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

* Re: mark as done on a previous date?
  2016-12-29 13:12 mark as done on a previous date? Stig Brautaset
@ 2016-12-30 12:14 ` Marco Wahl
  2016-12-30 16:38   ` Stig Brautaset
  0 siblings, 1 reply; 4+ messages in thread
From: Marco Wahl @ 2016-12-30 12:14 UTC (permalink / raw)
  To: emacs-orgmode

Hi!

> I'm trying to use org-habit to track my habits and sometimes I don't
> get around to mark stuff as done on the day I do them. I've found two
> different functions for marking stuff as done in the past, but I can't
> get either of them to work.
> [...]

I did not check why the other functions fail.

What about the following function?  I'm on Org 9.

#v+
(defun mw-org-todo-with-other-date (date &optional arg)
  "Like `org-todo' but ask for a specific DATE.
Optional argument ARG prefix arg."
  (interactive (list (org-read-date) current-prefix-arg))
  (let* ((org-use-effective-time t)
         (hour
          (truncate
           (- (/ (org-time-stamp-to-now date t)
                 60 60))))
          (org-extend-today-until (1+ hour)))
    (org-todo arg)))
#v-

This function has been inspired by Org's `org-todo-yesterday'.  The
latter even does its job when triggered from the agenda.


HTH
                       Marco

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

* Re: mark as done on a previous date?
  2016-12-30 12:14 ` Marco Wahl
@ 2016-12-30 16:38   ` Stig Brautaset
  2017-01-04 17:40     ` Marco Wahl
  0 siblings, 1 reply; 4+ messages in thread
From: Stig Brautaset @ 2016-12-30 16:38 UTC (permalink / raw)
  To: Marco Wahl; +Cc: emacs-orgmode


Marco Wahl <marcowahlsoft@gmail.com> writes:

> Hi!
>
>> I'm trying to use org-habit to track my habits and sometimes I don't
>> get around to mark stuff as done on the day I do them. I've found two
>> different functions for marking stuff as done in the past, but I can't
>> get either of them to work.
>> [...]

[...]

Interesting. I couldn't get yours to work as I expected either, and
decided to try =org-todo-yesterday=, and couldn't get _that_ to work as
I expected either, which I thought was strange so I dug a bit deeper. I
tested with =emacs -q foo.org= and added the following entry (I did this
on the 30th of December):

,----
| * TODO Testing 123
|   SCHEDULED: <2016-12-27 Tue .+1m>
|   :PROPERTIES:
|   :STYLE:    habit
|   :END:
`----

After using =org-todo-yesterday= I ended up with:

,----
| * TODO Testing 123
|   SCHEDULED: <2017-01-29 Sun .+1m>
|   - State "DONE"       from "TODO"       [2016-12-30 Fri 16:29]
|   :PROPERTIES:
|   :STYLE:    habit
|   :LAST_REPEAT: [2016-12-30 Fri 16:29]
|   :END:
`----

I now see (finally!) that the *re-scheduling* works as I would expect,
but the LAST_REPEAT and state change logging still uses the actual time.
I would have expected both those to use the 29th rather than the 30th as
well. Perhaps this is just my expectation that needs adjusting, but this
breaks org-habit's graphing of my consistency. Perhaps I just have to
get in the habit of ticking stuff off on the day I do them... :-)

Stig

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

* Re: mark as done on a previous date?
  2016-12-30 16:38   ` Stig Brautaset
@ 2017-01-04 17:40     ` Marco Wahl
  0 siblings, 0 replies; 4+ messages in thread
From: Marco Wahl @ 2017-01-04 17:40 UTC (permalink / raw)
  To: emacs-orgmode

> Interesting. I couldn't get yours to work as I expected either, and
> decided to try =org-todo-yesterday=, and couldn't get _that_ to work as
> I expected either, which I thought was strange so I dug a bit deeper. I
> tested with =emacs -q foo.org= and added the following entry (I did this
> on the 30th of December):
>
> ,----
> | * TODO Testing 123
> |   SCHEDULED: <2016-12-27 Tue .+1m>
> |   :PROPERTIES:
> |   :STYLE:    habit
> |   :END:
> `----
>
> After using =org-todo-yesterday= I ended up with:
>
> ,----
> | * TODO Testing 123
> |   SCHEDULED: <2017-01-29 Sun .+1m>
> |   - State "DONE"       from "TODO"       [2016-12-30 Fri 16:29]
> |   :PROPERTIES:
> |   :STYLE:    habit
> |   :LAST_REPEAT: [2016-12-30 Fri 16:29]
> |   :END:
> `----
>
> I now see (finally!) that the *re-scheduling* works as I would expect,
> but the LAST_REPEAT and state change logging still uses the actual time.
> I would have expected both those to use the 29th rather than the 30th as
> well. Perhaps this is just my expectation that needs adjusting, but this
> breaks org-habit's graphing of my consistency. Perhaps I just have to
> get in the habit of ticking stuff off on the day I do them... :-)

Hi Stig,

I think your expectation is right.  There is another thread in this
mailing list about the same topic AFAICT.  Hopefully something reliable
will emerge.


Ciao

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

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

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-12-29 13:12 mark as done on a previous date? Stig Brautaset
2016-12-30 12:14 ` Marco Wahl
2016-12-30 16:38   ` Stig Brautaset
2017-01-04 17:40     ` 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).