# Emacs Quick Capture

I like to use org-mode in Emacs; it is rather well described by its slogan, ‘your life in plain text’. When I am working in Emacs, which is quite often, my key bindings allow me to very easily take notes and add tasks to my agenda using org-capture, and then switch back to what I was doing. The following configuration allows me to access the same functionality quickly from outside Emacs.

In my Emacs configuration I have defined the following function:

(defun abs--quick-capture ()
;; redefine the function that splits the frame upon org-capture
(defun abs--org-capture-place-template-dont-delete-windows (oldfun args)
(cl-letf (((symbol-function 'org-switch-to-buffer-other-window) 'switch-to-buffer))
(apply oldfun args)))

;; run-once hook to close window after capture
(defun abs--delete-frame-after-capture ()
(delete-frame)
(remove-hook 'org-capture-after-finalize-hook 'abs--delete-frame-after-capture)
)

;; set frame title
(set-frame-name "emacs org capture")
(abs--org-capture-place-template-dont-delete-windows 'org-capture nil)
)

The function sets the frame title to “emacs org capture” (so that my window manager will recognize it), opens org-capture and automatically closes the frame when I either cancel or finish the capture session. To open org-capture in a popup window from anywhere outside emacs, I have the following shell script in my path:

#!/bin/sh

emacsclient -c -e "(abs--quick-capture)"

When run, the script opens a new Emacs frame (-c) and runs the function defined above, so that I can immediately capture whatever I have in mind.

Finally, my window manager, i3, is configured with a global shortcut (Mod4-c) to run the script and float the corresponding window:

bindsym \$mod+c exec "/home/abel/bin/ecapture"

for_window [title="emacs org capture"] floating enable