This is a useful configuration for a distraction-free note-taking system. Often
you want to quickly note something but don't want to break your flow too much.
The result will be a single key-combination that will pop a frame, allow you to
write in a task, and have it be written to your default org-mode file.
Nearly all of the meat of this configuration comes from Phil Windley's blog post. I assume you already have experience with org-mode.
;; org-capture code for popping a frame, from Phil Windley
;; http://www.windley.com/archives/2010/12/capture_mode_and_emacs.shtml
;; We configure a very simple default template
(setq org-capture-templates
'(("t" "Todo" entry (file "") ; use the default notes files
"* TODO %? %i %t")))
(defadvice org-capture-finalize
(after delete-capture-frame activate)
"Advise capture-finalize to close the frame"
(if (equal "capture" (frame-parameter nil 'name))
(delete-frame)))
(defadvice org-capture-destroy
(after delete-capture-frame activate)
"Advise capture-destroy to close the frame"
(if (equal "capture" (frame-parameter nil 'name))
(delete-frame)))
;; make the frame contain a single window. by default org-capture
;; splits the window.
(add-hook 'org-capture-mode-hook
'delete-other-windows)
(defun make-capture-frame ()
"Create a new frame and run org-capture."
(interactive)
(make-frame '((name . "capture")
(width . 120)
(height . 15)))
(select-frame-by-name "capture")
(setq word-wrap 1)
(setq truncate-lines nil)
;; Using the second argument to org-capture, we bypass interactive selection
;; and use the existing template defined above.
(org-capture nil "t"))
Now we add the binding to your (hopefully existing) call to the xmonad
additionalKeysP
function, which uses emacs-style notation for the keybindings.
popCaptureFrameCommand = "emacsclient -n -e '(make-capture-frame)'"
myConfig = desktopConfig
{
-- your existing config here
}
`additionalKeysP` [("M-o c", spawn popCaptureFrameCommand),
-- probably more existing bindings...
]
Now you can type M-o c, you'll be popped into a capture buffer, then C-c C-c will save and file it and close the window. It'll appear as a top-level heading in the file. You can change the template definition if you are more OCD-minded but I find that this simplistic configuration works and stays out of my way.