Update
This commit is contained in:
@@ -11,7 +11,75 @@
|
||||
:branch "dev")
|
||||
:hook (org-mode . org-indent-mode)
|
||||
:hook (org-mode . org-cdlatex-mode)
|
||||
|
||||
:pretty-hydra
|
||||
;; See `org-structure-template-alist'
|
||||
((:color blue :quit-key ("q" "C-g"))
|
||||
("Basic"
|
||||
(("a" (hot-expand "<a") "ascii")
|
||||
("c" (hot-expand "<c") "center")
|
||||
("C" (hot-expand "<C") "comment")
|
||||
("x" (hot-expand "<e") "example")
|
||||
("E" (hot-expand "<E") "export")
|
||||
("h" (hot-expand "<h") "html")
|
||||
("l" (hot-expand "<l") "latex")
|
||||
("n" (hot-expand "<n") "note")
|
||||
("o" (hot-expand "<q") "quote")
|
||||
("v" (hot-expand "<v") "verse"))
|
||||
"Head"
|
||||
(("i" (hot-expand "<i") "index")
|
||||
("A" (hot-expand "<A") "ASCII")
|
||||
("I" (hot-expand "<I") "INCLUDE")
|
||||
("H" (hot-expand "<H") "HTML")
|
||||
("L" (hot-expand "<L") "LaTeX"))
|
||||
"Source"
|
||||
(("s" (hot-expand "<s") "src")
|
||||
("e" (hot-expand "<s" "emacs-lisp") "emacs-lisp")
|
||||
("y" (hot-expand "<s" "python :results output") "python")
|
||||
("p" (hot-expand "<s" "perl") "perl")
|
||||
("w" (hot-expand "<s" "powershell") "powershell")
|
||||
("r" (hot-expand "<s" "ruby") "ruby")
|
||||
("S" (hot-expand "<s" "sh") "sh")
|
||||
("g" (hot-expand "<s" "go :imports '\(\"fmt\"\)") "golang"))
|
||||
"Misc"
|
||||
(("m" (hot-expand "<s" "mermaid :file chart.png") "mermaid")
|
||||
("u" (hot-expand "<s" "plantuml :file chart.png") "plantuml")
|
||||
("Y" (hot-expand "<s" "ipython :session :exports both :results raw drawer\n$0") "ipython")
|
||||
("P" (progn
|
||||
(insert "#+HEADERS: :results output :exports both :shebang \"#!/usr/bin/env perl\"\n")
|
||||
(hot-expand "<s" "perl")) "Perl tangled")
|
||||
("<" self-insert-command "ins"))))
|
||||
:bind (:map org-mode-map
|
||||
("<" . (lambda ()
|
||||
"Insert org template."
|
||||
(interactive)
|
||||
(if (or (region-active-p) (looking-back "^\s*" 1))
|
||||
(org-hydra/body)
|
||||
(self-insert-command 1)))))
|
||||
:config
|
||||
;; For hydra
|
||||
(defun hot-expand (str &optional mod)
|
||||
"Expand org template.
|
||||
|
||||
STR is a structure template string recognised by org like <s. MOD is a
|
||||
string with additional parameters to add the begin line of the
|
||||
structure element. HEADER string includes more parameters that are
|
||||
prepended to the element after the #+HEADER: tag."
|
||||
(let (text)
|
||||
(when (region-active-p)
|
||||
(setq text (buffer-substring (region-beginning) (region-end)))
|
||||
(delete-region (region-beginning) (region-end)))
|
||||
(insert str)
|
||||
(if (fboundp 'org-try-structure-completion)
|
||||
(org-try-structure-completion) ; < org 9
|
||||
(progn
|
||||
;; New template expansion since org 9
|
||||
(require 'org-tempo nil t)
|
||||
(org-tempo-complete-tag)))
|
||||
(when mod (insert mod) (forward-line))
|
||||
(when text (insert text))))
|
||||
|
||||
|
||||
;; (org-capture-init)
|
||||
(add-to-list 'org-modules 'org-habit)
|
||||
(setq org-directory "~/org/")
|
||||
|
||||
Reference in New Issue
Block a user