emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Org Clock Error
@ 2016-01-13 22:38 Mike McLean
  2016-01-14  1:30 ` Nick Dokos
  0 siblings, 1 reply; 7+ messages in thread
From: Mike McLean @ 2016-01-13 22:38 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 24143 bytes --]

Hello

In the last few days I started getting an error when moving tasks to the
DONE state.

I have ~(setq org-clock-out-when-done t)~ in my Emacs configuration.

I get the following back trace when I mark a task as done:

Debugger entered--Lisp error: (void-variable org-state)
  (member org-state org-done-keywords)
  (and (eq t org-clock-out-when-done) (member org-state org-done-keywords))
  (or (and (eq t org-clock-out-when-done) (member org-state
org-done-keywords)) (and (listp org-clock-out-when-done) (member org-state
org-clock-out-when-done)))
  (and (org-clocking-p) org-clock-out-when-done (marker-buffer
org-clock-marker) (or (and (eq t org-clock-out-when-done) (member org-state
org-done-keywords)) (and (listp org-clock-out-when-done) (member org-state
org-clock-out-when-done))) (equal (or (buffer-base-buffer
(org-clocking-buffer)) (org-clocking-buffer)) (or (buffer-base-buffer
(current-buffer)) (current-buffer))) (< (point) org-clock-marker) (>
(save-excursion (outline-next-heading) (point)) org-clock-marker))
  (if (and (org-clocking-p) org-clock-out-when-done (marker-buffer
org-clock-marker) (or (and (eq t org-clock-out-when-done) (member org-state
org-done-keywords)) (and (listp org-clock-out-when-done) (member org-state
org-clock-out-when-done))) (equal (or (buffer-base-buffer
(org-clocking-buffer)) (org-clocking-buffer)) (or (buffer-base-buffer
(current-buffer)) (current-buffer))) (< (point) org-clock-marker) (>
(save-excursion (outline-next-heading) (point)) org-clock-marker)) (progn
(let ((org-log-note-clock-out nil) (org-clock-out-switch-to-state nil))
(org-clock-out))))
  org-clock-out-if-current()
  run-hooks(org-after-todo-state-change-hook)
  (let* ((match-data (match-data)) (startpos (point-at-bol)) (logging (let
((save-match-data-internal (match-data))) (unwind-protect (progn
(org-entry-get nil "LOGGING" t t)) (set-match-data save-match-data-internal
(quote evaporate))))) (org-log-done org-log-done) (org-log-repeat
org-log-repeat) (org-todo-log-states org-todo-log-states)
(org-inhibit-logging (if (equal arg 0) (progn (setq arg nil) (quote note))
org-inhibit-logging)) (this (match-string 1)) (hl-pos (match-beginning 0))
(head (org-get-todo-sequence-head this)) (ass (assoc head
org-todo-kwd-alist)) (interpret (nth 1 ass)) (done-word (nth 3 ass))
(final-done-word (nth 4 ass)) (org-last-state (or this ""))
(completion-ignore-case t) (member (member this org-todo-keywords-1)) (tail
(cdr member)) (org-state (cond ((and org-todo-key-trigger (or (and ... ...)
(and ... org-use-fast-todo-selection ...))) (org-fast-todo-selection))
((and (equal arg (quote ...)) (or (not org-use-fast-todo-selection) (not
org-todo-key-trigger))) (completing-read "State: " (mapcar (function list)
org-todo-keywords-1) nil t)) ((eq arg (quote right)) (if this (if tail (car
tail) nil) (car org-todo-keywords-1))) ((eq arg (quote left)) (if (equal
member org-todo-keywords-1) nil (if this (nth ... org-todo-keywords-1)
(org-last org-todo-keywords-1)))) ((and (eq org-use-fast-todo-selection t)
(equal arg (quote ...)) (setq arg nil))) (arg (cond ((equal arg "") nil)
((eq arg ...) nil) ((eq arg ...) (or done-word ...)) ((eq arg ...) (or ...
...)) ((eq arg ...) (let ... ...)) ((car ...)) ((stringp arg) (user-error
"State `%s' not valid in this file" arg)) ((nth ... org-todo-keywords-1))))
((null member) (or head (car org-todo-keywords-1))) ((equal this
final-done-word) nil) ((null tail) nil) ((memq interpret (quote (type
priority))) (if (eq this-command last-command) (car tail) (if (> ... 0) (or
done-word ...) nil))) (t (car tail)))) (org-state (or
(run-hook-with-args-until-success (quote org-todo-get-default-hook)
org-state org-last-state) org-state)) (next (if org-state (concat " "
org-state " ") " ")) (change-plist (list :type (quote todo-state-change)
:from this :to org-state :position startpos)) dolog now-done-p) (if
org-blocker-hook (progn (setq org-last-todo-state-is-todo (not (member this
org-done-keywords))) (if (save-excursion (let ((save-match-data-internal
...)) (unwind-protect (progn ...) (set-match-data save-match-data-internal
...)))) nil (if (with-no-warnings (called-interactively-p (quote
interactive))) (user-error "TODO state change from %s to %s blocked (by
\"%s\")" this org-state org-block-entry-blocking) (message "TODO state
change from %s to %s blocked (by \"%s\")" this org-state
org-block-entry-blocking) (throw (quote exit) nil))))) (store-match-data
match-data) (replace-match next t t) (cond ((equal this org-state) (message
"TODO state was already %s" (org-trim next))) ((pos-visible-in-window-p
hl-pos) (message "TODO state changed to %s" (org-trim next)))) (if head nil
(setq head (org-get-todo-sequence-head org-state) ass (assoc head
org-todo-kwd-alist) interpret (nth 1 ass) done-word (nth 3 ass)
final-done-word (nth 4 ass))) (if (memq arg (quote (nextset previousset)))
(progn (message "Keyword-Set %d/%d: %s" (- (length org-todo-sets) -1
(length (memq (assoc org-state org-todo-sets) org-todo-sets))) (length
org-todo-sets) (mapconcat (quote identity) (assoc org-state org-todo-sets)
" ")))) (setq org-last-todo-state-is-todo (not (member org-state
org-done-keywords))) (setq now-done-p (and (member org-state
org-done-keywords) (not (member this org-done-keywords)))) (and logging
(org-local-logging logging)) (if (and (or org-todo-log-states org-log-done)
(not (eq org-inhibit-logging t)) (not (memq arg (quote (nextset
previousset))))) (progn (setq dolog (or (nth 1 (assoc org-state
org-todo-log-states)) (nth 2 (assoc this org-todo-log-states)))) (if (and
(eq dolog (quote note)) (eq org-inhibit-logging (quote note))) (progn (setq
dolog (quote time)))) (if (or (and (not org-state) (not
org-closed-keep-when-no-todo)) (and org-state (member org-state
org-not-done-keywords) (not (member this org-not-done-keywords)))) (progn
(org-add-planning-info nil nil (quote closed)))) (if (and now-done-p
org-log-done) (progn (org-add-planning-info (quote closed)
(org-current-effective-time)) (if (and (not dolog) (eq ... org-log-done))
(progn (org-add-log-setup ... org-state this ...))))) (if (and org-state
dolog) (progn (org-add-log-setup (quote state) org-state this dolog)))))
(org-todo-trigger-tag-changes org-state) (and org-auto-align-tags (not
org-setting-tags) (org-set-tags nil t)) (if org-provide-todo-statistics
(progn (org-update-parent-todo-statistics))) (run-hooks (quote
org-after-todo-state-change-hook)) (if (and arg (not (member org-state
org-done-keywords))) (progn (setq head (org-get-todo-sequence-head
org-state)))) (put-text-property (point-at-bol) (point-at-eol) (quote
org-todo-head) head) (if now-done-p (progn (if (boundp (quote
org-agenda-headline-snapshot-before-repeat)) (progn (let
((save-match-data-internal ...)) (unwind-protect (progn ...)
(set-match-data save-match-data-internal ...))))) (org-auto-repeat-maybe
org-state))) (if (and (outline-on-heading-p) (not (bolp)) (save-excursion
(beginning-of-line 1) (looking-at org-todo-line-regexp)) (< (point) (+ 2
(or (match-end 2) (match-end 1))))) (progn (goto-char (or (match-end 2)
(match-end 1))) (and (looking-at " ") (just-one-space)))) (if
org-trigger-hook (progn (save-excursion (run-hook-with-args (quote
org-trigger-hook) change-plist)))) (if commentp (progn
(org-toggle-comment))))
  (catch (quote exit) (org-back-to-heading t) (if
(org-in-commented-heading-p t) (progn (org-toggle-comment) (setq commentp
t))) (if (looking-at org-outline-regexp) (progn (goto-char (1- (match-end
0))))) (or (looking-at (concat " +" org-todo-regexp "\\( +\\|[ ]*$\\)"))
(looking-at "\\(?: *\\|[ ]*$\\)")) (let* ((match-data (match-data))
(startpos (point-at-bol)) (logging (let ((save-match-data-internal
(match-data))) (unwind-protect (progn (org-entry-get nil "LOGGING" t t))
(set-match-data save-match-data-internal (quote evaporate)))))
(org-log-done org-log-done) (org-log-repeat org-log-repeat)
(org-todo-log-states org-todo-log-states) (org-inhibit-logging (if (equal
arg 0) (progn (setq arg nil) (quote note)) org-inhibit-logging)) (this
(match-string 1)) (hl-pos (match-beginning 0)) (head
(org-get-todo-sequence-head this)) (ass (assoc head org-todo-kwd-alist))
(interpret (nth 1 ass)) (done-word (nth 3 ass)) (final-done-word (nth 4
ass)) (org-last-state (or this "")) (completion-ignore-case t) (member
(member this org-todo-keywords-1)) (tail (cdr member)) (org-state (cond
((and org-todo-key-trigger (or ... ...)) (org-fast-todo-selection)) ((and
(equal arg ...) (or ... ...)) (completing-read "State: " (mapcar ...
org-todo-keywords-1) nil t)) ((eq arg (quote right)) (if this (if tail ...
nil) (car org-todo-keywords-1))) ((eq arg (quote left)) (if (equal member
org-todo-keywords-1) nil (if this ... ...))) ((and (eq
org-use-fast-todo-selection t) (equal arg ...) (setq arg nil))) (arg (cond
(... nil) (... nil) (... ...) (... ...) (... ...) (...) (... ...) (...)))
((null member) (or head (car org-todo-keywords-1))) ((equal this
final-done-word) nil) ((null tail) nil) ((memq interpret (quote ...)) (if
(eq this-command last-command) (car tail) (if ... ... nil))) (t (car
tail)))) (org-state (or (run-hook-with-args-until-success (quote
org-todo-get-default-hook) org-state org-last-state) org-state)) (next (if
org-state (concat " " org-state " ") " ")) (change-plist (list :type (quote
todo-state-change) :from this :to org-state :position startpos)) dolog
now-done-p) (if org-blocker-hook (progn (setq org-last-todo-state-is-todo
(not (member this org-done-keywords))) (if (save-excursion (let (...)
(unwind-protect ... ...))) nil (if (with-no-warnings
(called-interactively-p ...)) (user-error "TODO state change from %s to %s
blocked (by \"%s\")" this org-state org-block-entry-blocking) (message
"TODO state change from %s to %s blocked (by \"%s\")" this org-state
org-block-entry-blocking) (throw (quote exit) nil))))) (store-match-data
match-data) (replace-match next t t) (cond ((equal this org-state) (message
"TODO state was already %s" (org-trim next))) ((pos-visible-in-window-p
hl-pos) (message "TODO state changed to %s" (org-trim next)))) (if head nil
(setq head (org-get-todo-sequence-head org-state) ass (assoc head
org-todo-kwd-alist) interpret (nth 1 ass) done-word (nth 3 ass)
final-done-word (nth 4 ass))) (if (memq arg (quote (nextset previousset)))
(progn (message "Keyword-Set %d/%d: %s" (- (length org-todo-sets) -1
(length (memq ... org-todo-sets))) (length org-todo-sets) (mapconcat (quote
identity) (assoc org-state org-todo-sets) " ")))) (setq
org-last-todo-state-is-todo (not (member org-state org-done-keywords)))
(setq now-done-p (and (member org-state org-done-keywords) (not (member
this org-done-keywords)))) (and logging (org-local-logging logging)) (if
(and (or org-todo-log-states org-log-done) (not (eq org-inhibit-logging t))
(not (memq arg (quote (nextset previousset))))) (progn (setq dolog (or (nth
1 (assoc org-state org-todo-log-states)) (nth 2 (assoc this
org-todo-log-states)))) (if (and (eq dolog (quote note)) (eq
org-inhibit-logging (quote note))) (progn (setq dolog (quote time)))) (if
(or (and (not org-state) (not org-closed-keep-when-no-todo)) (and org-state
(member org-state org-not-done-keywords) (not ...))) (progn
(org-add-planning-info nil nil (quote closed)))) (if (and now-done-p
org-log-done) (progn (org-add-planning-info (quote closed)
(org-current-effective-time)) (if (and ... ...) (progn ...)))) (if (and
org-state dolog) (progn (org-add-log-setup (quote state) org-state this
dolog))))) (org-todo-trigger-tag-changes org-state) (and
org-auto-align-tags (not org-setting-tags) (org-set-tags nil t)) (if
org-provide-todo-statistics (progn (org-update-parent-todo-statistics)))
(run-hooks (quote org-after-todo-state-change-hook)) (if (and arg (not
(member org-state org-done-keywords))) (progn (setq head
(org-get-todo-sequence-head org-state)))) (put-text-property (point-at-bol)
(point-at-eol) (quote org-todo-head) head) (if now-done-p (progn (if
(boundp (quote org-agenda-headline-snapshot-before-repeat)) (progn (let
(...) (unwind-protect ... ...)))) (org-auto-repeat-maybe org-state))) (if
(and (outline-on-heading-p) (not (bolp)) (save-excursion (beginning-of-line
1) (looking-at org-todo-line-regexp)) (< (point) (+ 2 (or (match-end 2)
(match-end 1))))) (progn (goto-char (or (match-end 2) (match-end 1))) (and
(looking-at " ") (just-one-space)))) (if org-trigger-hook (progn
(save-excursion (run-hook-with-args (quote org-trigger-hook)
change-plist)))) (if commentp (progn (org-toggle-comment)))))
  (save-excursion (catch (quote exit) (org-back-to-heading t) (if
(org-in-commented-heading-p t) (progn (org-toggle-comment) (setq commentp
t))) (if (looking-at org-outline-regexp) (progn (goto-char (1- (match-end
0))))) (or (looking-at (concat " +" org-todo-regexp "\\( +\\|[ ]*$\\)"))
(looking-at "\\(?: *\\|[ ]*$\\)")) (let* ((match-data (match-data))
(startpos (point-at-bol)) (logging (let ((save-match-data-internal ...))
(unwind-protect (progn ...) (set-match-data save-match-data-internal
...)))) (org-log-done org-log-done) (org-log-repeat org-log-repeat)
(org-todo-log-states org-todo-log-states) (org-inhibit-logging (if (equal
arg 0) (progn (setq arg nil) (quote note)) org-inhibit-logging)) (this
(match-string 1)) (hl-pos (match-beginning 0)) (head
(org-get-todo-sequence-head this)) (ass (assoc head org-todo-kwd-alist))
(interpret (nth 1 ass)) (done-word (nth 3 ass)) (final-done-word (nth 4
ass)) (org-last-state (or this "")) (completion-ignore-case t) (member
(member this org-todo-keywords-1)) (tail (cdr member)) (org-state (cond
((and org-todo-key-trigger ...) (org-fast-todo-selection)) ((and ... ...)
(completing-read "State: " ... nil t)) ((eq arg ...) (if this ... ...))
((eq arg ...) (if ... nil ...)) ((and ... ... ...)) (arg (cond ... ... ...
... ... ... ... ...)) ((null member) (or head ...)) ((equal this
final-done-word) nil) ((null tail) nil) ((memq interpret ...) (if ... ...
...)) (t (car tail)))) (org-state (or (run-hook-with-args-until-success
(quote org-todo-get-default-hook) org-state org-last-state) org-state))
(next (if org-state (concat " " org-state " ") " ")) (change-plist (list
:type (quote todo-state-change) :from this :to org-state :position
startpos)) dolog now-done-p) (if org-blocker-hook (progn (setq
org-last-todo-state-is-todo (not (member this org-done-keywords))) (if
(save-excursion (let ... ...)) nil (if (with-no-warnings ...) (user-error
"TODO state change from %s to %s blocked (by \"%s\")" this org-state
org-block-entry-blocking) (message "TODO state change from %s to %s blocked
(by \"%s\")" this org-state org-block-entry-blocking) (throw ... nil)))))
(store-match-data match-data) (replace-match next t t) (cond ((equal this
org-state) (message "TODO state was already %s" (org-trim next)))
((pos-visible-in-window-p hl-pos) (message "TODO state changed to %s"
(org-trim next)))) (if head nil (setq head (org-get-todo-sequence-head
org-state) ass (assoc head org-todo-kwd-alist) interpret (nth 1 ass)
done-word (nth 3 ass) final-done-word (nth 4 ass))) (if (memq arg (quote
(nextset previousset))) (progn (message "Keyword-Set %d/%d: %s" (- (length
org-todo-sets) -1 (length ...)) (length org-todo-sets) (mapconcat (quote
identity) (assoc org-state org-todo-sets) " ")))) (setq
org-last-todo-state-is-todo (not (member org-state org-done-keywords)))
(setq now-done-p (and (member org-state org-done-keywords) (not (member
this org-done-keywords)))) (and logging (org-local-logging logging)) (if
(and (or org-todo-log-states org-log-done) (not (eq org-inhibit-logging t))
(not (memq arg (quote ...)))) (progn (setq dolog (or (nth 1 ...) (nth 2
...))) (if (and (eq dolog ...) (eq org-inhibit-logging ...)) (progn (setq
dolog ...))) (if (or (and ... ...) (and org-state ... ...)) (progn
(org-add-planning-info nil nil ...))) (if (and now-done-p org-log-done)
(progn (org-add-planning-info ... ...) (if ... ...))) (if (and org-state
dolog) (progn (org-add-log-setup ... org-state this dolog)))))
(org-todo-trigger-tag-changes org-state) (and org-auto-align-tags (not
org-setting-tags) (org-set-tags nil t)) (if org-provide-todo-statistics
(progn (org-update-parent-todo-statistics))) (run-hooks (quote
org-after-todo-state-change-hook)) (if (and arg (not (member org-state
org-done-keywords))) (progn (setq head (org-get-todo-sequence-head
org-state)))) (put-text-property (point-at-bol) (point-at-eol) (quote
org-todo-head) head) (if now-done-p (progn (if (boundp (quote
org-agenda-headline-snapshot-before-repeat)) (progn (let ... ...)))
(org-auto-repeat-maybe org-state))) (if (and (outline-on-heading-p) (not
(bolp)) (save-excursion (beginning-of-line 1) (looking-at
org-todo-line-regexp)) (< (point) (+ 2 (or ... ...)))) (progn (goto-char
(or (match-end 2) (match-end 1))) (and (looking-at " ") (just-one-space))))
(if org-trigger-hook (progn (save-excursion (run-hook-with-args (quote
org-trigger-hook) change-plist)))) (if commentp (progn
(org-toggle-comment))))))
  (let ((org-blocker-hook org-blocker-hook) commentp case-fold-search) (if
(equal arg (quote (64))) (progn (setq arg nil org-blocker-hook nil))) (if
(and org-blocker-hook (or org-inhibit-blocking (org-entry-get nil
"NOBLOCKING"))) (progn (setq org-blocker-hook nil))) (save-excursion (catch
(quote exit) (org-back-to-heading t) (if (org-in-commented-heading-p t)
(progn (org-toggle-comment) (setq commentp t))) (if (looking-at
org-outline-regexp) (progn (goto-char (1- (match-end 0))))) (or (looking-at
(concat " +" org-todo-regexp "\\( +\\|[ ]*$\\)")) (looking-at "\\(?:
*\\|[ ]*$\\)"))
(let* ((match-data (match-data)) (startpos (point-at-bol)) (logging (let
(...) (unwind-protect ... ...))) (org-log-done org-log-done)
(org-log-repeat org-log-repeat) (org-todo-log-states org-todo-log-states)
(org-inhibit-logging (if (equal arg 0) (progn ... ...)
org-inhibit-logging)) (this (match-string 1)) (hl-pos (match-beginning 0))
(head (org-get-todo-sequence-head this)) (ass (assoc head
org-todo-kwd-alist)) (interpret (nth 1 ass)) (done-word (nth 3 ass))
(final-done-word (nth 4 ass)) (org-last-state (or this ""))
(completion-ignore-case t) (member (member this org-todo-keywords-1)) (tail
(cdr member)) (org-state (cond (... ...) (... ...) (... ...) (... ...)
(...) (arg ...) (... ...) (... nil) (... nil) (... ...) (t ...)))
(org-state (or (run-hook-with-args-until-success ... org-state
org-last-state) org-state)) (next (if org-state (concat " " org-state " ")
" ")) (change-plist (list :type (quote todo-state-change) :from this :to
org-state :position startpos)) dolog now-done-p) (if org-blocker-hook
(progn (setq org-last-todo-state-is-todo (not ...)) (if (save-excursion
...) nil (if ... ... ... ...)))) (store-match-data match-data)
(replace-match next t t) (cond ((equal this org-state) (message "TODO state
was already %s" (org-trim next))) ((pos-visible-in-window-p hl-pos)
(message "TODO state changed to %s" (org-trim next)))) (if head nil (setq
head (org-get-todo-sequence-head org-state) ass (assoc head
org-todo-kwd-alist) interpret (nth 1 ass) done-word (nth 3 ass)
final-done-word (nth 4 ass))) (if (memq arg (quote (nextset previousset)))
(progn (message "Keyword-Set %d/%d: %s" (- ... -1 ...) (length
org-todo-sets) (mapconcat ... ... " ")))) (setq org-last-todo-state-is-todo
(not (member org-state org-done-keywords))) (setq now-done-p (and (member
org-state org-done-keywords) (not (member this org-done-keywords)))) (and
logging (org-local-logging logging)) (if (and (or org-todo-log-states
org-log-done) (not (eq org-inhibit-logging t)) (not (memq arg ...))) (progn
(setq dolog (or ... ...)) (if (and ... ...) (progn ...)) (if (or ... ...)
(progn ...)) (if (and now-done-p org-log-done) (progn ... ...)) (if (and
org-state dolog) (progn ...)))) (org-todo-trigger-tag-changes org-state)
(and org-auto-align-tags (not org-setting-tags) (org-set-tags nil t)) (if
org-provide-todo-statistics (progn (org-update-parent-todo-statistics)))
(run-hooks (quote org-after-todo-state-change-hook)) (if (and arg (not
(member org-state org-done-keywords))) (progn (setq head
(org-get-todo-sequence-head org-state)))) (put-text-property (point-at-bol)
(point-at-eol) (quote org-todo-head) head) (if now-done-p (progn (if
(boundp ...) (progn ...)) (org-auto-repeat-maybe org-state))) (if (and
(outline-on-heading-p) (not (bolp)) (save-excursion (beginning-of-line 1)
(looking-at org-todo-line-regexp)) (< (point) (+ 2 ...))) (progn (goto-char
(or ... ...)) (and (looking-at " ") (just-one-space)))) (if
org-trigger-hook (progn (save-excursion (run-hook-with-args ...
change-plist)))) (if commentp (progn (org-toggle-comment)))))))
  (if (and (org-region-active-p) org-loop-over-headlines-in-active-region)
(let ((cl (if (eq org-loop-over-headlines-in-active-region (quote
start-level)) (quote region-start-level) (quote region)))
org-loop-over-headlines-in-active-region) (org-map-entries (list (quote
org-todo) arg) org-loop-over-headlines-in-active-region cl (if
(outline-invisible-p) (progn (org-end-of-subtree nil t))))) (if (equal arg
(quote (16))) (progn (setq arg (quote nextset)))) (if (equal arg -1) (progn
(org-cancel-repeater) (setq arg nil))) (let ((org-blocker-hook
org-blocker-hook) commentp case-fold-search) (if (equal arg (quote (64)))
(progn (setq arg nil org-blocker-hook nil))) (if (and org-blocker-hook (or
org-inhibit-blocking (org-entry-get nil "NOBLOCKING"))) (progn (setq
org-blocker-hook nil))) (save-excursion (catch (quote exit)
(org-back-to-heading t) (if (org-in-commented-heading-p t) (progn
(org-toggle-comment) (setq commentp t))) (if (looking-at
org-outline-regexp) (progn (goto-char (1- ...)))) (or (looking-at (concat "
+" org-todo-regexp "\\( +\\|[ ]*$\\)")) (looking-at "\\(?: *\\|[ ]*$\\)"))
(let* ((match-data (match-data)) (startpos (point-at-bol)) (logging (let
... ...)) (org-log-done org-log-done) (org-log-repeat org-log-repeat)
(org-todo-log-states org-todo-log-states) (org-inhibit-logging (if ... ...
org-inhibit-logging)) (this (match-string 1)) (hl-pos (match-beginning 0))
(head (org-get-todo-sequence-head this)) (ass (assoc head
org-todo-kwd-alist)) (interpret (nth 1 ass)) (done-word (nth 3 ass))
(final-done-word (nth 4 ass)) (org-last-state (or this ""))
(completion-ignore-case t) (member (member this org-todo-keywords-1)) (tail
(cdr member)) (org-state (cond ... ... ... ... ... ... ... ... ... ...
...)) (org-state (or ... org-state)) (next (if org-state ... " "))
(change-plist (list :type ... :from this :to org-state :position startpos))
dolog now-done-p) (if org-blocker-hook (progn (setq
org-last-todo-state-is-todo ...) (if ... nil ...))) (store-match-data
match-data) (replace-match next t t) (cond ((equal this org-state) (message
"TODO state was already %s" ...)) ((pos-visible-in-window-p hl-pos)
(message "TODO state changed to %s" ...))) (if head nil (setq head
(org-get-todo-sequence-head org-state) ass (assoc head org-todo-kwd-alist)
interpret (nth 1 ass) done-word (nth 3 ass) final-done-word (nth 4 ass)))
(if (memq arg (quote ...)) (progn (message "Keyword-Set %d/%d: %s" ... ...
...))) (setq org-last-todo-state-is-todo (not (member org-state
org-done-keywords))) (setq now-done-p (and (member org-state
org-done-keywords) (not ...))) (and logging (org-local-logging logging))
(if (and (or org-todo-log-states org-log-done) (not ...) (not ...)) (progn
(setq dolog ...) (if ... ...) (if ... ...) (if ... ...) (if ... ...)))
(org-todo-trigger-tag-changes org-state) (and org-auto-align-tags (not
org-setting-tags) (org-set-tags nil t)) (if org-provide-todo-statistics
(progn (org-update-parent-todo-statistics))) (run-hooks (quote
org-after-todo-state-change-hook)) (if (and arg (not ...)) (progn (setq
head ...))) (put-text-property (point-at-bol) (point-at-eol) (quote
org-todo-head) head) (if now-done-p (progn (if ... ...)
(org-auto-repeat-maybe org-state))) (if (and (outline-on-heading-p) (not
...) (save-excursion ... ...) (< ... ...)) (progn (goto-char ...) (and ...
...))) (if org-trigger-hook (progn (save-excursion ...))) (if commentp
(progn (org-toggle-comment))))))))
  org-todo(nil)
  call-interactively(org-todo)
  org-self-insert-command(1)
  call-interactively(org-self-insert-command nil nil)
  command-execute(org-self-insert-command)

[-- Attachment #2: Type: text/html, Size: 25637 bytes --]

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

* Re: Org Clock Error
  2016-01-13 22:38 Org Clock Error Mike McLean
@ 2016-01-14  1:30 ` Nick Dokos
  2016-01-14  8:45   ` Marco Wahl
  0 siblings, 1 reply; 7+ messages in thread
From: Nick Dokos @ 2016-01-14  1:30 UTC (permalink / raw)
  To: emacs-orgmode

Mike McLean <mike.mclean@pobox.com> writes:

> Hello
>
> In the last few days I started getting an error when moving tasks to the DONE state.
>
> I have ~(setq org-clock-out-when-done t)~ in my Emacs configuration. 
>
> I get the following back trace when I mark a task as done:
>
> Debugger entered--Lisp error: (void-variable org-state)
>   (member org-state org-done-keywords)
>   ...
>   org-clock-out-if-current()
>   run-hooks(org-after-todo-state-change-hook)
>   ...
>   org-todo(nil)

This is probably a lexical binding problem: org-state is supposed to be
dynamically bound by org-todo and then used by org-clock-out-if-current,
but it seems that the communication is lost.

I'm not sure what the solution is (I haven't really followed the
upstream discussion), but I wonder if adding

(defvar org-state)

in org.el, just before the

(defun org-todo ...

line is enough to resolve the problem (basically letting org-todo know
that org-state is dynamically bound).

Untested and possibly wrong.

-- 
Nick

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

* Re: Org Clock Error
  2016-01-14  1:30 ` Nick Dokos
@ 2016-01-14  8:45   ` Marco Wahl
  2016-01-14 15:59     ` Nick Dokos
  0 siblings, 1 reply; 7+ messages in thread
From: Marco Wahl @ 2016-01-14  8:45 UTC (permalink / raw)
  To: emacs-orgmode

Nick Dokos <ndokos@gmail.com> writes:

> Mike McLean <mike.mclean@pobox.com> writes:
>
>> Hello
>>
>> In the last few days I started getting an error when moving tasks to the DONE state.
>>
>> I have ~(setq org-clock-out-when-done t)~ in my Emacs configuration. 
>>
>> I get the following back trace when I mark a task as done:
>>
>> Debugger entered--Lisp error: (void-variable org-state)
>>   (member org-state org-done-keywords)
>>   ...
>>   org-clock-out-if-current()
>>   run-hooks(org-after-todo-state-change-hook)
>>   ...
>>   org-todo(nil)
>
> This is probably a lexical binding problem: org-state is supposed to be
> dynamically bound by org-todo and then used by org-clock-out-if-current,
> but it seems that the communication is lost.
>
> I'm not sure what the solution is (I haven't really followed the
> upstream discussion), but I wonder if adding
>
> (defvar org-state)
>
> in org.el, just before the
>
> (defun org-todo ...
>
> line is enough to resolve the problem (basically letting org-todo know
> that org-state is dynamically bound).
>
> Untested and possibly wrong.

Manually tested your suggestion and it fixes the issue of '(void-variable
org-state)'.

Technically I'm not sure what a reliable fix looks like.  There is
e.g. already the line

(defvar org-state) ;; dynamically scoped into this function

in org-clock.el.


Best regards,
-- 
Marco Wahl
GPG: 0x49010A040A3AE6F2

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

* Re: Org Clock Error
  2016-01-14  8:45   ` Marco Wahl
@ 2016-01-14 15:59     ` Nick Dokos
  2016-01-14 17:30       ` Nick Dokos
  0 siblings, 1 reply; 7+ messages in thread
From: Nick Dokos @ 2016-01-14 15:59 UTC (permalink / raw)
  To: emacs-orgmode

Marco Wahl <marcowahlsoft@gmail.com> writes:

> Nick Dokos <ndokos@gmail.com> writes:
>
>> I'm not sure what the solution is (I haven't really followed the
>> upstream discussion), but I wonder if adding
>>
>> (defvar org-state)
>>
>> in org.el, just before the
>>
>> (defun org-todo ...
>>
>> line is enough to resolve the problem (basically letting org-todo know
>> that org-state is dynamically bound).
>>
>> Untested and possibly wrong.
>
> Manually tested your suggestion and it fixes the issue of '(void-variable
> org-state)'.
>
> Technically I'm not sure what a reliable fix looks like.  There is
> e.g. already the line
>
> (defvar org-state) ;; dynamically scoped into this function
>
> in org-clock.el.
>

Right - and I think that allows the org-clock-* functions to treat
org-state as a dynamically bound variable.

But at the other end, org-todo has to set its value but since it does
not know that org-state is a special variable (I'm guessing while waving
hands violently), it creates its own lexical binding and sets that,
breaking the intended communication.

*Why* org-todo does not know that org-state is a special variable, is an
interesting question. I can see that if one byte-compiles org.el, the
compiler will not know that the variable is special without the defvar
and will translate any references to a stack offset. It is not clear to
me what happens if you run uncompiled: the specialness of the variable
should be globally available, so org-todo *should* be able to figure
things out - I have not tried it, so I don't know whether it does or not
- or whether this is a red herring. These are all guesses, untainted by
actual knowledge or research.

Corrections, clarifications, etc. to any of this are more than welcome.

--
Nick

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

* Re: Org Clock Error
  2016-01-14 15:59     ` Nick Dokos
@ 2016-01-14 17:30       ` Nick Dokos
  2016-01-15 11:03         ` Marco Wahl
  0 siblings, 1 reply; 7+ messages in thread
From: Nick Dokos @ 2016-01-14 17:30 UTC (permalink / raw)
  To: emacs-orgmode

Nick Dokos <ndokos@gmail.com> writes:

> These are all guesses, untainted by actual knowledge or research.
>

OK - here's some actual research for a change. I was wondering what

(defvar org-state)

actually does, so I looked at the source code for defvar. It contains
this comment:

,----
|   else if (!NILP (Vinternal_interpreter_environment)
| 	   && !XSYMBOL (sym)->declared_special)
|     /* A simple (defvar foo) with lexical scoping does "nothing" except
|        declare that var to be dynamically scoped *locally* (i.e. within
|        the current file or let-block).  */
|     Vinternal_interpreter_environment
|       = Fcons (sym, Vinternal_interpreter_environment);
|   else
`----

so it seems to be only active *for that file*: you need "(defvar org-state)" in
each file that uses the variable.

--
Nick

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

* Re: Org Clock Error
  2016-01-14 17:30       ` Nick Dokos
@ 2016-01-15 11:03         ` Marco Wahl
  2016-01-15 20:27           ` Nick Dokos
  0 siblings, 1 reply; 7+ messages in thread
From: Marco Wahl @ 2016-01-15 11:03 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: Nick Dokos, Mike McLean


>>> I have ~(setq org-clock-out-when-done t)~ in my Emacs configuration.
>>> 
>>> I get the following back trace when I mark a task as done:
>>> 
>>> Debugger entered--Lisp error: (void-variable org-state)
>>>
...
> OK - here's some actual research for a change. I was wondering what
>
> (defvar org-state)
>
> actually does, so I looked at the source code for defvar. It contains
> this comment:
>
> ,----
> |   else if (!NILP (Vinternal_interpreter_environment)
> | 	   && !XSYMBOL (sym)->declared_special)
> |     /* A simple (defvar foo) with lexical scoping does "nothing" except
> |        declare that var to be dynamically scoped *locally* (i.e. within
> |        the current file or let-block).  */
> |     Vinternal_interpreter_environment
> |       = Fcons (sym, Vinternal_interpreter_environment);
> |   else
> `----
>
> so it seems to be only active *for that file*: you need "(defvar org-state)" in
> each file that uses the variable.

Thanks for sharing your insights!  This looks good to me.  I just
committed your suggestion.


Best regards,
-- 
Marco Wahl
GPG: 0x49010A040A3AE6F2

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

* Re: Org Clock Error
  2016-01-15 11:03         ` Marco Wahl
@ 2016-01-15 20:27           ` Nick Dokos
  0 siblings, 0 replies; 7+ messages in thread
From: Nick Dokos @ 2016-01-15 20:27 UTC (permalink / raw)
  To: emacs-orgmode

Marco Wahl <marcowahlsoft@gmail.com> writes:

>>>> I have ~(setq org-clock-out-when-done t)~ in my Emacs configuration.
>>>> 
>>>> I get the following back trace when I mark a task as done:
>>>> 
>>>> Debugger entered--Lisp error: (void-variable org-state)
>>>>
> ...
>> OK - here's some actual research for a change. I was wondering what
>>
>> (defvar org-state)
>>
>> actually does, so I looked at the source code for defvar. It contains
>> this comment:
>>
>> ,----
>> |   else if (!NILP (Vinternal_interpreter_environment)
>> | 	   && !XSYMBOL (sym)->declared_special)
>> |     /* A simple (defvar foo) with lexical scoping does "nothing" except
>> |        declare that var to be dynamically scoped *locally* (i.e. within
>> |        the current file or let-block).  */
>> |     Vinternal_interpreter_environment
>> |       = Fcons (sym, Vinternal_interpreter_environment);
>> |   else
>> `----
>>
>> so it seems to be only active *for that file*: you need "(defvar org-state)" in
>> each file that uses the variable.
>
> Thanks for sharing your insights!  This looks good to me.  I just
> committed your suggestion.
>

Thanks! I hope it's correct :-)

--
Nick

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

end of thread, other threads:[~2016-01-15 20:27 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-13 22:38 Org Clock Error Mike McLean
2016-01-14  1:30 ` Nick Dokos
2016-01-14  8:45   ` Marco Wahl
2016-01-14 15:59     ` Nick Dokos
2016-01-14 17:30       ` Nick Dokos
2016-01-15 11:03         ` Marco Wahl
2016-01-15 20:27           ` Nick Dokos

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