forked from mirrors/org-mode
Export: General mechanism for local settings
Many different people want to set many different variables in a buffer-local way for export. This cannot be done with file variables, because the Org buffer is not current while the exporter is running. Lots of variables can be set with the #+OPTIONS lines, but finding abbreviations goes only so far. Therefore we have now a general mechanism that can be used to bind variables during export operations. a line like: #+BIND: variable value will bind the variable to value. For example, the line >> #+OPTIONS: toc:nil can now equivalently be written as >> #+BIND: org-export-with-toc nil
This commit is contained in:
parent
aa6654c9ce
commit
c1d00fa463
|
@ -8447,6 +8447,7 @@ Insert template with export options, see example below.
|
|||
@cindex #+LANGUAGE
|
||||
@cindex #+TEXT
|
||||
@cindex #+OPTIONS
|
||||
@cindex #+BIND
|
||||
@cindex #+LINK_UP
|
||||
@cindex #+LINK_HOME
|
||||
@cindex #+EXPORT_SELECT_TAGS
|
||||
|
@ -8466,6 +8467,7 @@ Insert template with export options, see example below.
|
|||
#+TEXT: Some descriptive text to be inserted at the beginning.
|
||||
#+TEXT: Several lines may be given.
|
||||
#+OPTIONS: H:2 num:t toc:t \n:nil @@:t ::t |:t ^:t f:t TeX:t ...
|
||||
#+BIND: lisp-var lisp-val, e.g.: org-export-latex-low-levels itemize
|
||||
#+LINK_UP: the ``up'' link of an exported page
|
||||
#+LINK_HOME: the ``home'' link of an exported page
|
||||
#+LATEX_HEADER: extra line(s) for the LaTeX header, like \usepackage@{xyz@}
|
||||
|
@ -10166,7 +10168,8 @@ this file, and (potentially) the corresponding @emph{fast tag selection}
|
|||
keys. The corresponding variable is @code{org-tag-alist}.
|
||||
@item #+TBLFM:
|
||||
This line contains the formulas for the table directly above the line.
|
||||
@item #+TITLE:, #+AUTHOR:, #+EMAIL:, #+LANGUAGE:, #+TEXT:, #+OPTIONS, #+DATE:,
|
||||
@item #+TITLE:, #+AUTHOR:, #+EMAIL:, #+LANGUAGE:, #+TEXT:, #+DATE:,
|
||||
@itemx #+OPTIONS:, #+BIND:
|
||||
@itemx #+DESCRIPTION:, #+KEYWORDS:
|
||||
@itemx #+LATEX_HEADER:, #+STYLE:, #+LINK_UP:, #+LINK_HOME:,
|
||||
@itemx #+EXPORT_SELECT_TAGS:, #+EXPORT_EXCLUDE_TAGS:
|
||||
|
|
|
@ -1,5 +1,22 @@
|
|||
2009-07-06 Carsten Dominik <carsten.dominik@gmail.com>
|
||||
|
||||
* org-macs.el (org-set-local): Make a local variable, do not make
|
||||
the variable buffer-local!
|
||||
|
||||
* org-latex.el (org-export-as-latex): Call `org-install-letbind'.
|
||||
|
||||
* org-html.el (org-export-as-html): Call `org-install-letbind'.
|
||||
|
||||
* org-docbook.el (org-export-as-docbook): Call
|
||||
`org-install-letbind'.
|
||||
|
||||
* org-ascii.el (org-export-as-ascii): Call `org-install-letbind'.
|
||||
|
||||
* org-exp.el (org-infile-export-plist): Read BIND lines.
|
||||
(org-install-letbind): New function.
|
||||
(org-export-as-org, org-export-preprocess-string): Call
|
||||
`org-install-letbind'.
|
||||
|
||||
* org-src.el (org-edit-src-exit): Untabify the example before
|
||||
returning to Org.
|
||||
|
||||
|
|
|
@ -250,6 +250,7 @@ publishing directory."
|
|||
(set-buffer buffer)
|
||||
(erase-buffer)
|
||||
(fundamental-mode)
|
||||
(org-install-letbind)
|
||||
;; create local variables for all options, to make sure all called
|
||||
;; functions get the correct information
|
||||
(mapc (lambda (x)
|
||||
|
|
|
@ -569,6 +569,7 @@ publishing directory."
|
|||
(set-buffer buffer)
|
||||
(let ((inhibit-read-only t)) (erase-buffer))
|
||||
(fundamental-mode)
|
||||
(org-install-letbind)
|
||||
|
||||
(and (fboundp 'set-buffer-file-coding-system)
|
||||
(set-buffer-file-coding-system coding-system-for-write))
|
||||
|
|
|
@ -642,10 +642,10 @@ modified) list.")
|
|||
'("TITLE" "AUTHOR" "DATE" "EMAIL" "TEXT" "OPTIONS" "LANGUAGE"
|
||||
"LINK_UP" "LINK_HOME" "SETUPFILE" "STYLE" "LATEX_HEADER"
|
||||
"EXPORT_SELECT_TAGS" "EXPORT_EXCLUDE_TAGS"
|
||||
"KEYWORDS" "DESCRIPTION" "MACRO")
|
||||
"KEYWORDS" "DESCRIPTION" "MACRO" "BIND")
|
||||
(mapcar 'car org-export-inbuffer-options-extra))))
|
||||
p key val text options a pr style
|
||||
latex-header macros
|
||||
latex-header macros letbind
|
||||
ext-setup-or-nil setup-contents (start 0))
|
||||
(while (or (and ext-setup-or-nil
|
||||
(string-match re ext-setup-or-nil start)
|
||||
|
@ -674,6 +674,8 @@ modified) list.")
|
|||
(setq text (if text (concat text "\n" val) val)))
|
||||
((string-equal key "OPTIONS")
|
||||
(setq options (concat val " " options)))
|
||||
((string-equal key "BIND")
|
||||
(push (read (concat "(" val ")")) letbind))
|
||||
((string-equal key "LINK_UP")
|
||||
(setq p (plist-put p :link-up val)))
|
||||
((string-equal key "LINK_HOME")
|
||||
|
@ -697,6 +699,7 @@ modified) list.")
|
|||
"\n" setup-contents "\n"
|
||||
(substring ext-setup-or-nil start)))))))
|
||||
(setq p (plist-put p :text text))
|
||||
(setq p (plist-put p :let-bind letbind))
|
||||
(when style (setq p (plist-put p :style-extra style)))
|
||||
(when latex-header
|
||||
(setq p (plist-put p :latex-header-extra (substring latex-header 1))))
|
||||
|
@ -725,6 +728,12 @@ modified) list.")
|
|||
(match-string 2 val)))))
|
||||
p))))
|
||||
|
||||
(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))))))
|
||||
|
||||
(defun org-export-add-options-to-plist (p options)
|
||||
"Parse an OPTIONS line and set values in the property list P."
|
||||
(let (o)
|
||||
|
@ -1216,6 +1225,7 @@ on this string to produce the exported version."
|
|||
|
||||
(let ((org-inhibit-startup t)) (org-mode))
|
||||
(setq case-fold-search t)
|
||||
(org-install-letbind)
|
||||
|
||||
;; Call the hook
|
||||
(run-hooks 'org-export-preprocess-hook)
|
||||
|
@ -2449,7 +2459,7 @@ command."
|
|||
;;;###autoload
|
||||
(defun org-export-as-org (arg &optional hidden ext-plist
|
||||
to-buffer body-only pub-dir)
|
||||
"Make a copy wiht not-exporting stuff removed.
|
||||
"Make a copy with not-exporting stuff removed.
|
||||
The purpose of this function is to provide a way to export the source
|
||||
Org file of a webpage in Org format, but with sensitive and/or irrelevant
|
||||
stuff removed. This command will remove the following:
|
||||
|
@ -2491,6 +2501,7 @@ directory."
|
|||
(erase-buffer)
|
||||
(insert region)
|
||||
(let ((org-inhibit-startup t)) (org-mode))
|
||||
(org-install-letbind)
|
||||
|
||||
;; Get rid of archived trees
|
||||
(org-export-remove-archived-trees (plist-get opt-plist :archived-trees))
|
||||
|
|
|
@ -694,6 +694,7 @@ PUB-DIR is set, use this as the publishing directory."
|
|||
(set-buffer buffer)
|
||||
(let ((inhibit-read-only t)) (erase-buffer))
|
||||
(fundamental-mode)
|
||||
(org-install-letbind)
|
||||
|
||||
(and (fboundp 'set-buffer-file-coding-system)
|
||||
(set-buffer-file-coding-system coding-system-for-write))
|
||||
|
|
|
@ -575,6 +575,7 @@ when PUB-DIR is set, use this as the publishing directory."
|
|||
|
||||
(set-buffer buffer)
|
||||
(erase-buffer)
|
||||
(org-install-letbind)
|
||||
|
||||
(and (fboundp 'set-buffer-file-coding-system)
|
||||
(set-buffer-file-coding-system coding-system-for-write))
|
||||
|
|
|
@ -187,7 +187,7 @@ we turn off invisibility temporarily. Use this in a `let' form."
|
|||
|
||||
(defsubst org-set-local (var value)
|
||||
"Make VAR local in current buffer and set it to VALUE."
|
||||
(set (make-variable-buffer-local var) value))
|
||||
(set (make-local-variable var) value))
|
||||
|
||||
(defsubst org-mode-p ()
|
||||
"Check if the current buffer is in Org-mode."
|
||||
|
|
|
@ -8727,7 +8727,8 @@ This function can be used in a hook."
|
|||
"BEGIN_CENTER" "END_CENTER"
|
||||
"BEGIN_SRC" "END_SRC"
|
||||
"CATEGORY" "COLUMNS"
|
||||
"CAPTION" "LABEL"))
|
||||
"CAPTION" "LABEL"
|
||||
"BIND"))
|
||||
|
||||
(defcustom org-structure-template-alist
|
||||
'(
|
||||
|
|
Loading…
Reference in New Issue