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