From df3934522fc922d4c1b1a88c4cfa9a6d06370720 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Fri, 21 Jun 2013 20:49:05 +0200 Subject: [PATCH] ox: Change OPTIONS syntax from key:value to :key value * lisp/ox.el (org-export--parse-option-keyword): Change OPTIONS syntax from key:value to :key value. Still recognize old syntax for compatibility. (org-export-insert-default-template): Use new syntax. * testing/lisp/test-ox.el: Update tests. --- lisp/ox.el | 26 +++++++++++++++++--------- testing/lisp/test-ox.el | 24 ++++++++++++------------ 2 files changed, 29 insertions(+), 21 deletions(-) diff --git a/lisp/ox.el b/lisp/ox.el index e49de22..8a29908 100644 --- a/lisp/ox.el +++ b/lisp/ox.el @@ -1524,20 +1524,29 @@ specific items to read, if any." (append (and backend (org-export-backend-options backend)) org-export-options-alist)) plist) - (dolist (option all) + (dolist (option all plist) (let ((property (car option)) (item (nth 2 option))) (when (and item (not (plist-member plist property)) - (string-match (concat "\\(\\`\\|[ \t]\\)" - (regexp-quote item) - ":\\(([^)\n]+)\\|[^ \t\n\r;,.]*\\)") - options)) + (let ((item (regexp-quote item))) + (or (string-match + (concat "\\(?:\\`\\|[ \t]\\):" + item + "[ \t]+\\(([^)\n]+)\\|[^ \t\n\r;,.]*\\)") + options) + ;; Compatibility code for deprecated + ;; item:value syntax. It can be removed in + ;; Org 9.0+. + (string-match + (concat "\\(?:\\`\\|[ \t]\\)" + item + ":\\(([^)\n]+)\\|[^ \t\n\r;,.]*\\)") + options)))) (setq plist (plist-put plist property (car (read-from-string - (match-string 2 options)))))))) - plist)) + (match-string 1 options)))))))))) (defun org-export--get-subtree-options (&optional backend) "Get export options in subtree at point. @@ -3171,8 +3180,7 @@ locally for the subtree through node properties." (when options (let ((items (mapcar - (lambda (opt) - (format "%s:%s" (car opt) (format "%s" (cdr opt)))) + (lambda (opt) (format ":%s %s" (car opt) (cdr opt))) (sort options (lambda (k1 k2) (string< (car k1) (car k2))))))) (if subtreep (org-entry-put diff --git a/testing/lisp/test-ox.el b/testing/lisp/test-ox.el index cbae08a..1a9c241 100644 --- a/testing/lisp/test-ox.el +++ b/testing/lisp/test-ox.el @@ -120,9 +120,9 @@ already filled in `info'." (should (equal (org-export--parse-option-keyword - "H:1 num:t \\n:t timestamp:t arch:t author:t creator:t d:t email:t - *:t e:t ::t f:t pri:t -:t ^:t toc:t |:t tags:t tasks:t <:t todo:t inline:nil - stat:t") + ":H 1 :num t :\\n t :timestamp t :arch t :author t :creator t :d t :email t + :* t :e t :: t :f t :pri t :- t :^ t :toc t :| t :tags t :tasks t :< t :todo t + :inline nil :stat t") '(:headline-levels 1 :preserve-breaks t :section-numbers t :time-stamp-file t :with-archived-trees t :with-author t :with-creator t :with-drawers t @@ -135,13 +135,13 @@ already filled in `info'." (should (equal (org-export--parse-option-keyword - "arch:headline creator:comment d:(\"TEST\") - ^:{} toc:1 tags:not-in-toc tasks:todo num:2 <:active") - '( :section-numbers - 2 - :with-archived-trees headline :with-creator comment - :with-drawers ("TEST") :with-sub-superscript {} :with-toc 1 - :with-tags not-in-toc :with-tasks todo :with-timestamps active)))) + ":arch headline :creator comment :d (\"TEST\") :^ {} :toc 1 + :tags not-in-toc :tasks todo :num 2 :< active") + '(:section-numbers + 2 + :with-archived-trees headline :with-creator comment + :with-drawers ("TEST") :with-sub-superscript {} :with-toc 1 + :with-tags not-in-toc :with-tasks todo :with-timestamps active)))) (ert-deftest test-org-export/get-inbuffer-options () "Test reading all standard export keywords." @@ -208,10 +208,10 @@ Paragraph" :title '("subtree-title") ;; EXPORT_OPTIONS. - (org-test-with-temp-text "#+OPTIONS: H:1 + (org-test-with-temp-text "#+OPTIONS: :H 1 * Headline :PROPERTIES: - :EXPORT_OPTIONS: H:2 + :EXPORT_OPTIONS: :H 2 :END: Paragraph" (forward-line) -- 1.8.3.1