diff --git a/doc/org.texi b/doc/org.texi index 69725e014..452155612 100644 --- a/doc/org.texi +++ b/doc/org.texi @@ -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: diff --git a/lisp/ChangeLog b/lisp/ChangeLog index cd2ab5cba..25ec54ced 100755 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,22 @@ 2009-07-06 Carsten Dominik + * 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. diff --git a/lisp/org-ascii.el b/lisp/org-ascii.el index e8be487d6..6a59a0680 100644 --- a/lisp/org-ascii.el +++ b/lisp/org-ascii.el @@ -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) diff --git a/lisp/org-docbook.el b/lisp/org-docbook.el index 795531875..d06d9ec70 100644 --- a/lisp/org-docbook.el +++ b/lisp/org-docbook.el @@ -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)) diff --git a/lisp/org-exp.el b/lisp/org-exp.el index f764312b5..44dd0b5b8 100644 --- a/lisp/org-exp.el +++ b/lisp/org-exp.el @@ -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)) diff --git a/lisp/org-html.el b/lisp/org-html.el index ee720655d..db7e0012a 100644 --- a/lisp/org-html.el +++ b/lisp/org-html.el @@ -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)) diff --git a/lisp/org-latex.el b/lisp/org-latex.el index 444433bb2..81612adb4 100644 --- a/lisp/org-latex.el +++ b/lisp/org-latex.el @@ -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)) diff --git a/lisp/org-macs.el b/lisp/org-macs.el index 5466ab6d3..e26436c2d 100644 --- a/lisp/org-macs.el +++ b/lisp/org-macs.el @@ -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." diff --git a/lisp/org.el b/lisp/org.el index a8d9d4fc9..9998c08b6 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -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 '(