Add support for BEAMER notes.
[org-mode.git] / lisp / org-beamer.el
blobeb08ca403f6bf43a39b4ec283b3a1294dbe07ba2
1 ;;; org-beamer.el --- Beamer-specific LaTeX export for org-mode
2 ;;
3 ;; Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc.
4 ;;
5 ;; Version: 6.33trans
6 ;; Author: Carsten Dominik <carsten.dominik AT gmail DOT com>
7 ;; Maintainer: Carsten Dominik <carsten.dominik AT gmail DOT com>
8 ;; Keywords: org, wp, tex
10 ;; This file is part of GNU Emacs.
12 ;; GNU Emacs is free software: you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation, either version 3 of the License, or
15 ;; (at your option) any later version.
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
25 ;;; Commentary:
27 ;; This library implement the special treatment needed by using the
28 ;; beamer class during LaTeX export.
30 (require 'org)
31 (require 'org-exp)
32 (defvar org-export-latex-header)
33 (defvar org-export-latex-options-plist)
34 (defvar org-export-opt-plist)
36 (defgroup org-beamer nil
37 "Options specific for using the beamer class in LaTeX export."
38 :tag "Org Beamer"
39 :group 'org-export-latex)
41 (defcustom org-beamer-use-parts nil
43 :group 'org-beamer
44 :type 'boolean)
46 (defcustom org-beamer-frame-level 1
47 "The level that should be interpreted as a frame.
48 The levels above this one will be translated into a sectioning structure.
49 Setting this to 2 will allow sections, 3 will allow subsections as well.
50 You can se this to 4 as well, if you at the same time set
51 `org-beamer-use-parts' to make the top levels `\part'."
52 :group 'org-beamer
53 :type '(choice
54 (const :tag "Frames need a BEAMER_env property" nil)
55 (integer :tag "Specific level makes a frame")))
57 (defcustom org-beamer-column-view-format
58 "%45ITEM %10BEAMER_env(Env) %10BEAMER_envargs(Env Args) %4BEAMER_col(Col) %8BEAMER_extra(Extra)"
59 "Default column view format that should be used to fill the template."
60 :group 'org-beamer
61 :type '(string :tag "Beamer column view format"))
63 (defcustom org-beamer-themes
64 "\\usetheme{default}\\usecolortheme{default}"
65 "Default string to be used for extra heading stuff in beamer presentations.
66 When a beamer template is filled, this will be the default for
67 BEAMER_HEADER_EXTRA, which will be inserted just before \\begin{document}."
68 :group 'org-beamer
69 :type '(string :tag "Beamer column view format"))
72 (defconst org-beamer-column-widths
73 "0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 0.0 :ETC"
74 "The column widths that should be installed as allowed property values.")
76 (defconst org-beamer-transitions
77 "\transblindsvertical \transblindshorizontal \transboxin \transboxout \transdissolve \transduration \transglitter \transsplithorizontalin \transsplithorizontalout \transsplitverticalin \transsplitverticalout \transwipe :ETC"
78 "Transitions available for beamer.
79 These are just a completion help.")
81 (defconst org-beamer-environments-default
82 '(("frame" "f" "dummy- special handling hard coded" "dummy")
83 ("columns" "C" "\\begin{columns}%o %% %h%x" "\\end{columns}")
84 ("column" "c" "\\begin{column}%o{%h\\textwidth}%x" "\\end{column}")
85 ("block" "b" "\\begin{block}%a{%h}%x" "\\end{block}")
86 ("alertblock" "a" "\\begin{alertblock}%a{%h}%x" "\\end{alertblock}")
87 ("verse" "v" "\\begin{verse}%a %% %h%x" "\\end{verse}")
88 ("quotation" "q" "\\begin{quotation}%a %% %h%x" "\\end{quotation}")
89 ("quote" "Q" "\\begin{quote}%a %% %h%x" "\\end{quote}")
90 ("structureenv" "s" "\\begin{structureenv}%a %% %h%x" "\\end{structureenv}")
91 ("theorem" "t" "\\begin{theorem}%a%U%x" "\\end{theorem}")
92 ("definition" "d" "\\begin{definition}%a%U%x" "\\end{definition}")
93 ("example" "e" "\\begin{example}%a%U%x" "\\end{example}")
94 ("proof" "p" "\\begin{proof}%a%U%x" "\\end{proof}")
95 ("beamercolorbox" "o" "\\begin{beamercolorbox}%o{%h}%x" "\\end{beamercolorbox}")
96 ("normal" "h" "%h" "") ; Emit the heading as normal text
97 ("note" "n" "\\note%o%a{%h" "}")
98 ("noteNH" "N" "\\note%o%a{" "}") ; note, ignore heading
99 ("ignoreheading" "i" "%%%% %h" ""))
100 "Environments triggered by properties in Beamer export.
101 These are the defaults - for user definitions, see
102 `org-beamer-environments-extra'.
103 \"normal\" is a special fake environment, which emite the heading as
104 normal text. It is needed when an environment should be surrounded
105 by normal text. Since beamer export converts nodes into environments,
106 you need to have a node to end the environment.
107 For example
109 ** a frame
110 some text
111 *** Blocktitle :B_block:
112 inside the block
113 *** After the block :B_normal:
114 continuing here
115 ** next frame")
117 (defcustom org-beamer-environments-extra nil
118 "Environments triggered by tags in Beamer export.
119 Each entry has 4 elements:
121 name Name of the environment
122 key Selection key for `org-beamer-set-environment-tag'
123 open The opening template for the environment, with the following excapes
124 %a the action/overlay specification
125 %A the default action/overlay specification
126 %o the options argument of the template
127 %h the headline text
128 %H if there is headline text, that text in {} braces
129 %U if there is headline text, that text in [] brackets
130 close The closing string of the environment."
132 :group 'org-beamer
133 :type '(repeat
134 (list
135 (string :tag "Environment")
136 (string :tag "Selection key")
137 (string :tag "Begin")
138 (string :tag "End"))))
140 (defvar org-beamer-frame-level-now nil)
141 (defvar org-beamer-header-extra nil)
142 (defvar org-beamer-export-is-beamer-p nil)
143 (defvar org-beamer-inside-frame-at-level nil)
144 (defvar org-beamer-columns-open nil)
145 (defvar org-beamer-column-open nil)
147 (defun org-beamer-cleanup-column-width (width)
148 "Make sure the width is not empty, and that it has a unit."
149 (setq width (org-trim (or width "")))
150 (unless (string-match "\\S-" width) (setq width "0.5"))
151 (if (string-match "\\`[.0-9]+\\'" width)
152 (setq width (concat width "\\textwidth")))
153 width)
155 (defun org-beamer-open-column (&optional width opt)
156 (org-beamer-close-column-maybe)
157 (setq org-beamer-column-open t)
158 (setq width (org-beamer-cleanup-column-width width))
159 (insert (format "\\begin{column}%s{%s}\n" (or opt "") width)))
160 (defun org-beamer-close-column-maybe ()
161 (when org-beamer-column-open
162 (setq org-beamer-column-open nil)
163 (insert "\\end{column}\n")))
164 (defun org-beamer-open-columns-maybe (&optional opts)
165 (unless org-beamer-columns-open
166 (setq org-beamer-columns-open t)
167 (insert (format "\\begin{columns}%s\n" (or opts "")))))
168 (defun org-beamer-close-columns-maybe ()
169 (org-beamer-close-column-maybe)
170 (when org-beamer-columns-open
171 (setq org-beamer-columns-open nil)
172 (insert "\\end{columns}\n")))
174 (defun org-beamer-set-environment-tag ()
175 "Set an environment tag, to determine the beamer environment to be used.
176 This makes use of the fast tag selection interface."
177 (interactive)
178 (let* ((envs (append org-beamer-environments-extra
179 org-beamer-environments-default))
180 (org-tag-alist
181 (append '((:startgroup))
182 (mapcar (lambda (e) (cons (concat "B_" (car e))
183 (string-to-char (nth 1 e))))
184 envs)
185 '((:endgroup))
186 '(("BMCOL" . ?|))))
187 (org-fast-tag-selection-single-key t))
188 (org-set-tags)
189 (let ((tags (or (ignore-errors (org-get-tags-string)) "")))
190 (cond
191 ((equal org-last-tag-selection-key ?|)
192 (if (string-match ":BMCOL:" tags)
193 (org-set-property "BEAMER_col" (read-string "Column width: "))
194 (org-delete-property "BEAMER_col")))
195 ((string-match (concat ":B_\\("
196 (mapconcat 'car envs "\\|")
197 "\\):")
198 tags)
199 (org-entry-put nil "BEAMER_env" (match-string 1 tags)))
200 (t (org-entry-delete nil "BEAMER_env"))))))
203 (defun org-beamer-sectioning (level text)
204 "Return the sectioning entry for the current headline.
205 LEVEL is the reduced level of the headline.
206 TEXT is the text of the headline, everything except the leading stars.
207 The return value is a cons cell. The car is the headline text, usually
208 just TEXT, but possibly modified if options have been extracted from the
209 text. The cdr is the sectioning entry, similar to what is given
210 in org-export-latex-classes."
211 (let* ((frame-level (or org-beamer-frame-level-now org-beamer-frame-level))
212 (default
213 (if org-beamer-use-parts
214 '((1 . ("\\part{%s}" . "\\part*{%s}"))
215 (2 . ("\\section{%s}" . "\\section*{%s}"))
216 (3 . ("\\subsection{%s}" . "\\subsection*{%s}")))
217 '((1 . ("\\section{%s}" . "\\section*{%s}"))
218 (2 . ("\\subsection{%s}" . "\\subsection*{%s}")))))
219 (envs (append org-beamer-environments-extra
220 org-beamer-environments-default))
221 (props (org-get-text-property-any 0 'org-props text))
222 (in "") (out "") option action defaction environment extra
223 columns-option column-option
224 env have-text ass tmp)
225 (if (= frame-level 0) (setq frame-level nil))
226 (when (and org-beamer-inside-frame-at-level
227 (<= level org-beamer-inside-frame-at-level))
228 (setq org-beamer-inside-frame-at-level nil))
229 (when (setq tmp (org-beamer-assoc-not-empty "BEAMER_col" props))
230 (if (and (string-match "\\`[0-9.]+\\'" tmp)
231 (or (= (string-to-number tmp) 1.0)
232 (= (string-to-number tmp) 0.0)))
233 ;; column width 1 means cloase columns, go back to full width
234 (org-beamer-close-columns-maybe)
235 (when (setq ass (assoc "BEAMER_envargs" props))
236 (let (case-fold-search)
237 (when (string-match "C\\(\\[[^][]*\\]\\)" (cdr ass))
238 (setq columns-option (match-string 1 (cdr ass)))
239 (setcdr ass (replace-match "" t t (cdr ass))))
240 (when (string-match "c\\(\\[[^][]*\\]\\)" (cdr ass))
241 (setq column-option (match-string 1 (cdr ass)))
242 (setcdr ass (replace-match "" t t (cdr ass))))))
243 (org-beamer-open-columns-maybe columns-option)
244 (org-beamer-open-column tmp column-option)))
245 (cond
246 ((or (equal (cdr (assoc "BEAMER_env" props)) "frame")
247 (and frame-level (= level frame-level)))
248 ;; A frame
249 (org-beamer-get-special props)
251 (setq in (org-fill-template
252 "\\begin{frame}%a%A%o%T%S%x"
253 (list (cons "a" (or action ""))
254 (cons "A" (or defaction ""))
255 (cons "o" (or option ""))
256 (cons "x" (if extra (concat "\n" extra) ""))
257 (cons "h" "%s")
258 (cons "T" (if (string-match "\\S-" text)
259 "\n\\frametitle{%s}" ""))
260 (cons "S" (if (string-match "\\\\\\\\" text)
261 "\n\\framesubtitle{%s}" ""))))
262 out (copy-sequence "\\end{frame}"))
263 (org-add-props out
264 '(org-insert-hook org-beamer-close-columns-maybe))
265 (setq org-beamer-inside-frame-at-level level)
266 (cons text (list in out in out)))
267 ((and (setq env (cdr (assoc "BEAMER_env" props)))
268 (setq ass (assoc env envs)))
269 ;; A beamer environment selected by the BEAMER_env property
270 (if (string-match "[ \t]+:[ \t]*$" text)
271 (setq text (replace-match "" t t text)))
272 (if (member env '("note" "noteNH"))
273 ;; There should be no labels in a note, so we remove the targets
274 ;; FIXME???
275 (remove-text-properties 0 (length text) '(target nil) text))
276 (org-beamer-get-special props)
277 (setq text (org-trim text))
278 (setq have-text (string-match "\\S-" text))
279 (setq in (org-fill-template
280 (nth 2 ass)
281 (list (cons "a" (or action ""))
282 (cons "A" (or defaction ""))
283 (cons "o" (or option ""))
284 (cons "x" (if extra (concat "\n" extra) ""))
285 (cons "h" "%s")
286 (cons "H" (if have-text (concat "{" text "}") ""))
287 (cons "U" (if have-text (concat "[" text "]") ""))))
288 out (nth 3 ass))
289 (cond
290 ((equal out "\\end{columns}")
291 (setq org-beamer-columns-open t)
292 (setq out (org-add-props (copy-sequence out)
293 '(org-insert-hook
294 (lambda ()
295 (org-beamer-close-column-maybe)
296 (setq org-beamer-columns-open nil))))))
297 ((equal out "\\end{column}")
298 (org-beamer-open-columns-maybe)))
299 (cons text (list in out in out)))
300 ((and (not org-beamer-inside-frame-at-level)
301 (or (not frame-level)
302 (< level frame-level))
303 (assoc level default))
304 ;; Normal sectioning
305 (cons text (cdr (assoc level default))))
306 (t nil))))
308 (defvar extra)
309 (defvar option)
310 (defvar action)
311 (defvar defaction)
312 (defvar environment)
313 (defun org-beamer-get-special (props)
314 "Extract an option, action, and default action string from text.
315 The variables option, action, defaction, extra are all scoped into
316 this function dynamically."
317 (let (tmp)
318 (setq environment (org-beamer-assoc-not-empty "BEAMER_env" props))
319 (setq extra (org-beamer-assoc-not-empty "BEAMER_extra" props))
320 (when extra
321 (setq extra (replace-regexp-in-string "\\\\n" "\n" extra)))
322 (setq tmp (org-beamer-assoc-not-empty "BEAMER_envargs" props))
323 (when tmp
324 (setq tmp (copy-sequence tmp))
325 (if (string-match "\\[<[^][<>]*>\\]" tmp)
326 (setq defaction (match-string 0 tmp)
327 tmp (replace-match "" t t tmp)))
328 (if (string-match "\\[[^][]*\\]" tmp)
329 (setq option (match-string 0 tmp)
330 tmp (replace-match "" t t tmp)))
331 (if (string-match "<[^<>]*>" tmp)
332 (setq action (match-string 0 tmp)
333 tmp (replace-match "" t t tmp))))))
335 (defun org-beamer-assoc-not-empty (elt list)
336 (let ((tmp (cdr (assoc elt list))))
337 (and tmp (string-match "\\S-" tmp) tmp)))
340 (defvar org-beamer-mode-map (make-sparse-keymap)
341 "The keymap for `org-beamer-mode'.")
342 (define-key org-beamer-mode-map "\C-c\C-b" 'org-beamer-set-environment-tag)
344 (define-minor-mode org-beamer-mode
345 "Special support for editing Org-mode files made to export to beamer."
346 nil " Bm" nil)
347 (font-lock-add-keywords
348 'org-mode
349 '((":\\(B_[a-z]+\\|BMCOL\\):" 1 'org-beamer-tag prepend))
350 'prepent)
352 (defun org-beamer-place-default-actions-for-lists ()
353 "Find default overlay specifications in items, and move them.
354 The need to be after the begin statement of the environment."
355 (when org-beamer-export-is-beamer-p
356 (let (dovl)
357 (goto-char (point-min))
358 (while (re-search-forward
359 "^[ \t]*\\\\begin{\\(itemize\\|enumerate\\|desctiption\\)}[ \t\n]*\\\\item\\>\\( ?\\(<[^<>\n]*>\\|\\[[^][\n*]\\]\\)\\)?[ \t]*\\S-" nil t)
360 (if (setq dovl (cdr (assoc "BEAMER_dovl"
361 (get-text-property (match-end 0)
362 'org-props))))
363 (save-excursion
364 (goto-char (1+ (match-end 1)))
365 (insert dovl)))))))
367 (defun org-beamer-amend-header ()
368 (when (and org-beamer-export-is-beamer-p
369 org-beamer-header-extra)
370 (goto-char (point-min))
371 (when (re-search-forward "^[ \t]*\\\\begin{document}" nil t)
372 (goto-char (match-beginning 0))
373 (insert org-beamer-header-extra)
374 (or (bolp) (insert "\n")))))
376 (defcustom org-beamer-fragile-re "^[ \t]*\\\\begin{verbatim}"
377 "If this regexp matches in a frame, the frame is marked as fragile."
378 :group 'org-beamer
379 :type 'regexp)
381 (defface org-beamer-tag '((t (:box (:line-width 1 :color grey40))))
382 "The special face for beamer tags."
383 :group 'org-beamer)
386 ;; Functions to initialize and post-process
387 ;; These fuctions will be hooked into various places in the export process
389 (defun org-beamer-initialize-open-trackers ()
390 "Reset variables that track if certain environments are open during export."
391 (setq org-beamer-columns-open nil)
392 (setq org-beamer-column-open nil)
393 (setq org-beamer-inside-frame-at-level nil)
394 (setq org-beamer-export-is-beamer-p nil))
396 (defun org-beamer-after-initial-vars ()
397 "Find special setings for beamer and store them.
398 The effect is that these values will be accessible during export."
399 ;; First verify that we are exporting using the beamer class
400 (setq org-beamer-export-is-beamer-p
401 (string-match "\\\\documentclass\\(\\[[^][]*?\\]\\)?{beamer}"
402 org-export-latex-header))
403 (when org-beamer-export-is-beamer-p
404 ;; Find the frame level
405 (setq org-beamer-frame-level-now
406 (or (and (org-region-active-p)
407 (save-excursion
408 (goto-char (region-beginning))
409 (and (looking-at org-complex-heading-regexp)
410 (org-entry-get nil "BEAMER_FRAME_LEVEL" 'selective))))
411 (save-excursion
412 (save-restriction
413 (widen)
414 (goto-char (point-min))
415 (and (re-search-forward
416 "^#\\+BEAMER_FRAME_LEVEL:[ \t]*\\(.*?\\)[ \t]*$" nil t)
417 (match-string 1))))
418 (plist-get org-export-latex-options-plist :beamer-frame-level)
419 org-beamer-frame-level))
420 ;; Normalize the value so that the functions can trust the value
421 (cond
422 ((not org-beamer-frame-level-now)
423 (setq org-beamer-frame-level-now nil))
424 ((stringp org-beamer-frame-level-now)
425 (setq org-beamer-frame-level-now
426 (string-to-number org-beamer-frame-level-now))))
427 ;; Find the header additons, most likely theme commands
428 (setq org-beamer-header-extra
429 (or (and (org-region-active-p)
430 (save-excursion
431 (goto-char (region-beginning))
432 (and (looking-at org-complex-heading-regexp)
433 (org-entry-get nil "BEAMER_HEADER_EXTRA"
434 'selective))))
435 (save-excursion
436 (save-restriction
437 (widen)
438 (let ((txt ""))
439 (goto-char (point-min))
440 (while (re-search-forward
441 "^#\\+BEAMER_HEADER_EXTRA:[ \t]*\\(.*?\\)[ \t]*$"
442 nil t)
443 (setq txt (concat txt "\n" (match-string 1))))
444 (if (> (length txt) 0) (substring txt 1)))))
445 (plist-get org-export-latex-options-plist
446 :beamer-header-extra)))
447 (let ((inhibit-read-only t)
448 (case-fold-search nil)
449 props)
450 (org-unmodified
451 (remove-text-properties (point-min) (point-max) '(org-props nil))
452 (org-map-entries
453 '(progn
454 (setq props (org-entry-properties nil 'standard))
455 (if (and (not (assoc "BEAMER_env" props))
456 (looking-at ".*?:B_\\(note\\(NH\\)?\\):"))
457 (push (cons "BEAMER_env" (match-string 1)) props))
458 (put-text-property (point-at-bol) (point-at-eol) 'org-props props)))
459 (setq org-export-latex-options-plist
460 (plist-put org-export-latex-options-plist :tags nil))))))
462 (defun org-beamer-auto-fragile-frames ()
463 "Mark any frames containing verbatim environments as fragile.
464 This funcion will run in the final LaTeX document."
465 (when org-beamer-export-is-beamer-p
466 (let (opts)
467 (goto-char (point-min))
468 ;; Find something that might be fragile
469 (while (re-search-forward org-beamer-fragile-re nil t)
470 (save-excursion
471 ;; Are we inside a frame here?
472 (when (and (re-search-backward "^[ \t]*\\\\\\(begin\\|end\\){frame}"
473 nil t)
474 (equal (match-string 1) "begin"))
475 ;; yes, inside a frame, make sure "fragile" is one of the options
476 (goto-char (match-end 0))
477 (if (not (looking-at "\\[.*?\\]"))
478 (insert "[fragile]")
479 (setq opts (substring (match-string 0) 1 -1))
480 (delete-region (match-beginning 0) (match-end 0))
481 (setq opts (org-split-string opts ","))
482 (add-to-list 'opts "fragile")
483 (insert "[" (mapconcat 'identity opts ",") "]"))))))))
485 (defun org-beamer-fix-toc ()
486 "Fix the table of contents by removing the vspace line."
487 (when org-beamer-export-is-beamer-p
488 (save-excursion
489 (goto-char (point-min))
490 (when (re-search-forward "\\\\setcounter{tocdepth.*\n\\\\tableofcontents.*\n\\(\\\\vspace\\*.*\\)" nil t)
491 (delete-region (match-beginning 1) (match-end 1))))))
493 (defun org-beamer-property-changed (property value)
494 "Track the BEAMER_env property with tags."
495 (cond
496 ((equal property "BEAMER_env")
497 (save-excursion
498 (org-back-to-heading t)
499 (let ((tags (org-get-tags)))
500 (setq tags (delq nil (mapcar (lambda (x)
501 (if (string-match "^B_" x) nil x))
502 tags)))
503 (org-set-tags-to tags))
504 (when (and value (stringp value) (string-match "\\S-" value))
505 (org-toggle-tag (concat "B_" value) 'on))))
506 ((equal property "BEAMER_col")
507 (org-toggle-tag "BMCOL" (if (and value (string-match "\\S-" value))
508 'on 'off)))))
510 (defun org-beamer-select-beamer-code ()
511 "Take code marked for BEAMER and turn it into marked for LaTeX."
512 (when org-beamer-export-is-beamer-p
513 (goto-char (point-min))
514 (while (re-search-forward
515 "^\\([ \]*#\\+\\(begin_\\|end_\\)?\\)\\(beamer\\)\\>" nil t)
516 (replace-match "\\1latex"))))
518 ;; OK, hook all these functions into appropriate places
519 (add-hook 'org-export-first-hook
520 'org-beamer-initialize-open-trackers)
521 (add-hook 'org-property-changed-functions
522 'org-beamer-property-changed)
523 (add-hook 'org-export-latex-after-initial-vars-hook
524 'org-beamer-after-initial-vars)
525 (add-hook 'org-export-latex-final-hook
526 'org-beamer-place-default-actions-for-lists)
527 (add-hook 'org-export-latex-final-hook
528 'org-beamer-auto-fragile-frames)
529 (add-hook 'org-export-latex-final-hook
530 'org-beamer-fix-toc)
531 (add-hook 'org-export-latex-final-hook
532 'org-beamer-amend-header)
533 (add-hook 'org-export-preprocess-before-selecting-backend-code-hook
534 'org-beamer-select-beamer-code)
536 (defun org-beamer-settings-template (kind)
537 "Insert a settings template, to make sure users do this right."
538 (interactive (progn
539 (message "Current [s]ubtree or [g]lobal?")
540 (if (equal (read-char-exclusive) ?g)
541 (list 'global)
542 (list 'subtree))))
543 (if (eq kind 'subtree)
544 (progn
545 (org-back-to-heading t)
546 (org-reveal)
547 (org-entry-put nil "LaTeX_CLASS" "beamer")
548 (org-entry-put nil "LaTeX_CLASS_OPTIONS" "[presentation]")
549 (org-entry-put nil "EXPORT_FILE_NAME" "presentation.pdf")
550 (org-entry-put nil "BEAMER_FRAME_LEVEL" (number-to-string
551 org-beamer-frame-level))
552 (org-entry-put nil "BEAMER_HEADER_EXTRA" org-beamer-themes)
553 (org-entry-put nil "COLUMNS" org-beamer-column-view-format)
554 (org-entry-put nil "BEAMER_col_ALL" "0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 :ETC"))
555 (insert "#+LaTeX_CLASS: beamer\n")
556 (insert "#+LaTeX_CLASS_OPTIONS: [presentation]\n")
557 (insert (format "#+BEAMER_FRAME_LEVEL: %d\n" org-beamer-frame-level) "\n")
558 (insert "#+BEAMER_HEADER_EXTRA: " org-beamer-themes "\n")
559 (insert "#+COLUMNS: " org-beamer-column-view-format "\n")
560 (insert "#+PROPERTY: BEAMER_col_ALL 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 :ETC\n")))
563 (defun org-beamer-allowed-property-values (property)
564 "Supply allowed values for BEAMER properties."
565 (cond
566 ((and (equal property "BEAMER_env")
567 (not (org-entry-get nil (concat property "_ALL") 'inherit)))
568 ;; If no allowed values for BEAMER_env have been defined,
569 ;; supply all defined environments
570 (mapcar 'car (append org-beamer-environments-extra
571 org-beamer-environments-default)))
572 ((and (equal property "BEAMER_col")
573 (not (org-entry-get nil (concat property "_ALL") 'inherit)))
574 ;; If no allowed values for BEAMER_col have been defined,
575 ;; supply some
576 '("0.1" "0.2" "0.3" "0.4" "0.5" "0.6" "0.7" "0.8" "0.9" "" ":ETC"))
577 (t nil)))
579 (add-hook 'org-property-allowed-value-functions
580 'org-beamer-allowed-property-values)
582 (provide 'org-beamer)
584 ;; arch-tag: 68bac91a-a946-43a3-8173-a9269306f67c
586 ;;; org-beamer.el ends here