3 ms·
And some elisp to create and bind a keymap for those capture invocations might look like: (let ((capture-map (make-sparse-keymap))) (global-set-key (
by throwanem 6y ago
And some elisp to create and bind a keymap for those capture invocations might look like:
(let ((capture-map (make-sparse-keymap)))
(global-set-key (kbd "C-n" capture-map)
(define-key capture-map (kbd "w")
#'(lambda nil (interactive) (org-capture nil "work")))
(define-key capture-map (kbd "h")
#'(lambda nil (interactive) (org-capture nil "home"))))
Doing it as a separate keymap makes it easier to change the keybindings if you later decide to leave C-n at its default binding of next-line - something I actually recommend, since being able to perform cursor movement with keybindings that don't require moving your hands away from the default position has actually proven a lot faster in my experience than using the arrow keys. Navigation via isearch (C-s forward, C-r backward) is faster still, and something I'd really recommend making some time to try out as a newish Emacs user.
- stinkytaco 6y agoThis seems unnecessary when all you need to do is define a key for org capture (I'm assuming here that Cmd-N is mapped to org-capture), which effectively drops you into its own keymap interface. Then the keys for each template are easily defined within template. Or is there something I'm missing here? EDIT: Also, the user's reference to Cmd+N leads me to believe they are still using C-n for navigation but has a Mac, which has an additional key called "Command".
- throwanem 6y agoAh, that's fair. Generally a buffer on a relevant Org file is never not visible to me, so I don't really need org-capture and went with a keymap based on the direct-to-template invocation described in the linked documentation. I also use a Mac for work, but tend to forget about all the complex gymkhana I go through with keyboard prefs and Karabiner-Elements to get its keyboard to behave like those of the Linux and Windows machines I use. Since that includes remapping Caps to Command outside Emacs, and Command to Control inside it, that all probably makes my keybinding advice a little useless, or at least worth more consideration of how things would be in a closer-to-stock configuration.