]> code.delx.au - gnu-emacs/blobdiff - lisp/org/org-beamer.el
Sync Org 7.9.2 from the commit tagged "release_7.9.2" in Org's Git repo.
[gnu-emacs] / lisp / org / org-beamer.el
index cccbcb27824b3feb2b8dc97b898399c2afb682ea..b5f3013e0006c2347e6aaad05ac542e7ea0aec14 100644 (file)
@@ -1,8 +1,7 @@
 ;;; org-beamer.el --- Beamer-specific LaTeX export for org-mode
 ;;
-;; Copyright (C) 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
+;; Copyright (C) 2007-2012  Free Software Foundation, Inc.
 ;;
-;; Version: 7.4
 ;; Author: Carsten Dominik <carsten.dominik AT gmail DOT com>
 ;; Maintainer: Carsten Dominik <carsten.dominik AT gmail DOT com>
 ;; Keywords: org, wp, tex
@@ -44,6 +43,7 @@
 (defcustom org-beamer-use-parts nil
   ""
   :group 'org-beamer
+  :version "24.1"
   :type 'boolean)
 
 (defcustom org-beamer-frame-level 1
@@ -53,6 +53,7 @@ Setting this to 2 will allow sections, 3 will allow subsections as well.
 You can set this to 4 as well, if you at the same time set
 `org-beamer-use-parts' to make the top levels `\part'."
   :group 'org-beamer
+  :version "24.1"
   :type '(choice
          (const :tag "Frames need a BEAMER_env property" nil)
          (integer :tag "Specific level makes a frame")))
@@ -61,12 +62,14 @@ You can set this to 4 as well, if you at the same time set
   "Default options string to use for frames, should contains the [brackets].
 And example for this is \"[allowframebreaks]\"."
   :group 'org-beamer
+  :version "24.1"
   :type '(string :tag "[options]"))
 
 (defcustom org-beamer-column-view-format
   "%45ITEM %10BEAMER_env(Env) %10BEAMER_envargs(Env Args) %4BEAMER_col(Col) %8BEAMER_extra(Extra)"
   "Default column view format that should be used to fill the template."
   :group 'org-beamer
+  :version "24.1"
   :type '(choice
          (const  :tag "Do not insert Beamer column view format" nil)
          (string :tag "Beamer column view format")))
@@ -77,13 +80,14 @@ And example for this is \"[allowframebreaks]\"."
 When a beamer template is filled, this will be the default for
 BEAMER_HEADER_EXTRA, which will be inserted just before \\begin{document}."
   :group 'org-beamer
+  :version "24.1"
   :type '(choice
          (const  :tag "Do not insert Beamer themes" nil)
          (string :tag "Beamer themes")))
 
 (defconst org-beamer-column-widths
   "0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 0.0 :ETC"
-"The column widths that should be installed as allowed property values.")
+  "The column widths that should be installed as allowed property values.")
 
 (defconst org-beamer-transitions
   "\transblindsvertical \transblindshorizontal \transboxin \transboxout \transdissolve \transduration \transglitter \transsplithorizontalin \transsplithorizontalout \transsplitverticalin \transsplitverticalout \transwipe :ETC"
@@ -103,6 +107,7 @@ These are just a completion help.")
     ("theorem"        "t" "\\begin{theorem}%a%U%x"             "\\end{theorem}")
     ("definition"     "d" "\\begin{definition}%a%U%x"          "\\end{definition}")
     ("example"        "e" "\\begin{example}%a%U%x"             "\\end{example}")
+    ("exampleblock"   "E" "\\begin{exampleblock}%a{%h}%x"      "\\end{exampleblock}")
     ("proof"          "p" "\\begin{proof}%a%U%x"               "\\end{proof}")
     ("beamercolorbox" "o" "\\begin{beamercolorbox}%o{%h}%x"    "\\end{beamercolorbox}")
     ("normal"         "h" "%h" "") ; Emit the heading as normal text
@@ -113,7 +118,7 @@ These are just a completion help.")
 These are the defaults - for user definitions, see
 `org-beamer-environments-extra'.
 \"normal\" is a special fake environment, which emit the heading as
-normal text. It is needed when an environment should be surrounded
+normal text.  It is needed when an environment should be surrounded
 by normal text.  Since beamer export converts nodes into environments,
 you need to have a node to end the environment.
 For example
@@ -139,9 +144,11 @@ open    The opening template for the environment, with the following escapes
         %h   the headline text
         %H   if there is headline text, that text in {} braces
         %U   if there is headline text, that text in [] brackets
+        %x   the content of the BEAMER_extra property
 close   The closing string of the environment."
 
   :group 'org-beamer
+  :version "24.1"
   :type '(repeat
          (list
           (string :tag "Environment")
@@ -149,6 +156,12 @@ close   The closing string of the environment."
           (string :tag "Begin")
           (string :tag "End"))))
 
+(defcustom org-beamer-inherited-properties nil
+  "Properties that should be inherited during beamer export."
+  :group 'org-beamer
+  :type '(repeat
+         (string :tag "Property")))
+
 (defvar org-beamer-frame-level-now nil)
 (defvar org-beamer-header-extra nil)
 (defvar org-beamer-export-is-beamer-p nil)
@@ -235,7 +248,7 @@ in org-export-latex-classes."
         (envs (append org-beamer-environments-extra
                       org-beamer-environments-default))
         (props (org-get-text-property-any 0 'org-props text))
-        (in "") (out "") option action defaction environment extra
+        (in "") (out "") org-beamer-option org-beamer-action org-beamer-defaction org-beamer-environment org-beamer-extra
         columns-option column-option
         env have-text ass tmp)
     (if (= frame-level 0) (setq frame-level nil))
@@ -266,10 +279,10 @@ in org-export-latex-classes."
 
       (setq in (org-fill-template
                "\\begin{frame}%a%A%o%T%S%x"
-               (list (cons "a" (or action ""))
-                     (cons "A" (or defaction ""))
-                     (cons "o" (or option org-beamer-frame-default-options ""))
-                     (cons "x" (if extra (concat "\n" extra) ""))
+               (list (cons "a" (or org-beamer-action ""))
+                     (cons "A" (or org-beamer-defaction ""))
+                     (cons "o" (or org-beamer-option org-beamer-frame-default-options ""))
+                     (cons "x" (if org-beamer-extra (concat "\n" org-beamer-extra) ""))
                      (cons "h" "%s")
                      (cons "T" (if (string-match "\\S-" text)
                                    "\n\\frametitle{%s}" ""))
@@ -294,10 +307,10 @@ in org-export-latex-classes."
       (setq have-text (string-match "\\S-" text))
       (setq in (org-fill-template
                (nth 2 ass)
-               (list (cons "a" (or action ""))
-                     (cons "A" (or defaction ""))
-                     (cons "o" (or option ""))
-                     (cons "x" (if extra (concat "\n" extra) ""))
+               (list (cons "a" (or org-beamer-action ""))
+                     (cons "A" (or org-beamer-defaction ""))
+                     (cons "o" (or org-beamer-option ""))
+                     (cons "x" (if org-beamer-extra (concat "\n" org-beamer-extra) ""))
                      (cons "h" "%s")
                      (cons "H" (if have-text (concat "{" text "}") ""))
                      (cons "U" (if have-text (concat "[" text "]") ""))))
@@ -321,31 +334,31 @@ in org-export-latex-classes."
       (cons text (cdr (assoc level default))))
      (t nil))))
 
-(defvar extra)
-(defvar option)
-(defvar action)
-(defvar defaction)
-(defvar environment)
+(defvar org-beamer-extra)
+(defvar org-beamer-option)
+(defvar org-beamer-action)
+(defvar org-beamer-defaction)
+(defvar org-beamer-environment)
 (defun org-beamer-get-special (props)
   "Extract an option, action, and default action string from text.
-The variables option, action, defaction, extra are all scoped into
-this function dynamically."
+The variables org-beamer-option, org-beamer-action, org-beamer-defaction,
+org-beamer-extra are all scoped into this function dynamically."
   (let (tmp)
-    (setq environment (org-beamer-assoc-not-empty "BEAMER_env" props))
-    (setq extra (org-beamer-assoc-not-empty "BEAMER_extra" props))
-    (when extra
-      (setq extra (replace-regexp-in-string "\\\\n" "\n" extra)))
+    (setq org-beamer-environment (org-beamer-assoc-not-empty "BEAMER_env" props))
+    (setq org-beamer-extra (org-beamer-assoc-not-empty "BEAMER_extra" props))
+    (when org-beamer-extra
+      (setq org-beamer-extra (replace-regexp-in-string "\\\\n" "\n" org-beamer-extra)))
     (setq tmp (org-beamer-assoc-not-empty "BEAMER_envargs" props))
     (when tmp
       (setq tmp (copy-sequence tmp))
       (if (string-match "\\[<[^][<>]*>\\]" tmp)
-         (setq defaction (match-string 0 tmp)
+         (setq org-beamer-defaction (match-string 0 tmp)
                tmp (replace-match "" t t tmp)))
       (if (string-match "\\[[^][]*\\]" tmp)
-         (setq option (match-string 0 tmp)
+         (setq org-beamer-option (match-string 0 tmp)
                tmp (replace-match "" t t tmp)))
       (if (string-match "<[^<>]*>" tmp)
-         (setq action (match-string 0 tmp)
+         (setq org-beamer-action (match-string 0 tmp)
                tmp (replace-match "" t t tmp))))))
 
 (defun org-beamer-assoc-not-empty (elt list)
@@ -399,9 +412,10 @@ the value will be inserted right after the documentclass statement."
       (insert org-beamer-header-extra)
       (or (bolp) (insert "\n"))))))
 
-(defcustom org-beamer-fragile-re "^[ \t]*\\\\begin{\\(verbatim\\|lstlisting\\)}"
+(defcustom org-beamer-fragile-re "\\\\\\(verb\\|lstinline\\)\\|^[ \t]*\\\\begin{\\(verbatim\\|lstlisting\\|minted\\)}"
   "If this regexp matches in a frame, the frame is marked as fragile."
   :group 'org-beamer
+  :version "24.1"
   :type 'regexp)
 
 (defface org-beamer-tag '((t (:box (:line-width 1 :color grey40))))
@@ -410,7 +424,7 @@ the value will be inserted right after the documentclass statement."
 
 
 ;; Functions to initialize and post-process
-;; These fuctions will be hooked into various places in the export process
+;; These functions will be hooked into various places in the export process
 
 (defun org-beamer-initialize-open-trackers ()
   "Reset variables that track if certain environments are open during export."
@@ -450,7 +464,7 @@ The effect is that these values will be accessible during export."
      ((stringp org-beamer-frame-level-now)
       (setq org-beamer-frame-level-now
            (string-to-number org-beamer-frame-level-now))))
-    ;; Find the header additons, most likely theme commands
+    ;; Find the header additions, most likely theme commands
     (setq org-beamer-header-extra
          (or (and (org-region-active-p)
                   (save-excursion
@@ -481,6 +495,12 @@ The effect is that these values will be accessible during export."
           (if (and (not (assoc "BEAMER_env" props))
                    (looking-at ".*?:B_\\(note\\(NH\\)?\\):"))
               (push (cons "BEAMER_env" (match-string 1)) props))
+          (when (org-bound-and-true-p org-beamer-inherited-properties)
+            (mapc (lambda (p)
+                    (unless (assoc p props)
+                      (let ((v (org-entry-get nil p 'inherit)))
+                        (and v (push (cons p v) props)))))
+                  org-beamer-inherited-properties))
           (put-text-property (point-at-bol) (point-at-eol) 'org-props props)))
        (setq org-export-latex-options-plist
             (plist-put org-export-latex-options-plist :tags nil))))))
@@ -495,7 +515,7 @@ This function will run in the final LaTeX document."
       (while (re-search-forward org-beamer-fragile-re nil t)
        (save-excursion
          ;; Are we inside a frame here?
-         (when (and (re-search-backward "^[ \t]*\\\\\\(begin\\|end\\){frame}"
+         (when (and (re-search-backward "^[ \t]*\\\\\\(begin\\|end\\){frame}\\(<[^>]*>\\)?"
                                         nil t)
                     (equal (match-string 1) "begin"))
            ;; yes, inside a frame, make sure "fragile" is one of the options
@@ -511,16 +531,18 @@ This function will run in the final LaTeX document."
 (defcustom org-beamer-outline-frame-title "Outline"
   "Default title of a frame containing an outline."
   :group 'org-beamer
+  :version "24.1"
   :type '(string :tag "Outline frame title")
-)
+  )
 
 (defcustom org-beamer-outline-frame-options nil
   "Outline frame options appended after \\begin{frame}.
 You might want to put e.g. [allowframebreaks=0.9] here.  Remember to
 include square brackets."
   :group 'org-beamer
+  :version "24.1"
   :type '(string :tag "Outline frame options")
-)
+  )
 
 (defun org-beamer-fix-toc ()
   "Fix the table of contents by removing the vspace line."
@@ -579,7 +601,7 @@ include square brackets."
 (add-hook 'org-export-preprocess-before-selecting-backend-code-hook
          'org-beamer-select-beamer-code)
 
-(defun org-insert-beamer-options-template (kind)
+(defun org-insert-beamer-options-template (&optional kind)
   "Insert a settings template, to make sure users do this right."
   (interactive (progn
                 (message "Current [s]ubtree or [g]lobal?")
@@ -631,5 +653,4 @@ include square brackets."
 
 (provide 'org-beamer)
 
-
 ;;; org-beamer.el ends here