In org-mode, I like to run org-todo-list
, which displays the global todo list including all my org-agenda files. How do I view a TODO list for only the current buffer, ignoring my other org-agenda files?
3 Answers
You can use <
from the agenda menu to restrict the current agenda call to the buffer that the agenda was invoked from. To restrict to that file for more than one call, you can use C-c C-x <
(org-agenda-set-restriction-lock
). See (info "(org) Agenda files")
for more information.
You can use org-show-todo-tree
to get a sparse tree view of the current buffer's TODO items. It's bound to C-c / t
by default.
-
1
You could bind org-agenda-files
dynamically to the current buffer's file and call org-todo-list
from there:
(defun org-todo-list-current-file (&optional arg)
"Like `org-todo-list', but using only the current buffer's file."
(interactive "P")
(let ((org-agenda-files (list (buffer-file-name (current-buffer)))))
(if (null (car org-agenda-files))
(error "%s is not visiting a file" (buffer-name (current-buffer)))
(org-todo-list arg))))
-
I am having following message:
Global list of TODO items of type: ALL Available with ‘N r’: (0)[ALL]
– alperCommented Jun 1, 2020 at 10:42 -
The let-binding of
org-agenda-files
is only good for this command and will be reverted for any additional searches, so in particularN r
for some number N will not limit itself to the current file: it will be a global search through the default value oforg-agenda-files
.– NickDCommented Apr 26, 2021 at 18:57