4

I want to have in an unique buffer with agenda and todo list, and only for the current buffer (not for all my org mode files).

I found how to define two functions (org-agenda-list-current-file and org-todo-list-current-file) but I cannot manage to write a function calling both agenda and todo-list.

Thanks in advance.

;; org-agenda-current-file : agenda for current buffer 
(defun org-agenda-list-current-file (&optional arg)
  "org-agenda-list, but using only the current buffer's file."
  (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-agenda-list arg))))

;; org-todo-list-current-file : todo list for current buffer 
(defun org-todo-list-current-file (&optional arg)
  "`org-todo-list', but using only the current buffer's file."
  (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))))


;; org-agenda-and-todo-list
    ;;  ???

(setq org-agenda-custom-commands
      '(
        ("a" "calendar" org-agenda-list-current-file )
        ("t" "todo" org-todo-list-current-file )
        ("z" "calendar + todo" org-agenda-and-todo-list )
        ))

1 Answer 1

2

Well, the easiest approach is to use two of Org-mode's existing features together. Use a block agenda to show the agenda and todo list together, like this:

(add-to-list
 'org-agenda-custom-commands
 '("z" "calendar + todo"
   ((agenda "")
    (todo ""))))

And then, when you open the agenda, restrict to the current file with the < key (so, if you have org-agenda bound to C-c a, do C-c a < z instead of just C-c a z).

It's probably possible to use your current approach, or in some other way remove the need for the < prefix here, but the Org-mode code is not exactly straightforward, so I haven't worked out exactly how yet.

Your Answer

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

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