-
-
Notifications
You must be signed in to change notification settings - Fork 113
Org mode block templates
Heikki Lehvaslaiho edited this page Mar 8, 2015
·
15 revisions
This is an expansion of hydra from org-mode block templates in Hydra. Instead of using skeletons, different programming language src blocks can have their own keys in this hydra. The few below are just examples. This approach could be expanded further by adding interactive lisp commands to fill in input and output strings.
(defhydra hydra-org-template (:color blue :hint nil)
"
_c_enter _q_uote _e_macs-lisp _L_aTeX:
_l_atex _e_xample _p_erl _i_ndex:
_a_scii _v_erse _P_erl tangled _I_NCLUDE:
_s_rc ^ ^ plant_u_ml _H_TML:
_h_tml ^ ^ ^ ^ _A_SCII:
"
("s" (hot-expand "<s"))
("e" (hot-expand "<e"))
("q" (hot-expand "<q"))
("v" (hot-expand "<v"))
("c" (hot-expand "<c"))
("l" (hot-expand "<l"))
("h" (hot-expand "<h"))
("a" (hot-expand "<a"))
("L" (hot-expand "<L"))
("i" (hot-expand "<i"))
("e" (progn (hot-expand "<s") (insert "emacs-lisp") (forward-line)))
("p" (progn (hot-expand "<s") (insert "perl") (forward-line)))
("u" (progn (hot-expand "<s") (insert "plantuml :file CHANGE.png") (forward-line)))
("P" (progn
(insert "#+HEADERS: :results output :exports both :shebang \"#!/usr/bin/env perl\"\n")
(hot-expand "<s")
(insert "perl")
(forward-line)))
("I" (hot-expand "<I"))
("H" (hot-expand "<H"))
("A" (hot-expand "<A"))
("<" self-insert-command "ins")
("o" nil "quit"))
(defun hot-expand (str)
"Expand org template."
(insert str)
(org-try-structure-completion))
;; I bind it for myself like this:
(define-key org-mode-map "<"
(lambda () (interactive)
(if (looking-back "^")
(hydra-org-template/body)
(self-insert-command 1))))
- Binding-Styles
- Basics
- Verbosity
- Verbosity-Long-Short
- Conditional-Hydra
- defcustom
- Hydra-Colors
- internals
- Nesting-Hydras
- Prefix-map