Skip to main content leehalls.net

HTML/CSS Formatted Agenda for Emacs Batch Output

UPDATE [2021-01-03 Sun 13:30]

After posting a reply on reddit to request for help on emacs batch mode and the agenda i realised when i migrated from the pi based server to the macmini replacement i had not re-setup batch mode myself, so following my own advice below i recreated the dotemacs added in the css export from a good working installation, altered the org-super-agenda as described here and typed in the magic code:

/usr/local/bin/emacs -Q -batch -l ~/.emacs -eval '(org-batch-store-agenda-views)'

emacs booted up, org-super-agenda began its magic but when viewing the resulting HTML page it was blank. Checking the source shows the agenda, so its exported correctly and in the super-agenda mode but there is something wrong with how the CSS is interpreted, removing the (setq org-agenda-export-html-style code and the agenda is shown but in the old plain format.

So for now the following can be ignored. Pretty bad when your own notes let you down :-O


BELOW NOT QUITE ACCURATE!


Success whhooo … seems sunshine might be good for the brain as i finally have an agenda created in batch mode that renders in a modified gruvbox format (i tweaked the gruvbox el file to my liking). The steps needed;

In your working emacs use C-a and bring up your formatted agenda and then whilst the focus is on the agenda M-x and org-export-htmlize-generate-css this will generate a css file containing all the formatting used, note a lot of it you might not need. Now we have the CSS file we need to add the contents to our dotemacs file.

If you open the file it may start like;

css code snippet start

<style type="text/css">
    <!--
      body {
        color: #fdf4c1;
        background-color: #1d2021;
      }
      .org-border {
      }
      .org-browse-url-button {
        /* browse-url-button */
        color: #458588;
        text-decoration: underline;
      }
      .org-buffer-menu-buffer {
        /* buffer-menu-buffer */
        font-weight: bold;
      }
      .org-builtin {
        /* font-lock-builtin-face */
        color: #fe8019;
      }

css code snippet end

However we cannot just copy/paste into our dotemacs oh no, i’m learning there are always some detours or hurdles to take. The bit we are interested in is everything from body { downwards and not the initial <style type stuff.

So open up the dotemacs file and type

elisp code snippet start

(setq org-agenda-export-html-style
"<style>

<---- paste the copied code here --->

</style>"

elisp code snippet end

What you should see (shortened form shown) is something like;

elisp code snippet start

(setq org-agenda-export-html-style
"<style>
      body {
        color: #fdf4c1;
        background-color: #1d2021;
      }
      .org-border {
      }
      .org-browse-url-button {
        /* browse-url-button */
        color: #458588;
        text-decoration: underline;
      }
      a:hover {
        text-decoration: underline;
      }
</style>"

)

elisp code snippet end

Now when running the command /usr/local/bin/emacs -Q -batch -l ~/.emacs -eval '(org-batch-store-agenda-views)' emacs should output your agenda in gloriously formatted HTML.

Good luck!