Search code examples
emacsorg-mode

Emacs org-agenda Export agenda -how to?


I'am new with Emacs and certainly with lisp. I know that we can save an agenda (view?) with C-x C-w. Fine but can we do that with the (setq org-agenda-custom-commands) ? I would like to save the weekly agenda to a .txt file (like agenda.txt).


Solution

  • Accounding the documentation of org-agenda-custom-commands(partly paste here):

    Custom commands for the agenda. Each entry is a list like this:
    
    (key desc type match settings files)
    
    or
    
    (key desc (cmd1 cmd2 ...) general-settings-for-whole-set files)
    
    files     A list of files to write the produced agenda buffer to with
              the command org-store-agenda-views.
              If a file name ends in ".html", an HTML version of the buffer
              is written out.  If it ends in ".ps", a postscript version is
              produced.  Otherwise, only the plain text is written to the file.
    
    

    You can set org-agenda-custom-commands like:

    (setq org-agenda-custom-commands
          '(("n" "Agenda and all TODOs"
             ((agenda "")
              (alltodo ""))
             nil
             ("~/agenda.txt"))))
    

    and then M-x org-agenda n M-x org-store-agenda-views to save the agenda view to ~/agenda.txt.

    or you can write a function to do this.

    (defun save-agenda-view (&optional arg)
      (interactive "P")
      (org-agenda arg "n")
      (org-store-agenda-views))