Using ad-hoc views for emacs org agenda


This article summarizes my approach to start major modes in emacs as dedicated application.


What is a view? Well, if you're searching for solutions to start emacs with an org-agenda, you often get the advice to use init-buffer or something similar 'hooked' after the init or frame etc. My current approach, however, is different. Yes, I keep all my configs inside emacs but build ad-hoc "views" for dedicated use-cases when I need it.

Org Agenda Use-Case

One of such an use-case is my daily agenda. The idea here is to start an emacs instance that shows my (pre-defined) daily agenda and can be closed by pressing <q>. To achieve the intended behavior I'm using a shell script that setups and starts emacs.

Due to the fact that you can use any application within the very first shebang line of a script, rather then #!/bin/sh you can use:


This is what I do in normal case (ie. Unix, Linux, Windo... - not really).

So, on most of the system I have in use, I'll came up with something like:


emacs \
    --eval "(org-agenda nil \"d\")" \
    --eval "(delete-other-windows)" \
    --eval "(defun kill-window-or-emacs () (interactive) (if (one-window-p) (kill-emacs) (delete-window)))" \
    --eval "(defun exit-from-here () (interactive) (org-agenda-exit) (kill-window-or-emacs))" \
    --eval "(define-key org-agenda-mode-map [remap org-agenda-quit] 'exit-from-here)"

Adapt it for Mac OS

BUT, to make that approach also work on MacOS, I'm using Automator. In Automator, I create a pogram (ie. runemacs) for a shell environment (ie. /bin/zsh). Instead of the shebang line in combination with emacs the very first line looks like

open -n /Applications/ --args \
     --eval ....

Keep in mind to adapt the path where you stored the accordingly (I installed it as my local user under Applications). After saving that program (ie. under ~/.local/bin/runemacs) you can execute it and an emacs showing a daily agenda pops up. In addition, you can automatically launch runemacs at system startup after login by adding it to the list of startup programs.

Bonus: Elgato Stream Deck

You can combine your Automator script with Elgato Stream Deck which brings your every-day used emacs commands close to your fingertips. Doing so is rather easy, choose 'Run Application' (ie. with the rocket icon) within Elgato Desktop application and select the path to your Automator script. If you want, you can also choose an alterantive icon to get rid off the stock icon set.