From: Thorsten Jolitz <tjolitz@gmail.com>
To: emacs-orgmode@gnu.org
Subject: [PATCH] Enable appending to multivalued-property
Date: Mon, 18 Mar 2013 10:47:16 +0100 [thread overview]
Message-ID: <87li9l82fv.fsf@gmail.com> (raw)
[-- 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
next reply other threads:[~2013-03-18 9:47 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-18 9:47 Thorsten Jolitz [this message]
2013-03-19 17:03 ` [PATCH] Enable appending to multivalued-property Bastien
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87li9l82fv.fsf@gmail.com \
--to=tjolitz@gmail.com \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).