From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thorsten Jolitz Subject: [PATCH] Enable appending to multivalued-property Date: Mon, 18 Mar 2013 10:47:16 +0100 Message-ID: <87li9l82fv.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([208.118.235.92]:36868) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UHWfK-00007V-Nb for emacs-orgmode@gnu.org; Mon, 18 Mar 2013 05:47:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UHWfG-0006w6-JF for emacs-orgmode@gnu.org; Mon, 18 Mar 2013 05:47:38 -0400 Received: from plane.gmane.org ([80.91.229.3]:43929) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UHWfG-0006vw-CO for emacs-orgmode@gnu.org; Mon, 18 Mar 2013 05:47:34 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1UHWfb-0007fe-Ed for emacs-orgmode@gnu.org; Mon, 18 Mar 2013 10:47:55 +0100 Received: from e178061224.adsl.alicedsl.de ([85.178.61.224]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 18 Mar 2013 10:47:55 +0100 Received: from tj by e178061224.adsl.alicedsl.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 18 Mar 2013 10:47:55 +0100 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain Hi List, sometimes it make more sense to append a new value to a multivalued-property than putting it in front of the old values, so here is a patch that enables this: --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0002-Org-enable-appending-to-multivalued-property.patch Content-Description: Patch: Appending to multivalued property >From ca1c5585fd7e57b559d360d3cbcc69b1deb18c98 Mon Sep 17 00:00:00 2001 From: tj Date: Mon, 18 Mar 2013 10:40:54 +0100 Subject: [PATCH 2/2] Org: enable appending to multivalued property * org.el (org-entry-add-to-multivalued-property): Add optional argument APPEND to enable insertion of added value at the end of the multivalued property list. As an example, adding a new year to a property :copyright-years: should result in something like '2012 2013' and not '2013 2012'. --- lisp/org.el | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index a1fa315..33ade96 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -15089,13 +15089,17 @@ an empty drawer to delete." ;; Multi-values properties are properties that contain multiple values ;; These values are assumed to be single words, separated by whitespace. -(defun org-entry-add-to-multivalued-property (pom property value) +(defun org-entry-add-to-multivalued-property + (pom property value &optional APPEND) "Add VALUE to the words in the PROPERTY in entry at point-or-marker POM." (let* ((old (org-entry-get pom property)) (values (and old (org-split-string old "[ \t]")))) (setq value (org-entry-protect-space value)) (unless (member value values) - (setq values (cons value values)) + (setq values + (if APPEND + (add-to-list 'values value 'APPEND) + (cons value values))) (org-entry-put pom property (mapconcat 'identity values " "))))) -- 1.8.2 --=-=-= Content-Type: text/plain -- cheers, Thorsten --=-=-=--