1 ;;; hydra-ox.el --- Org mode export widget implemented in Hydra
3 ;; Copyright (C) 2015 Free Software Foundation, Inc.
7 ;; This file is part of GNU Emacs.
9 ;; GNU Emacs is free software: you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation, either version 3 of the License, or
12 ;; (at your option) any later version.
14 ;; GNU Emacs is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
24 ;; This shows how a complex dispatch menu can be built with Hydra.
29 (defhydradio hydra-ox ()
30 (body-only "Export only the body.")
31 (export-scope "Export scope." [buffer subtree])
32 (async-export "When non-nil, export async.")
33 (visible-only "When non-nil, export visible only")
34 (force-publishing "Toggle force publishing"))
36 (defhydra hydra-ox-html (:color blue)
38 ("H" (org-html-export-as-html
40 (eq hydra-ox/export-scope 'subtree)
44 ("h" (org-html-export-to-html
46 (eq hydra-ox/export-scope 'subtree)
48 hydra-ox/body-only) "As HTML file")
50 (org-html-export-to-html
52 (eq hydra-ox/export-scope 'subtree)
54 hydra-ox/body-only)) "As HTML file and open")
55 ("b" hydra-ox/body "back")
58 (defhydra hydra-ox-latex (:color blue)
60 ("L" org-latex-export-as-latex "As LaTeX buffer")
61 ("l" org-latex-export-to-latex "As LaTeX file")
62 ("p" org-latex-export-to-pdf "As PDF file")
63 ("o" (org-open-file (org-latex-export-to-pdf)) "As PDF file and open")
64 ("b" hydra-ox/body "back")
67 (defhydra hydra-ox-text (:color blue)
69 ("A" (org-ascii-export-as-ascii
71 '(:ascii-charset ascii))
74 ("a" (org-ascii-export-to-ascii
76 '(:ascii-charset ascii))
78 ("L" (org-ascii-export-as-ascii
80 '(:ascii-charset latin1))
82 ("l" (org-ascii-export-to-ascii
84 '(:ascii-charset latin1))
86 ("U" (org-ascii-export-as-ascii
88 '(:ascii-charset utf-8))
90 ("u" (org-ascii-export-to-ascii
92 '(:ascii-charset utf-8))
94 ("b" hydra-ox/body "back")
99 _C-b_ Body only: % -15`hydra-ox/body-only^^^ _C-v_ Visible only: %`hydra-ox/visible-only
100 _C-s_ Export scope: % -15`hydra-ox/export-scope _C-f_ Force publishing: %`hydra-ox/force-publishing
101 _C-a_ Async export: %`hydra-ox/async-export
104 ("C-b" (hydra-ox/body-only) nil)
105 ("C-v" (hydra-ox/visible-only) nil)
106 ("C-s" (hydra-ox/export-scope) nil)
107 ("C-f" (hydra-ox/force-publishing) nil)
108 ("C-a" (hydra-ox/async-export) nil)
109 ("h" hydra-ox-html/body "Export to HTML" :exit t)
110 ("l" hydra-ox-latex/body "Export to LaTeX" :exit t)
111 ("t" hydra-ox-text/body "Export to Plain Text" :exit t)
114 (define-key org-mode-map (kbd "C-c C-,") 'hydra-ox/body)
118 ;;; hydra-ox.el ends here