emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] Enable appending to multivalued-property
@ 2013-03-18  9:47 Thorsten Jolitz
  2013-03-19 17:03 ` Bastien
  0 siblings, 1 reply; 2+ messages in thread
From: Thorsten Jolitz @ 2013-03-18  9:47 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 172 bytes --]


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:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Patch: Appending to multivalued property --]
[-- Type: text/x-patch, Size: 1542 bytes --]

From ca1c5585fd7e57b559d360d3cbcc69b1deb18c98 Mon Sep 17 00:00:00 2001
From: tj <tj@data-driven.de>
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


[-- Attachment #3: Type: text/plain, Size: 23 bytes --]


-- 
cheers,
Thorsten


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-03-19 18:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-18  9:47 [PATCH] Enable appending to multivalued-property Thorsten Jolitz
2013-03-19 17:03 ` Bastien

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).