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