]> code.delx.au - gnu-emacs-elpa/blob - packages/hydra/hydra-ox.el
Merge commit '199c52606dcd614cb856bbcaca13b5fada0772b6' from avy
[gnu-emacs-elpa] / packages / hydra / hydra-ox.el
1 ;;; hydra-ox.el --- Org mode export widget implemented in Hydra
2
3 ;; Copyright (C) 2015 Free Software Foundation, Inc.
4
5 ;; Author: Oleh Krehel
6
7 ;; This file is part of GNU Emacs.
8
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.
13
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.
18
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/>.
21
22 ;;; Commentary:
23 ;;
24 ;; This shows how a complex dispatch menu can be built with Hydra.
25
26 ;;; Code:
27 (require 'org)
28 (require 'hydra) ;`defhydradio' is not autoloaded!
29
30 (defhydradio hydra-ox ()
31 (body-only "Export only the body.")
32 (export-scope "Export scope." [buffer subtree])
33 (async-export "When non-nil, export async.")
34 (visible-only "When non-nil, export visible only")
35 (force-publishing "Toggle force publishing"))
36
37 (defhydra hydra-ox-html (:color blue)
38 "ox-html"
39 ("H" (org-html-export-as-html
40 hydra-ox/async-export
41 (eq hydra-ox/export-scope 'subtree)
42 hydra-ox/visible-only
43 hydra-ox/body-only)
44 "As HTML buffer")
45 ("h" (org-html-export-to-html
46 hydra-ox/async-export
47 (eq hydra-ox/export-scope 'subtree)
48 hydra-ox/visible-only
49 hydra-ox/body-only) "As HTML file")
50 ("o" (org-open-file
51 (org-html-export-to-html
52 hydra-ox/async-export
53 (eq hydra-ox/export-scope 'subtree)
54 hydra-ox/visible-only
55 hydra-ox/body-only)) "As HTML file and open")
56 ("b" hydra-ox/body "back")
57 ("q" nil "quit"))
58
59 (defhydra hydra-ox-latex (:color blue)
60 "ox-latex"
61 ("L" org-latex-export-as-latex "As LaTeX buffer")
62 ("l" org-latex-export-to-latex "As LaTeX file")
63 ("p" org-latex-export-to-pdf "As PDF file")
64 ("o" (org-open-file (org-latex-export-to-pdf)) "As PDF file and open")
65 ("b" hydra-ox/body "back")
66 ("q" nil "quit"))
67
68 (defhydra hydra-ox-text (:color blue)
69 "ox-text"
70 ("A" (org-ascii-export-as-ascii
71 nil nil nil nil
72 '(:ascii-charset ascii))
73 "As ASCII buffer")
74
75 ("a" (org-ascii-export-to-ascii
76 nil nil nil nil
77 '(:ascii-charset ascii))
78 "As ASCII file")
79 ("L" (org-ascii-export-as-ascii
80 nil nil nil nil
81 '(:ascii-charset latin1))
82 "As Latin1 buffer")
83 ("l" (org-ascii-export-to-ascii
84 nil nil nil nil
85 '(:ascii-charset latin1))
86 "As Latin1 file")
87 ("U" (org-ascii-export-as-ascii
88 nil nil nil nil
89 '(:ascii-charset utf-8))
90 "As UTF-8 buffer")
91 ("u" (org-ascii-export-to-ascii
92 nil nil nil nil
93 '(:ascii-charset utf-8))
94 "As UTF-8 file")
95 ("b" hydra-ox/body "back")
96 ("q" nil "quit"))
97
98 (defhydra hydra-ox ()
99 "
100 _C-b_ Body only: % -15`hydra-ox/body-only^^^ _C-v_ Visible only: %`hydra-ox/visible-only
101 _C-s_ Export scope: % -15`hydra-ox/export-scope _C-f_ Force publishing: %`hydra-ox/force-publishing
102 _C-a_ Async export: %`hydra-ox/async-export
103
104 "
105 ("C-b" (hydra-ox/body-only) nil)
106 ("C-v" (hydra-ox/visible-only) nil)
107 ("C-s" (hydra-ox/export-scope) nil)
108 ("C-f" (hydra-ox/force-publishing) nil)
109 ("C-a" (hydra-ox/async-export) nil)
110 ("h" hydra-ox-html/body "Export to HTML" :exit t)
111 ("l" hydra-ox-latex/body "Export to LaTeX" :exit t)
112 ("t" hydra-ox-text/body "Export to Plain Text" :exit t)
113 ("q" nil "quit"))
114
115 (define-key org-mode-map (kbd "C-c C-,") 'hydra-ox/body)
116
117 (provide 'hydra-ox)
118
119 ;;; hydra-ox.el ends here