Browse Source

Change the insertion location of `org-beamer-header-extra'

Carsten Dominik 15 năm trước cách đây
mục cha
commit
6c8c5c85e4
2 tập tin đã thay đổi với 14 bổ sung3 xóa
  1. 3 0
      lisp/ChangeLog
  2. 11 3
      lisp/org-beamer.el

+ 3 - 0
lisp/ChangeLog

@@ -1,5 +1,8 @@
 2010-01-07  Carsten Dominik  <carsten.dominik@gmail.com>
 
+	* org-beamer.el (org-beamer-amend-header): Change the location
+	where `org-beamer-header-extra' is inserted.
+
 	* org.el (org-compute-latex-and-specials-regexp): Don't do BIND
 	just for computing this regexp.
 

+ 11 - 3
lisp/org-beamer.el

@@ -370,13 +370,21 @@ The need to be after the begin statement of the environment."
 	      (insert dovl)))))))
 
 (defun org-beamer-amend-header ()
+  "Add `org-beamer-header-extra' to the LaTeX herder.
+If the file contains the string BEAMER-HEADER-EXTRA-HERE on a line
+by itself, it will be replaced with `org-beamer-header-extra'.  If not,
+the value will be inserted right after the documentclass statement."
   (when (and org-beamer-export-is-beamer-p
 	     org-beamer-header-extra)
     (goto-char (point-min))
-    (when (re-search-forward "^[ \t]*\\\\begin{document}" nil t)
-      (goto-char (match-beginning 0))
+    (cond
+     ((re-search-forward "^[ \t]*BEAMER-HEADER-EXTRA-HERE[ \t]*$" nil t)
+      (replace-match org-beamer-header-extra t t)
+      (or (bolp) (insert "\n")))
+     ((re-search-forward "^[ \t]*\\\\documentclass\\>" nil t)
+      (beginning-of-line 2)
       (insert org-beamer-header-extra)
-      (or (bolp) (insert "\n")))))
+      (or (bolp) (insert "\n"))))))
 
 (defcustom org-beamer-fragile-re "^[ \t]*\\\\begin{verbatim}"
   "If this regexp matches in a frame, the frame is marked as fragile."