emacsorg-modegtd

org-capture and time clocking misbehaving


I am sure some of you may have gathered (from my recent barrage of questions) that I am setting up org-mode on emacs and walking through Brent Hansen's impressive org set up. He is a clocking fanatic, and I like a lot of the stuff he does to track time spent on projects.

I (think) haven't messed up in setting things up, but whenever I try to clock in our out of a task I get an error with a lot of gibberish (reported below). I've tried to see if there are some patterns to how the error emerges but am unable to discover them. They seem to happen pretty often but not all the time which makes debugging them an even bigger pain.

Typically, when I clock out of a task (but sometime when I clock in too), I get a message like this

save-excursion: Wrong number of arguments: #[(drawer pos) "rÂ!
Ã!pq~bÄÅ    ÆQÇ\"$ÈÉ!+" [pos drawer markerp marker-buffer org-in-regexp "^[     ]*:" ":[    ]*
[   ]*:END:[    ]*
?" 2 replace-match ""] 4 ("/Users/krishnan/.emacs.d/elpa/org-20140210/org.elc" . 450779)], 1
[a-z..]:Set [SPC]:clear [2 times]

As always, I am happy to follow up to questions that might help discover the source of the error. I have not been able to discern if it standard practice to include my entire .emacs etc, but am happy to post follow up information as is needed.

Many thanks in advance!

edit 1: Following @iqbal-ansari , I did M-x toggle-debug-on-error which produces the following gunk:

Debugger entered--Lisp error: (wrong-number-of-arguments #[(drawer pos) "r\302!\203
\303!\202pq\210\212\214~\210b\210\304\305   \306Q\307\"\205$\310\311!+\207" [pos drawer markerp marker-buffer org-in-regexp "^[     ]*:" ":[    ]*
[   ]*:END:[    ]*
?" 2 replace-match ""] 4 ("/Users/krishnan/.emacs.d/elpa/org-20140210/org.elc" . 450779)] 1)
  org-remove-empty-drawer-at(307)
  (save-excursion (beginning-of-line 0) (org-remove-empty-drawer-at (point)))
  bh/remove-empty-drawer-on-clock-out()
  #[(f) " \207" [f] 1](bh/remove-empty-drawer-on-clock-out)
  mapc(#[(f) " \207" [f] 1] (org-clock-remove-empty-clock-drawer bh/remove-empty-drawer-on-clock-out bh/clock-out-maybe))
  byte-code("\306 \204\307\310\"    \311 \210\203\312\313\314\"\210\202\315\316!\210\f\2035\317\320r\321
!q\210@)\322\314\323%\2027A\324B!\322\211\211\211\211\211CDEFGHIAIJ\212\325 q\210\214~\210
b\210\326\327!\210\330\331KP!\203~\332\327!L\232\203~\332\333!H\202\216\203\212\312\313\322\"\210\202\216\334\335!\210\336\225b\210`\337 |\210\340c\210\341M\206\242I\342\343#G\344\345\346\347G!\"!\344\345\346\347H!\"!ZF\350F\351\245!EFE\351_ZF\350F\352\245!DF\211\352_ZF\353\354\355ED#\261\210N\205\364ED\\\336U\211C\203\326\327!\210`\337 |\210\330\356!\203d`TV\203\357\327!\210
\322\211\223\210O\322\211\223\210P\2033\360\361\322\211\211\211\362\363\314!\364Q&\210Q\203@\365Q!\210\322QR\203M\365R!\210\322R\307\310\"  A\203\234\212\366\314!\210\314\322ST\367A!\203\205\330U!\210A\332\333!!\211V\203\201\370V!\210)\202\233A\203\233\330W\331A\371R!\204\233\370A!\210+\311 \210\372\373\374E\352_D\\!\375QGC\203\267\376\202\270\377#\210XEYZ\232\203\335[\201]=\203\335S\203\335\307\201^E\"E\201_\201`E\"\210)\306 ?\205\362\322\211\\.\n\207" [global-mode-string org-frame-title-format-backup frame-title-format fail-quietly switch-to-state org-clock-marker org-clocking-p delq org-mode-line-string force-mode-line-update throw exit t user-error "No active clock" completing-read "Switch to state: " marker-buffer nil "DONE" org-current-time org-clocking-buffer beginning-of-line 1 looking-at "[  ]*" match-string 2 error "Clock start time is gone" 0 point-at-eol "--" org-insert-time-stamp with-hm inactive org-float-time apply encode-time org-parse-time-string floor 3600 60 " => " format "%2d:%02d" "\n" delete-char org-add-log-setup clock-out ...] 10)
  org-clock-out()
  org-clock-out-if-current()
  run-hooks(org-after-todo-state-change-hook)
  byte-code("\306\307!\210\310\311P!\203\312 \210\307\310\n!\203\313\225Sb\210\310\314\315Q!\204)\310\316!\210\304 \317 \304 @\320\216\321\322\323\307\211$*ABBCCDDE\313\232\203X\322E\324\202ZFF\325\326!G\313\224H\327G!I\330IJ\"\211KA@L\331K8M\332K8NG\206\212\333O\307PGQ\235\211RAST\203\303E\334\232\203\255U\335=\204\276E\204\303U\203\303U\335=\204\303\336 \202E\337\232\203\341U\203\324T\204\341\340\341\342\343Q\"\322\307$\202E\344=\203\376G\203\370S\205S@\202Q@\202E\345=\203/RQ\232?\205G\203\"\346QGSG\347#Q8\202Q#\350#!@)\202U\307=\203DE\351\232\203D\322\211E\206E\203\310E\333\232\203T\322\202E\352=\203_\322\202E\353=\203qM\206V@\202E\354=\203\210IW\235A@\206W@\202E\355=\203\246\356W!WIW\235A@\206\242W@)\202EQ\235@\206E;\203\275\357\360E\"\202\361E!SQ8\202R\204\330I\206Q@\202GN\232\203\344\322\202S\204\355\322\202L\362>\203XY=\203S@\202SG\313V\205M\206V@\202S@Z\363\364ZO#\206&Z\211Z\2034\365Z\365Q\2025\365[\366\367\370G\371Z\372
\257\\\322\211]^=\203\230GV\235?_\212\304 @\373\216\212\214~\210\374\375\\\"-\204\230\376\377!\203\201\357\201jGZ`$\210\202\230\201k\201jGZ`$\210\201l\201m\322\"\210\201n\f!\210\201o[\307\211#\210\201pH!\204\276\201k\201q\201r[!\"\210I\204\342\327Z!I\330IJ\"\211KA@L\331K8M\332K8NE\201s>\203\201k\201t\346aG\201u\330Za\"a>G#aG\201v\201w\330Za\"\365#$\210ZV\235?_ZV\235\205,GV\235?^A\203:\201xA!\210D\204DB\203\357F\307=\204\357E\201y>\204\357\330ZD\"A@\206g\347\330GD\"8\211]\324=\203{F\324=\203{\201z]Z\204\205b\203\232Z\203\244Zc\235\203\244Gc\235\204\244\201{\322\211\201|#\210^\203\324B\203\324\201{\201|\201} \"\210]\204\324B\324=\203\324\201~\353ZG\201\324%\210Z\203\357]\203\357\201~\201\200ZG\201]%\210\201\201Z!\210d\203e\204\201\202\322\307\"\210f\203\201\203 \210\201\204\201\205!\210E\203,ZV\235\204,\327Z!I\201\206\317 \201\207 \201\210I$\210^\203a\201\211\201g!\203Z\304 @\201\212\216\201\213 g*\201\214Z!\210\201\215 \203\235n\204\235\212\201\216\326!\210\310h!)\203\235`\347\211\225\206\204\326\225\\W\203\235\347\225\206\220\326\225b\210\310\365!\203\235\201\217 \210i\203\256\212\201\220\201i\\\"\210) \205\264\312 .\207" [org-comment-string commentp org-outline-regexp org-todo-regexp match-data startpos org-back-to-heading t looking-at "^\\*+ " org-toggle-comment 0 " +" "\\( +\\|[  ]*$\\)" "\\(?: *\\|[    ]*$\\)" point-at-bol ((byte-code "\301\302\"\207" [save-match-data-internal set-match-data evaporate] 3)) org-entry-get nil "LOGGING" note match-string 1 org-get-todo-sequence-head assoc 3 4 "" (4) prefix org-fast-todo-selection (4) org-icompleting-read "State: " mapcar list right left - 2 last (4) none done nextset previousset reverse user-error "State `%s' not valid in this file" prefix-numeric-value ...] 10)
  org-todo(nil)
  call-interactively(org-todo)
  org-agenda-todo(nil)
  call-interactively(org-agenda-todo nil nil)

Solution

  • The issue is caused by the line (org-remove-empty-drawer-at (point)) in the function bh/remove-empty-drawer-on-clock-out. If you read the documentation of the function org-remove-empty-drawer-at (do C-hforg-remove-empty-drawer-atRET, it says that the function accepts two arguments drawer and point while the function bh/remove-empty-drawer-on-clock-out passes only one argument (point). This causes the error you reported. It seems the code was written for an older version of org-mode.

    This is a temporary solution, remove the line

    (add-hook 'org-clock-out-hook 'bh/remove-empty-drawer-on-clock-out 'append)
    

    from your init file (and restart emacs). This will get rid of the error.

    UPDATE

    I got (I think) a permanent solution to the problem. The first argument to the function org-remove-empty-drawer-at is the name of the drawer to remove, from Brent Hansen's setup it seems he wants to remove empty 'LOGBOOK' drawers, in this case the modify the function bh/remove-empty-drawer-on-clock-out as follows

    (defun bh/remove-empty-drawer-on-clock-out ()
      (interactive)
      (save-excursion
        (beginning-of-line 0)
        (org-remove-empty-drawer-at "LOGBOOK" (point))))
    

    Note that the argument "LOGBOOK" has been added to the call to function org-remove-empty-drawer-at. Also now you do not need to remove the line

    (add-hook 'org-clock-out-hook 'bh/remove-empty-drawer-on-clock-out 'append)
    

    from your init file.