diff --git a/lisp/ox.el b/lisp/ox.el index 24e8b5039..e1e79c8f7 100644 --- a/lisp/ox.el +++ b/lisp/ox.el @@ -1658,14 +1658,13 @@ Assume buffer is in Org mode. Narrowing, if any, is ignored." (regexp (format "^[ \t]*#\\+%s:" (regexp-opt (nconc (delq nil (mapcar 'cadr options)) org-export-special-keywords)))) - (find-opt + (find-properties (lambda (keyword) - ;; Return property name associated to KEYWORD. - (catch 'exit - (mapc (lambda (option) - (when (equal (nth 1 option) keyword) - (throw 'exit (car option)))) - options)))) + ;; Return all properties associated to KEYWORD. + (let (properties) + (dolist (option options properties) + (when (equal (nth 1 option) keyword) + (push (car option) properties)))))) (get-options (lambda (&optional files plist) ;; Recursively read keywords in buffer. FILES is a list @@ -1705,47 +1704,45 @@ Assume buffer is in Org mode. Narrowing, if any, is ignored." (plist-get plist :filetags))))))) (t ;; Options in `org-export-options-alist'. - (let* ((prop (funcall find-opt key)) - (behaviour (nth 4 (assq prop options)))) - (setq plist - (plist-put - plist prop - ;; Handle value depending on specified - ;; BEHAVIOUR. - (case behaviour - (space - (if (not (plist-get plist prop)) - (org-trim val) - (concat (plist-get plist prop) - " " - (org-trim val)))) - (newline - (org-trim (concat (plist-get plist prop) - "\n" - (org-trim val)))) - (split `(,@(plist-get plist prop) - ,@(org-split-string val))) - ('t val) - (otherwise - (if (not (plist-member plist prop)) val - (plist-get plist prop))))))))))))) + (dolist (property (funcall find-properties key)) + (let ((behaviour (nth 4 (assq property options)))) + (setq plist + (plist-put + plist property + ;; Handle value depending on specified + ;; BEHAVIOUR. + (case behaviour + (space + (if (not (plist-get plist property)) + (org-trim val) + (concat (plist-get plist property) + " " + (org-trim val)))) + (newline + (org-trim + (concat (plist-get plist property) + "\n" + (org-trim val)))) + (split `(,@(plist-get plist property) + ,@(org-split-string val))) + ('t val) + (otherwise + (if (not (plist-member plist property)) val + (plist-get plist property)))))))))))))) ;; Return final value. plist)))) ;; Read options in the current buffer. (setq plist (funcall get-options buffer-file-name nil)) - ;; Parse keywords specified in `org-element-document-properties'. - (mapc (lambda (keyword) - ;; Find the property associated to the keyword. - (let* ((prop (funcall find-opt keyword)) - (value (and prop (plist-get plist prop)))) - (when (stringp value) - (setq plist - (plist-put plist prop - (org-element-parse-secondary-string - value (org-element-restriction 'keyword))))))) - org-element-document-properties) - ;; Return value. - plist)) + ;; Parse keywords specified in `org-element-document-properties' + ;; and return PLIST. + (dolist (keyword org-element-document-properties plist) + (dolist (property (funcall find-properties keyword)) + (let ((value (plist-get plist property))) + (when (stringp value) + (setq plist + (plist-put plist property + (org-element-parse-secondary-string + value (org-element-restriction 'keyword)))))))))) (defun org-export--get-buffer-attributes () "Return properties related to buffer attributes, as a plist." diff --git a/testing/lisp/test-ox.el b/testing/lisp/test-ox.el index 0ba20f270..abe980c62 100644 --- a/testing/lisp/test-ox.el +++ b/testing/lisp/test-ox.el @@ -183,7 +183,15 @@ already filled in `info'." org-test-dir) (org-export--get-inbuffer-options)) '(:description "l1\nl2\nl3":language "fr" :select-tags ("a" "b" "c") - :title ("a b c"))))) + :title ("a b c")))) + ;; More than one property can refer to the same buffer keyword. + (should + (equal '(:k2 "value" :k1 "value") + (let ((backend (org-export-create-backend + :options '((:k1 "KEYWORD") + (:k2 "KEYWORD"))))) + (org-test-with-temp-text "#+KEYWORD: value" + (org-export--get-inbuffer-options backend)))))) (ert-deftest test-org-export/get-subtree-options () "Test setting options from headline's properties."