From 2496eec5ad79c7e4e4f3804efb1bbce17f913704 Mon Sep 17 00:00:00 2001 From: Eric Schulte Date: Tue, 1 Nov 2011 10:56:36 -0600 Subject: [PATCH] Allow some properties to accumulate (see `org-accumulated-properties-alist'). The default value of this new variable is '(("var" . ", ")) resulting in the following behavior #+property: var foo=1 #+property: var bar=2 #+begin_src emacs-lisp (+ foo bar) #+end_src #+results: : 3 * lisp/org.el (org-accumulated-properties-alist): Adding an alist which specifies which properties may be accumulated and how. (org-set-regexps-and-options): Make use of accumulating properties when collecting said. --- lisp/org.el | 28 ++++++++++++++++++++++++++-- 1 files changed, 26 insertions(+), 2 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index 318ccfd..b34d274 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -4431,6 +4431,22 @@ in the #+STARTUP line, the corresponding variable, and the value to set this variable to if the option is found. An optional forth element PUSH means to push this value onto the list in the variable.") +(defcustom org-accumulated-properties-alist + '(("var" . ", ")) + "Alist of properties whose values should accumulate rather than overwrite. +Each element of this alist should include both a string property +name as well as the string connector used to join multiple values +for this property. So for example using the default value of +this list which associates \"var\" with \", \", the following +Org-mode text, + + #+PROPERTY: var foo=1 + #+PROPERTY: var bar=2 + +will result in the following being added to `org-file-properties'. + + '(\"var\" . \"foo=1, bar=2\")") + (defun org-set-regexps-and-options () "Precompute regular expressions for current buffer." (when (eq major-mode 'org-mode) @@ -4492,8 +4508,16 @@ means to push this value onto the list in the variable.") (setq prio (org-split-string value " +"))) ((equal key "PROPERTY") (when (string-match "\\(\\S-+\\)\\s-+\\(.*\\)" value) - (push (cons (match-string 1 value) (match-string 2 value)) - props))) + (let* ((prop (match-string 1 value)) + (value (match-string 2 value)) + (str (cdr (assoc prop org-accumulated-properties-alist))) + (existing (cdr (assoc prop props)))) + (if (and str existing) + (setq props (cons (cons prop (concat existing str value)) + (org-remove-if (lambda (p) + (string= (car p) prop)) + props))) + (push (cons prop value) props))))) ((equal key "FILETAGS") (when (string-match "\\S-" value) (setq ftags -- 1.7.4.1