Merge branch 'maint'

This commit is contained in:
Nicolas Goaziou 2015-09-09 22:51:31 +02:00
commit a34a334582
2 changed files with 67 additions and 36 deletions

View File

@ -1339,21 +1339,24 @@ inferior to file-local settings."
Optional argument BACKEND is an export back-end, as returned by,
e.g., `org-export-create-backend'. It specifies which back-end
specific items to read, if any."
(let ((all
(mapcar
(lambda (o) (cons (nth 2 o) (car o)))
;; Priority is given to back-end specific options.
(append (and backend (org-export-get-all-options backend))
org-export-options-alist)))
(start)
plist)
(while (string-match "\\(.+?\\):\\((.*?)\\|\\S-*\\)[ \t\n]*" options start)
(setq start (match-end 0))
(let ((property (cdr (assoc-string (match-string 1 options) all t))))
(when property
(setq plist
(plist-put plist property (read (match-string 2 options)))))))
plist))
(let ((line
(let ((s 0) alist)
(while (string-match "\\(.+?\\):\\((.*?)\\|\\S-*\\)[ \t]*" options s)
(setq s (match-end 0))
(push (cons (match-string 1 options)
(read (match-string 2 options)))
alist))
alist))
;; Priority is given to back-end specific options.
(all (append (and backend (org-export-get-all-options backend))
org-export-options-alist))
(plist))
(when line
(dolist (entry all plist)
(let ((item (nth 2 entry)))
(when item
(let ((v (assoc-string item line t)))
(when v (setq plist (plist-put plist (car entry) (cdr v)))))))))))
(defun org-export--get-subtree-options (&optional backend)
"Get export options in subtree at point.

View File

@ -104,34 +104,62 @@ variable, and communication channel under `info'."
(ert-deftest test-org-export/parse-option-keyword ()
"Test reading all standard #+OPTIONS: items."
(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 title:t")
'(:headline-levels
1 :section-numbers t :preserve-breaks t :time-stamp-file t
:with-archived-trees t :with-author t :with-creator t :with-drawers t
:with-email t :with-emphasize t :with-entities t :with-fixed-width t
:with-footnotes t :with-priority t :with-special-strings t
:with-sub-superscript t :with-toc t :with-tables t :with-tags t
:with-tasks t :with-timestamps t :with-todo-keywords t
:with-inlinetasks nil :with-statistics-cookies t :with-title t)))
(let ((options
(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 title:t")))
(and (eq (plist-get options :headline-levels) 1)
(eq (plist-get options :section-numbers) t)
(eq (plist-get options :preserve-breaks) t)
(eq (plist-get options :time-stamp-file) t)
(eq (plist-get options :with-archived-trees) t)
(eq (plist-get options :with-author) t)
(eq (plist-get options :with-drawers) t)
(eq (plist-get options :with-email) t)
(eq (plist-get options :with-emphasize) t)
(eq (plist-get options :with-entities) t)
(eq (plist-get options :with-fixed-width) t)
(eq (plist-get options :with-footnotes) t)
(eq (plist-get options :with-priority) t)
(eq (plist-get options :with-special-strings) t)
(eq (plist-get options :with-sub-superscript) t)
(eq (plist-get options :with-toc) t)
(eq (plist-get options :with-tables) t)
(eq (plist-get options :with-tags) t)
(eq (plist-get options :with-tasks) t)
(eq (plist-get options :with-timestamps) t)
(eq (plist-get options :with-todo-keywords) t)
(eq (plist-get options :with-inlinetasks) nil)
(eq (plist-get options :with-statistics-cookies) t)
(eq (plist-get options :with-title) t))))
;; Test some special values.
(should
(equal
(org-export--parse-option-keyword
"arch:headline d:(\"TEST\") ^:{} toc:1 tags:not-in-toc tasks:todo num:2 <:active")
'(:with-archived-trees
headline :with-drawers ("TEST") :with-sub-superscript {} :with-toc 1
:with-tags not-in-toc :with-tasks todo :section-numbers 2
:with-timestamps active)))
(let ((options
(org-export--parse-option-keyword
"arch:headline d:(\"TEST\") ^:{} toc:1 tags:not-in-toc tasks:todo \
num:2 <:active")))
(and (eq (plist-get options :with-archived-trees) 'headline)
(eq (plist-get options :with-sub-superscript) '{})
(eq (plist-get options :with-toc) 1)
(eq (plist-get options :with-tags) 'not-in-toc)
(eq (plist-get options :with-tasks) 'todo)
(eq (plist-get options :section-numbers) 2)
(eq (plist-get options :with-timestamps) 'active)
(equal (plist-get options :with-drawers) '("TEST")))))
;; Test back-end specific values.
(should
(equal
(org-export--parse-option-keyword
"opt:t" (org-export-create-backend :options '((:option nil "opt"))))
'(:option t))))
'(:option t)))
;; More than one property can refer to the same option item.
(should
(equal '(:opt1 t :opt2 t)
(org-export--parse-option-keyword
"opt:t"
(org-export-create-backend
:options '((:opt1 nil "opt") (:opt2 nil "opt")))))))
(ert-deftest test-org-export/get-inbuffer-options ()
"Test reading all standard export keywords."