Simplify setting the ox-export local buffer variables

This commit is contained in:
Gerard Vermeulen 2022-02-22 07:58:33 +01:00
parent a3f825e61b
commit 02bf1bda54

View File

@ -1,6 +1,6 @@
#+title: Emacs setup for use with LaTeX, Org, and Python #+title: Emacs setup for use with LaTeX, Org, and Python
#+author: Gerard Vermeulen #+author: Gerard Vermeulen
#+latex_class: article-1+2+3 #+latex_class: article-local
#+latex_class_options: [11pt,a4paper,english,svgnames,tables] #+latex_class_options: [11pt,a4paper,english,svgnames,tables]
#+setupfile: "setup-include.org" #+setupfile: "setup-include.org"
#+include: "setup-include.org" #+include: "setup-include.org"
@ -2015,18 +2015,22 @@ Listing [[lst:use-latex-header-1]], [[lst:use-latex-header-2]], [[lst:use-latex-
:CUSTOM_ID: sec:advanced-latex-export-settings :CUSTOM_ID: sec:advanced-latex-export-settings
:END: :END:
[[https://emacs.stackexchange.com/questions/47347/customizing-org-latex-title-command-to-edit-title-page][How to customize =org-latex-title-command= only in this buffer]] Listing [[lst:ox-latex-emacs-lisp-setup]] initializes the buffer local variables
=org-latex-classes=, =org-latex-title-command=, =org-latex-toc-command=, and
=org-latex-subtitle-format=. Listing [[lst/title-page]] is a template to initialize
=org-latex-title-command=. Type {{{kbd(M-x org-latex-classes)}}}, {{{kbd(M-x
org-latex-subtitle-format)}}}, {{{kbd(M-x org-latex-title-command)}}}, and
{{{kbd(M-x org-latex-toc-command)}}} to read how those variables control
exporting from Org-mode to LaTeX.
#+caption[Define =my-ox-latex-export-buffer-local-variables=]: #+caption[Define buffer local =ox-latex= variables]:
#+caption: Define =my-ox-latex-export-buffer-local-variables=. #+caption: Define buffer local =-ox-latex= variables.
#+name: lst:emacs-lisp-setup-defun #+header: :var title-page=lst/title-page
#+name: lst:ox-latex-emacs-lisp-setup
#+begin_src emacs-lisp :results silent #+begin_src emacs-lisp :results silent
(defun my-ox-latex-export-buffer-local-variables (title-page)
(with-eval-after-load 'ox
(make-variable-buffer-local 'org-export-before-parsing-hook)
(cl-pushnew #'org-latex-header-blocks-filter
org-export-before-parsing-hook))
(when (require 'ox-latex nil 'noerror) (when (require 'ox-latex nil 'noerror)
;; https://emacs.stackexchange.com/questions/47347/
;; customizing-org-latex-title-command-to-edit-title-page
(make-variable-buffer-local 'org-latex-classes) (make-variable-buffer-local 'org-latex-classes)
(cl-pushnew '("article-local" (cl-pushnew '("article-local"
"\\documentclass[11pt]{article} "\\documentclass[11pt]{article}
@ -2054,20 +2058,7 @@ Listing [[lst:use-latex-header-1]], [[lst:use-latex-header-2]], [[lst:use-latex-
"") "\n")) "") "\n"))
(make-variable-buffer-local 'org-latex-subtitle-format) (make-variable-buffer-local 'org-latex-subtitle-format)
(setq org-latex-subtitle-format ""))) (setq org-latex-subtitle-format ""))
#+end_src
Listing [[lst:emacs-lisp-setup-call]] initializes the buffer local variables
=org-export-before-parsing-hook=, =org-latex-classes=,
=org-latex-title-command=, =org-latex-toc-command=, and
=org-latex-subtitle-format=.
#+caption[Call =my-ox-latex-export-local-variables=]:
#+caption: Use the setup macro for =ox-latex=.
#+name: lst:emacs-lisp-setup-call
#+header: :var title-page=lst/title-page
#+begin_src emacs-lisp :tangle no
(my-ox-latex-export-buffer-local-variables title-page)
#+end_src #+end_src
#+caption[Show a title-page example for =org-latex-title-command=]: #+caption[Show a title-page example for =org-latex-title-command=]: