From 40ef7af622cb461527555538965b7a6a023e76d2 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Sun, 1 Mar 2015 17:03:02 +0100 Subject: [PATCH] org-element: Elements can accept multiple secondary strings * lisp/org-element.el (org-element-secondary-value-alist): Turn secondary properties into a list. (org-element-secondary-p, org-element-map): Apply changes to variable above. --- lisp/org-element.el | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/lisp/org-element.el b/lisp/org-element.el index 4ef76a286..711817c96 100644 --- a/lisp/org-element.el +++ b/lisp/org-element.el @@ -395,10 +395,10 @@ This alist also applies to secondary string. For example, an still has an entry since one of its properties (`:title') does.") (defconst org-element-secondary-value-alist - '((headline . :title) - (inlinetask . :title) - (item . :tag)) - "Alist between element types and location of secondary value.") + '((headline :title) + (inlinetask :title) + (item :tag)) + "Alist between element types and locations of secondary values.") (defconst org-element--pair-square-table (let ((table (make-syntax-table))) @@ -473,14 +473,15 @@ Return modified element." (t (nconc element contents)))) (defun org-element-secondary-p (object) - "Non-nil when OBJECT belongs to a secondary string. + "Non-nil when OBJECT directly belongs to a secondary string. Return value is the property name, as a keyword, or nil." (let* ((parent (org-element-property :parent object)) - (property (cdr (assq (org-element-type parent) - org-element-secondary-value-alist)))) - (and property - (memq object (org-element-property property parent)) - property))) + (properties (cdr (assq (org-element-type parent) + org-element-secondary-value-alist)))) + (catch 'exit + (dolist (p properties) + (and (memq object (org-element-property p parent)) + (throw 'exit p)))))) (defsubst org-element-adopt-elements (parent &rest children) "Append elements to the contents of another element. @@ -598,7 +599,7 @@ is cleared and contents are removed in the process." ;; Most of them accepts no argument. Though, exceptions exist. Hence ;; every element containing a secondary string (see ;; `org-element-secondary-value-alist') will accept an optional -;; argument to toggle parsing of that secondary string. Moreover, +;; argument to toggle parsing of these secondary strings. Moreover, ;; `item' parser requires current list's structure as its first ;; element. ;; @@ -4064,11 +4065,9 @@ looking into captions: ;; If --DATA has a secondary string that can contain ;; objects with their type among TYPES, look into it. (when (and (eq --category 'objects) (not (stringp --data))) - (let ((sec-prop - (assq --type org-element-secondary-value-alist))) - (when sec-prop - (funcall --walk-tree - (org-element-property (cdr sec-prop) --data))))) + (dolist (p (cdr (assq --type + org-element-secondary-value-alist))) + (funcall --walk-tree (org-element-property p --data)))) ;; If --DATA has any parsed affiliated keywords and ;; WITH-AFFILIATED is non-nil, look for objects in ;; them. -- 2.11.4.GIT