20

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?

0

3 Answers 3

22

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.

13

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
  • 1
    After that how can I expand only all TODOs?
    – alper
    Jun 1, 2020 at 10:41
9

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))))
2
  • I am having following message: Global list of TODO items of type: ALL Available with ‘N r’: (0)[ALL]
    – alper
    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 particular N r for some number N will not limit itself to the current file: it will be a global search through the default value of org-agenda-files.
    – NickD
    Apr 26, 2021 at 18:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.