Browse Source

Fix bug with #+BIND during LaTeX export

Christopher Suckling writes:

> Thank you, but not quite working yet:
>
> ,----
> | #+BIND: org-export-latex-title-command ""
> `----
>
> now appears to be having the *effect* of setting a global variable.
>
> I load Emacs then visit the below test org file. I then export the file.
>
> I get a \maketitle line.
>
> I then C-c C-c on the #+BIND: line and re-export.
>
> \maketitle is removed.
>
> I then export another org file without the #+BIND: line.
>
> There is no \maketitle, even though there should be.
>
> I add
>
> ,----
> | #+BIND: org-export-latex-title-command "\foobar"
> `----
>
> to the new org file, C-c C-c and export:
>
> \foobar is added to the exported file.
>
> Finally, I re-export the original test org file (without C-c C-c on the
> #+BIND: line):
>
> \foobar is added to the exported file.
>
> However,
>
> ,----
> | C-h v org-export-latex-title-command
> `----
>
> always returns the value "\\maketitle", no matter what the value of the
> #+BIND: line.
>
> Best, Christopher
Carsten Dominik 15 years ago
parent
commit
e1a18bdf27
3 changed files with 10 additions and 5 deletions
  1. 3 0
      lisp/ChangeLog
  2. 4 3
      lisp/org-exp.el
  3. 3 2
      lisp/org-latex.el

+ 3 - 0
lisp/ChangeLog

@@ -1,5 +1,8 @@
 2010-01-04  Carsten Dominik  <carsten.dominik@gmail.com>
 
+	* org-latex.el (org-export-as-latex): Do the first letbind in the
+	right moment.
+
 	* org-agenda.el (org-get-entries-from-diary): Add the new face to
 	these entries.
 

+ 4 - 3
lisp/org-exp.el

@@ -784,9 +784,10 @@ security risks."
 
 (defun org-install-letbind ()
   "Install the values from #+BIND lines as local variables."
-  (let ((letbind (plist-get org-export-opt-plist :let-bind)))
-    (while letbind
-      (org-set-local (caar letbind) (nth 1 (pop letbind))))))
+  (let ((letbind (plist-get org-export-opt-plist :let-bind))
+	pair)
+    (while (setq pair (pop letbind))
+      (org-set-local (car pair) (nth 1 pair)))))
 
 (defun org-export-add-options-to-plist (p options)
   "Parse an OPTIONS line and set values in the property list P."

+ 3 - 2
lisp/org-latex.el

@@ -548,7 +548,6 @@ without even the \begin{document} and \end{document} commands.
 when PUB-DIR is set, use this as the publishing directory."
   (interactive "P")
   (run-hooks 'org-export-first-hook)
-  (org-install-letbind)
 
   ;; Make sure we have a file name when we need it.
   (when (and (not (or to-buffer body-only))
@@ -566,6 +565,8 @@ when PUB-DIR is set, use this as the publishing directory."
 			     '(:org-license-to-kill nil))))
   (org-update-radio-target-regexp)
   (org-export-latex-set-initial-vars ext-plist arg)
+  (setq org-export-opt-plist org-export-latex-options-plist)
+  (org-install-letbind)
   (run-hooks 'org-export-latex-after-initial-vars-hook)
   (let* ((wcf (current-window-configuration))
 	 (opt-plist org-export-latex-options-plist)
@@ -585,7 +586,7 @@ when PUB-DIR is set, use this as the publishing directory."
 			      (org-export-add-subtree-options opt-plist rbeg)
 			    opt-plist)))
 	 ;; Make sure the variable contains the updated values.
-	 (org-export-latex-options-plist opt-plist)
+	 (org-export-latex-options-plist (setq org-export-opt-plist opt-plist))
 	 (title (or (and subtree-p (org-export-get-title-from-subtree))
 		    (plist-get opt-plist :title)
 		    (and (not