Description
When calling org-todo
from a function, e.g., via org-map-entries
or search-forward
(see example code below), then the todo state change logging is only applied to one matched heading.
For example, calling one of these mark-done
functions:
(defun mark-done ()
(interactive)
(org-map-entries
(lambda ()
(org-todo "DONE"))
"/TODO" 'file))
(defun mark-done ()
(interactive)
(let ((case-fold-search nil))
(goto-char (point-min))
(while (search-forward " TODO " nil t)
(org-todo "DONE"))))
On this file:
#+TODO: TODO(t) WAIT(w) | DONE(d!)
* WAIT W1
SCHEDULED: <2000-01-01 Sat>
* TODO T1
SCHEDULED: <2000-01-01 Sat>
* WAIT W2
SCHEDULED: <2000-01-01 Sat>
* TODO T2
SCHEDULED: <2000-01-01 Sat>
Results in this file (State
line not added to T1
, only added to T2
):
#+TODO: TODO(t) WAIT(w) | DONE(d!)
* WAIT W1
SCHEDULED: <2000-01-01 Sat>
* DONE T1
CLOSED: [2000-01-01 Sat 00:01] SCHEDULED: <2000-01-01 Sat>
* WAIT W2
SCHEDULED: <2000-01-01 Sat>
* DONE T2
CLOSED: [2000-01-01 Sat 00:01] SCHEDULED: <2000-01-01 Sat>
- State "DONE" from "TODO" [2000-01-01 Sat 00:01]
This could be a bug, but my (e)lisp knowledge is basically nil
, so I am not sure how to investigate it further or if I am calling the function incorrectly.
Question
How do you make org-todo
apply todo state change logging to all headings, when called from a function? I.e., how can you replicate the behavior of manually calling org-todo
on each headline?
Version
This was run as emacs -Q
in:
GNU Emacs 26.1 (build 1, x86_64-pc-linux-gnu, X toolkit, Xaw scroll bars) of 2019-03-25
.Org mode version 9.1.9 (release_9.1.9-65-g5e4542 @ /usr/share/emacs/26.1/lisp/org/
.