4

When composing my weekly schedule, it feels somewhat jarring to have to switch to the agenda buffer in the other frame and rebuild, just to see how things align. Adding org-agenda-redo to after-save-hook doesn't seem to work. Having the hook call (org-agenda-redo t), which should rebuild ALL agenda buffers, doesn't seem to work either.

Here's a sample of the code I'm using:

(defun org-agenda-redo-all ()
  "Rebuild all agenda buffers"
  (org-agenda-redo t))

(add-hook 'org-mode-hook
          (lambda()
            (add-hook 'after-save-hook 'org-agenda-redo-all nil 'make-it-local)))

According to the *Messages* buffer, org-agenda-redo appears to be called:

Saving file /home/mkaito/notes/agenda.org...
Wrote /home/mkaito/notes/agenda.org
Rebuilding agenda buffer...done

But the agenda buffer in the other frame is not updated.

5

org-agenda-redo does not rebuilt all agenda buffers rather it rebuilts all views in current buffer. From the documentation C-hforg-agenda-redoRET

(org-agenda-redo &optional ALL)

Rebuild possibly ALL agenda view(s) in the current buffer.

You will need to manually loop through all agenda buffers and rebuild them. Below is one such command

(defun my-redo-all-agenda-buffers ()
  (interactive)
  (dolist (buffer (buffer-list))
    (with-current-buffer buffer
      (when (derived-mode-p 'org-agenda-mode)
        (org-agenda-redo t)))))
| improve this answer | |
  • 1
    Knowing how to loop over all buffers will be useful in the future. Thank you! – mkaito Sep 5 '15 at 11:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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