Saving the organizational agenda

I would like to save the output of the org agenda to a text file, every time an organizational agenda is calculated. Thus, I can use an external program (for example, ATNotes on windows or conky on linux) to pick up this text file and display it on the desktop.

How can i do this?

+4
source share
3 answers

It seems to me that I am stepping on your parade after you have encountered difficulties in writing this code, cut off (and also used part of the advice!), But in fact this function is already baked in org-mode, and is documented in the manual . Required org-write-agenda command (Cx Cw in the agenda buffer). See the org-mode Information Section entitled โ€œExporting Agenda Views.โ€

+3
source

If you want to do this while you open emacs, you can simply call save-buffer in the *Agenda* buffer via Mx save-buffer (since orgmode binds Cx Cs to org-save-all-org-buffer. .. You can bind save-buffer to something else in org-mode-map if you want.

If you want to do this via cron, you can use the fragment in this stream in the org-mode mailing list to send the output to a file. I have used this in the past:

  emacs -batch -eval '(org-batch-agenda "a" org-agenda-ndays 7 org-agenda-include-diary nil org-agenda-files (quote ("~/org/todo.org")))' > agenda.txt 
+2
source

So, I finally decided to open the emacs lisp manual and figure it out myself. I wrote this bit of code that seems to work just fine! :)

 ;; Save the org-agenda for display with conky (defadvice org-todo-list (after saveorgagenda activate) "save this output to my todo file" (get-buffer-create "todo") (with-current-buffer "todo" (set-buffer-modified-p nil)) (kill-buffer "todo") (write-file "~/todo")) 

EDIT REASONS:

1) Without kill-buffer, the defadvice creates a new todo buffer each time the org-todo list is executed. This is annoying.

2) Without the get-buffer-create function, kill buffers are not executed the first time, because at this moment there is no buffer named todo.

3) Without set-buffer-modified-p, the function will continue to tell you that "todo buffer is modified. Do you really want to kill it? (Y or n)" that would really defeat the whole target.

Phew! I am so happy that I actually took the time and effort to figure it out !: D

+1
source

All Articles