emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Bug: org-clock-remove-empty-clock-drawer eats LOGBOOK drawer before todo state gets logged [8.3.2 (8.3.2-52-g6d0af5-elpaplus @ /Users/Olli/.emacs.d/elpa/org-20151228/)]
@ 2016-01-03 16:09 Olli P
  2016-01-06 14:52 ` Nicolas Goaziou
  0 siblings, 1 reply; 3+ messages in thread
From: Olli P @ 2016-01-03 16:09 UTC (permalink / raw)
  To: emacs-orgmode


Steps to reproduce:

Launching Emacs with -Q, calling `M-x package-initialize` and then `M-x
org-mode`, and evaluating the following settings:

(setq org-clock-into-drawer t)
(setq org-log-into-drawer t)
(setq org-clock-into-drawer t)
(setq org-log-done 'time)
(setq org-clock-out-when-done t)
(setq org-clock-out-remove-zero-time-clocks t)
(setq org-todo-keywords '((sequence "TODO(t)" "WAIT(w@/!)" "|" "DONE(d!)" "CANCELED(c@)")))

Creating a new task, clock-in in and immediately completing the task
will result in:
----------------------------------------------------------------------

* DONE I bug out
  CLOSED: [2016-01-03 Sun 21:36]
  - State "DONE"       from "TODO"       [2016-01-03 Sun 21:36]

----------------------------------------------------------------------
Instead of the expected:
----------------------------------------------------------------------

    * DONE I bug out
      CLOSED: [2016-01-03 Sun 21:38]
      :LOGBOOK:
      - State "DONE"       from "TODO"       [2016-01-03 Sun 21:38]
      :END:

----------------------------------------------------------------------
If I wait for the timer to run for a minute then things work as expected
as well:
----------------------------------------------------------------------

    * DONE I bug out
      CLOSED: [2016-01-03 Sun 23:00]
      :LOGBOOK:
      - State "DONE"       from "TODO"       [2016-01-03 Sun 23:00]
      CLOCK: [2016-01-03 Sun 22:59]--[2016-01-03 Sun 23:00] =>  0:01
      :END:

----------------------------------------------------------------------
The culprit is `org-clock-remove-empty-clock-drawer` that gets run at
the end of `org-clock-out` for being a `org-clock-out-hook`.

There is in fact code that handles a similar case of storing a note at
the end of `org-clock-out`:

    ...
    (if (and clock-drawer
             (not (stringp clock-drawer)) ;; 1)
             (org-log-into-drawer)
             (eq org-log-done 'note)      ;; 2)
             org-clock-out-when-done)
        (setq h (delq 'org-clock-remove-empty-clock-drawer h)))
    (mapc (lambda (f) (funcall f)) h)
    ...

..but I as far as I see this branch of the `if` can never actually run
as I couldn't come up with a way for `(not (stringp clock-drawer))` to
be true.

If I comment out the lines marked as 1) and 2) then my issue goes away,
but I don't know if this might cause problems elsewhere.

- Olli

> Emacs  : GNU Emacs 24.5.1 (x86_64-apple-darwin14.3.0, Carbon Version 157 AppKit 1347.57)
>  of 2015-12-20 on Ollis-MacBook-Pro.local
> Package: Org-mode version 8.3.2 (8.3.2-52-g6d0af5-elpaplus @ /Users/Olli/.emacs.d/elpa/org-20151228/)
>
> current state:
> ==============
> (setq
>  org-id-locations-file "/Users/Olli/.emacs.d/.cache/.org-id-locations"
>  org-export-babel-evaluate nil
>  org-agenda-tags-todo-honor-ignore-options t
>  org-tab-first-hook '(org-hide-block-toggle-maybe org-babel-hide-result-toggle-maybe org-babel-header-arg-expand)
>  org-insert-heading-hook '(gtd/insert-heading-inactive-timestamp)
>  org-clock-persist-file "/Users/Olli/.emacs.d/.cache/org-clock-save.el"
>  org-speed-command-hook '(org-speed-command-default-hook org-babel-speed-command-hook)
>  org-agenda-skip-timestamp-if-done t
>  org-clock-history-length 24
>  org-occur-hook '(org-first-headline-recenter)
>  org-agenda-todo-ignore-timestamp t
>  org-metaup-hook '(org-babel-load-in-session-maybe)
>  org-agenda-todo-ignore-deadlines t
>  org-log-done 'time
>  org-src-window-setup 'current-window
>  org-confirm-shell-link-function 'yes-or-no-p
>  org-id-link-to-org-use-id 'create-if-interactive-and-no-custom-id
>  org-link-translation-function 'toc-org-unhrefify
>  org-pomodoro-started-hook '(gtd/keep-clock-running)
>  org-present-mode-hook '(spacemacs//org-present-start)
>  org-agenda-sticky t
>  org-agenda-restore-windows-after-quit t
>  org-agenda-todo-ignore-scheduled t
>  org-agenda-skip-scheduled-if-done t
>  org-agenda-custom-commands '(("N" "Notes" tags "NOTE"
>                                ((org-agenda-overriding-header "Notes") (org-tags-match-list-sublevels t)))
>                               (" " "Agenda"
>                                ((agenda "" nil)
>                                 (tags-todo "-WAITING-CANCELLED/!NEXT"
>                                  ((org-agenda-overriding-header "Next Tasks")
>                                   (org-agenda-skip-function (quote gtd/skip-projects-and-habits-and-single-tasks))
>                                   (org-agenda-todo-ignore-scheduled t) (org-agenda-todo-ignore-deadlines t)
>                                   (org-agenda-todo-ignore-with-date t) (org-agenda-tags-todo-honor-todo-options t)
>                                   (org-tags-match-list-sublevels t)
>                                   (org-agenda-sorting-strategy
>                                    (quote (todo-state-down priority-down effort-up category-keep)))
>                                   )
>                                  )
>                                 (tags-todo "-REFILE-CANCELLED-URL/!-DEFER-WAITING"
>                                  ((org-agenda-overriding-header "Tasks")
>                                   (org-agenda-skip-function (quote gtd/skip-project-tasks-maybe))
>                                   (org-agenda-todo-ignore-scheduled t) (org-agenda-todo-ignore-deadlines t)
>                                   (org-agenda-todo-ignore-with-date t)
>                                   (org-agenda-sorting-strategy (quote (priority-down effort-up category-keep))))
>                                  )
>                                 (tags-todo "-CANCELLED/!-DEFER+WAITING"
>                                  ((org-agenda-overriding-header "Waiting") (org-tags-match-list-sublevels nil)
>                                   (org-agenda-todo-ignore-scheduled (quote future))
>                                   (org-agenda-todo-ignore-deadlines (quote future)))
>                                  )
>                                 (tags-todo "-CANCELLED/!"
>                                  ((org-agenda-overriding-header "Stuck Projects")
>                                   (org-agenda-skip-function (quote gtd/skip-non-stuck-projects)))
>                                  )
>                                 (tags-todo "-DEFER-CANCELLED/!"
>                                  ((org-agenda-overriding-header "Projects")
>                                   (org-agenda-skip-function (quote gtd/skip-non-projects))
>                                   (org-agenda-sorting-strategy (quote (priority-down effort-up category-keep))))
>                                  )
>                                 (tags-todo "-CANCELLED/!DEFER"
>                                  ((org-agenda-overriding-header "Deferred")
>                                   (org-agenda-skip-function (quote gtd/skip-stuck-projects))
>                                   (org-tags-match-list-sublevels nil)
>                                   (org-agenda-todo-ignore-scheduled (quote future))
>                                   (org-agenda-todo-ignore-deadlines (quote future)))
>                                  )
>                                 (tags-todo "-REFILE+URL-DONE"
>                                  ((org-agenda-overriding-header "Web") (org-tags-match-list-sublevels nil)))
>                                 (tags "REFILE"
>                                  ((org-agenda-overriding-header "Tasks to Refile")
>                                   (org-tags-match-list-sublevels nil))
>                                  )
>                                 (tags "-REFILE/"
>                                  ((org-agenda-overriding-header "Tasks to Archive")
>                                   (org-agenda-skip-function (quote gtd/skip-non-archivable-tasks))
>                                   (org-tags-match-list-sublevels nil))
>                                  )
>                                 )
>                                nil)
>                               ("r" "Tasks to Refile" tags "REFILE"
>                                ((org-agenda-overriding-header "Tasks to Refile")
>                                 (org-tags-match-list-sublevels nil))
>                                )
>                               ("d" "Done Tasks" agenda ""
>                                ((org-agenda-start-with-log-mode (quote (closed)))
>                                 (org-agenda-skip-function
>                                  (quote (org-agenda-skip-entry-if (quote nottodo) (quote ("DONE")))))
>                                 )
>                                )
>                               ("#" "Stuck Projects" tags-todo "-CANCELLED/!"
>                                ((org-agenda-overriding-header "Stuck Projects")
>                                 (org-agenda-skip-function (quote gtd/skip-non-stuck-projects)))
>                                )
>                               ("n" "Next Tasks" tags-todo "-WAITING-CANCELLED/!NEXT"
>                                ((org-agenda-overriding-header "Next Tasks")
>                                 (org-agenda-skip-function (quote gtd/skip-projects-and-habits-and-single-tasks))
>                                 (org-agenda-todo-ignore-scheduled t) (org-agenda-todo-ignore-deadlines t)
>                                 (org-agenda-todo-ignore-with-date t) (org-tags-match-list-sublevels t)
>                                 (org-agenda-sorting-strategy (quote (todo-state-down effort-up category-keep))))
>                                )
>                               ("t" "Tasks" tags-todo "-REFILE-CANCELLED/!-DEFER-WAITING"
>                                ((org-agenda-overriding-header "Tasks")
>                                 (org-agenda-skip-function (quote gtd/skip-project-tasks-maybe))
>                                 (org-agenda-sorting-strategy (quote (category-keep))))
>                                )
>                               ("p" "Projects" tags-todo "-DEFER-CANCELLED/!"
>                                ((org-agenda-overriding-header "Projects")
>                                 (org-agenda-skip-function (quote gtd/skip-non-projects))
>                                 (org-agenda-sorting-strategy (quote (category-keep))))
>                                )
>                               ("w" "Waiting Tasks" tags-todo "-CANCELLED+WAITING/!"
>                                ((org-agenda-overriding-header "Waiting and Postponed tasks"))
>                                (org-tags-match-list-sublevels nil))
>                               ("h" "Habits" tags-todo "STYLE=\"habit\""
>                                ((org-agenda-overriding-header "Habits")
>                                 (org-agenda-sorting-strategy (quote (todo-state-down effort-up category-keep))))
>                                )
>                               ("u" "Web" tags-todo "+URL-DONE"
>                                ((org-agenda-overriding-header "List of pages to study/read later")))
>                               ("A" "Tasks to Archive" tags "-REFILE/"
>                                ((org-agenda-overriding-header "Tasks to Archive")
>                                 (org-agenda-skip-function (quote gtd/skip-non-archivable-tasks))
>                                 (org-tags-match-list-sublevels nil))
>                                )
>                               )
>  org-return-follows-link t
>  org-default-notes-file "~/org/gtd/refile.org"
>  org-clock-in-resume t
>  org-todo-keyword-faces '(("TODO" :weight bold :foreground "RosyBrown1" :background "OrangeRed3" :box
>                            (:style released-button))
>                           ("DONE" :weight bold :foreground "#8bc34a" :background "#1b5e10" :box
>                            (:style released-button))
>                           ("NEXT" :weight bold :foreground "wheat1" :background "DarkOrange2" :box
>                            (:style released-button))
>                           ("CANCELLED" :weight bold :foreground "#8bc34a" :background "#1b5e10" :box
>                            (:style released-button))
>                           ("WAITING" :weight bold :foreground "SkyBlue1" :background "DodgerBlue3" :box
>                            (:style released-button))
>                           ("DEFER" :weight bold :foreground "plum1" :background "purple3" :box
>                            (:style released-button))
>                           )
>  org-capture-templates '(("t" "Todo" entry (file "~/org/gtd/refile.org") "* TODO [#B] %?\n%U\n")
>                          ("l" "Todo Link" entry (file "~/org/gtd/refile.org") "* TODO [#B] Reply to: %a\n%U\n")
>                          ("n" "Note" entry (file "~/org/gtd/refile.org") "* %? :NOTE:\n%U\n")
>                          ("i" "Idea" entry (file "~/org/ideas.org") "\n* %? :IDEA:\n%U\n")
>                          ("d" "Drill" entry (file "~/org/drill/refile.org") "* %?" :empty-lines 1)
>                          ("l" "Ledger Entry" plain (file "~/ledger/2015.ledger") "%(org-read-date) * %?\n"
>                           :empty-lines 1)
>                          ("w" "Web" entry (file "~/org/gtd/refile.org") "* TODO Check out: %? :URL:\n%U\n"))
>  org-startup-indented t
>  org-after-todo-state-change-hook '(org-clock-out-if-current)
>  org-src-mode-hook '(org-src-babel-configure-edit-buffer org-src-mode-configure-edit-buffer)
>  org-agenda-before-write-hook '(org-agenda-add-entry-text)
>  org-babel-pre-tangle-hook '(save-buffer)
>  org-global-properties '(("Effort_ALL" . "0:05 0:10 0:15 0:30 0:45 1:00 2:00 3:00 5:00 0:00"))
>  org-mode-hook '(spacemacs/load-yasnippet toc-org-enable org-bullets-mode org-clock-load
>                  #[nil "\300\301\302\303\304$\207"
>                    [org-add-hook change-major-mode-hook org-show-block-all append local] 5]
>                  #[nil "\300\301\302\303\304$\207"
>                    [org-add-hook change-major-mode-hook org-babel-show-result-all append local] 5]
>                  org-babel-result-hide-spec org-babel-hide-all-hashes spacemacs/add-org-surrounds evil-org-mode
>                  org-eldoc-load spacemacs//init-company-org-mode company-mode)
>  org-refile-targets '((nil :maxlevel . 9) (org-agenda-files :maxlevel . 9) (someday-file :maxlevel . 9)
>                       (weblog-file :maxlevel . 9))
>  org-outline-path-complete-in-steps nil
>  org-todo-state-tags-triggers '(("CANCELLED" ("CANCELLED" . t)) ("WAITING" ("WAITING" . t))
>                                 ("DEFER" ("WAITING" . t) ("DEFER" . t)) (done ("WAITING") ("DEFER"))
>                                 ("TODO" ("WAITING") ("CANCELLED") ("DEFER"))
>                                 ("NEXT" ("WAITING") ("CANCELLED") ("DEFER"))
>                                 ("DONE" ("WAITING") ("CANCELLED") ("DEFER")))
>  org-stuck-projects '("" nil nil "")
>  org-archive-hook '(org-attach-archive-delete-maybe)
>  org-agenda-compact-blocks t
>  org-clock-persist t
>  org-ctrl-c-ctrl-c-hook '(org-babel-hash-at-point org-babel-execute-safely-maybe)
>  org-refile-use-outline-path t
>  org-clock-in-switch-to-state 'gtd/clock-in-to-next
>  org-enforce-todo-dependencies t
>  org-cycle-hook '(org-cycle-hide-archived-subtrees org-cycle-hide-drawers org-cycle-show-empty-lines
>                   org-optimize-window-after-visibility-change)
>  org-agenda-tags-column 85
>  org-archive-location "%s_archive::* Archived Tasks"
>  org-present-mode-quit-hook '(spacemacs//org-present-end)
>  org-clock-persist-query-resume nil
>  org-agenda-todo-ignore-with-date t
>  org-refile-allow-creating-parent-nodes 'confirm
>  org-todo-keywords '((sequence "TODO(t)" "NEXT(n)" "|" "DONE(d!/!)")
>                      (sequence "WAITING(w/!)" "DEFER(f@/!)" "|" "CANCELLED(c/!)"))
>  org-agenda-window-setup 'current-window
>  org-clock-report-include-clocking-task t
>  org-agenda-span 'day
>  org-confirm-elisp-link-function 'yes-or-no-p
>  org-startup-with-inline-images t
>  org-metadown-hook '(org-babel-pop-to-session-maybe)
>  org-pomodoro-finished-hook '(gtd/dont-keep-clock-running)
>  org-log-into-drawer t
>  org-blocker-hook '(org-block-todo-from-children-or-siblings-or-parent)
>  org-agenda-skip-deadline-if-done t
>  org-fontify-whole-heading-line t
>  org-agenda-files '("~/org/gtd/" "~/org/projects.org")
>  org-clock-out-hook '(org-clock-remove-empty-clock-drawer gtd/clock-out-maybe)
>  org-confirm-babel-evaluate nil
>  org-clock-out-remove-zero-time-clocks t
>  org-refile-target-verify-function 'gtd/verify-refile-target
>  org-pomodoro-killed-hook '(gtd/dont-keep-clock-running)
>  )

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

* Re: Bug: org-clock-remove-empty-clock-drawer eats LOGBOOK drawer before todo state gets logged [8.3.2 (8.3.2-52-g6d0af5-elpaplus @ /Users/Olli/.emacs.d/elpa/org-20151228/)]
  2016-01-03 16:09 Bug: org-clock-remove-empty-clock-drawer eats LOGBOOK drawer before todo state gets logged [8.3.2 (8.3.2-52-g6d0af5-elpaplus @ /Users/Olli/.emacs.d/elpa/org-20151228/)] Olli P
@ 2016-01-06 14:52 ` Nicolas Goaziou
  2016-01-06 17:02   ` Olli Piepponen
  0 siblings, 1 reply; 3+ messages in thread
From: Nicolas Goaziou @ 2016-01-06 14:52 UTC (permalink / raw)
  To: Olli P; +Cc: emacs-orgmode

Hello,

Olli P <kotkis@gmail.com> writes:

> Steps to reproduce:
>
> Launching Emacs with -Q, calling `M-x package-initialize` and then `M-x
> org-mode`, and evaluating the following settings:
>
> (setq org-clock-into-drawer t)
> (setq org-log-into-drawer t)
> (setq org-clock-into-drawer t)
> (setq org-log-done 'time)
> (setq org-clock-out-when-done t)
> (setq org-clock-out-remove-zero-time-clocks t)
> (setq org-todo-keywords '((sequence "TODO(t)" "WAIT(w@/!)" "|" "DONE(d!)" "CANCELED(c@)")))
>
> Creating a new task, clock-in in and immediately completing the task
> will result in:
> ----------------------------------------------------------------------
>
> * DONE I bug out
>   CLOSED: [2016-01-03 Sun 21:36]
>   - State "DONE"       from "TODO"       [2016-01-03 Sun 21:36]
>
> ----------------------------------------------------------------------
> Instead of the expected:
> ----------------------------------------------------------------------
>
>     * DONE I bug out
>       CLOSED: [2016-01-03 Sun 21:38]
>       :LOGBOOK:
>       - State "DONE"       from "TODO"       [2016-01-03 Sun 21:38]
>       :END:
>
> ----------------------------------------------------------------------
> If I wait for the timer to run for a minute then things work as expected
> as well:
> ----------------------------------------------------------------------
>
>     * DONE I bug out
>       CLOSED: [2016-01-03 Sun 23:00]
>       :LOGBOOK:
>       - State "DONE"       from "TODO"       [2016-01-03 Sun 23:00]
>       CLOCK: [2016-01-03 Sun 22:59]--[2016-01-03 Sun 23:00] =>  0:01
>       :END:
>
> ----------------------------------------------------------------------
> The culprit is `org-clock-remove-empty-clock-drawer` that gets run at
> the end of `org-clock-out` for being a `org-clock-out-hook`.

Fixed in development version. Thank you for the report.

Regards,

-- 
Nicolas Goaziou

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

* Re: Bug: org-clock-remove-empty-clock-drawer eats LOGBOOK drawer before todo state gets logged [8.3.2 (8.3.2-52-g6d0af5-elpaplus @ /Users/Olli/.emacs.d/elpa/org-20151228/)]
  2016-01-06 14:52 ` Nicolas Goaziou
@ 2016-01-06 17:02   ` Olli Piepponen
  0 siblings, 0 replies; 3+ messages in thread
From: Olli Piepponen @ 2016-01-06 17:02 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-orgmode


Thanks for the quick fix!

Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:

> Hello,
>
> Olli P <kotkis@gmail.com> writes:
>
>> Steps to reproduce:
>>
>> Launching Emacs with -Q, calling `M-x package-initialize` and then `M-x
>> org-mode`, and evaluating the following settings:
>>
>> (setq org-clock-into-drawer t)
>> (setq org-log-into-drawer t)
>> (setq org-clock-into-drawer t)
>> (setq org-log-done 'time)
>> (setq org-clock-out-when-done t)
>> (setq org-clock-out-remove-zero-time-clocks t)
>> (setq org-todo-keywords '((sequence "TODO(t)" "WAIT(w@/!)" "|" "DONE(d!)" "CANCELED(c@)")))
>>
>> Creating a new task, clock-in in and immediately completing the task
>> will result in:
>> ----------------------------------------------------------------------
>>
>> * DONE I bug out
>>   CLOSED: [2016-01-03 Sun 21:36]
>>   - State "DONE"       from "TODO"       [2016-01-03 Sun 21:36]
>>
>> ----------------------------------------------------------------------
>> Instead of the expected:
>> ----------------------------------------------------------------------
>>
>>     * DONE I bug out
>>       CLOSED: [2016-01-03 Sun 21:38]
>>       :LOGBOOK:
>>       - State "DONE"       from "TODO"       [2016-01-03 Sun 21:38]
>>       :END:
>>
>> ----------------------------------------------------------------------
>> If I wait for the timer to run for a minute then things work as expected
>> as well:
>> ----------------------------------------------------------------------
>>
>>     * DONE I bug out
>>       CLOSED: [2016-01-03 Sun 23:00]
>>       :LOGBOOK:
>>       - State "DONE"       from "TODO"       [2016-01-03 Sun 23:00]
>>       CLOCK: [2016-01-03 Sun 22:59]--[2016-01-03 Sun 23:00] =>  0:01
>>       :END:
>>
>> ----------------------------------------------------------------------
>> The culprit is `org-clock-remove-empty-clock-drawer` that gets run at
>> the end of `org-clock-out` for being a `org-clock-out-hook`.
>
> Fixed in development version. Thank you for the report.
>
> Regards,

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

end of thread, other threads:[~2016-01-06 17:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-03 16:09 Bug: org-clock-remove-empty-clock-drawer eats LOGBOOK drawer before todo state gets logged [8.3.2 (8.3.2-52-g6d0af5-elpaplus @ /Users/Olli/.emacs.d/elpa/org-20151228/)] Olli P
2016-01-06 14:52 ` Nicolas Goaziou
2016-01-06 17:02   ` Olli Piepponen

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