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