From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christian Moe Subject: Re: Merge Properties into Template Date: Thu, 06 Oct 2011 14:50:55 +0200 Message-ID: <4E8DA42F.6040306@christianmoe.com> References: Reply-To: mail@christianmoe.com Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([140.186.70.92]:38737) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RBnNF-0000ZF-Q8 for emacs-orgmode@gnu.org; Thu, 06 Oct 2011 08:48:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RBnNB-00069m-Ki for emacs-orgmode@gnu.org; Thu, 06 Oct 2011 08:48:29 -0400 Received: from mars.hitrost.net ([91.185.211.18]:51604) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RBnNB-00069W-C4 for emacs-orgmode@gnu.org; Thu, 06 Oct 2011 08:48:25 -0400 In-Reply-To: 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: Richard Parsons Cc: emacs-orgmode@gnu.org Hi, Org doesn't already have a particular way to do this, I think, so a little elisp is called for. It's fairly easy with the Org Properties API. Here's a modest example that will work with your sample document: #+begin_src emacs-lisp (defun cm/org-merge (target) "Fill a template headlined TARGET with the properties of the entry at point, replacing e.g. `[AGE]' with the contents of an :AGE: property. Use `[HEADLINE]' for the text of the entry heading." (interactive "sTarget template: ") (let ((props (org-entry-properties)) prop template) (setq props (cons (cons "HEADLINE" (org-get-heading)) props)) (save-excursion (org-open-link-from-string (format "[[*%s]]" target)) (setq template (org-get-entry))) (dolist (p props) (setq template (replace-regexp-in-string (format "\\[%s\\]" (car p)) (cdr p) template t))) (message template))) #+end_src Evaluate this code. Then place point in the Fido entry, do `M-x cm/org-merge', and type `Dog Template' at the prompt. To improve on that, how do you want to use it? Once Fido's data are merged with the template, what do you want to do with the results? Mail them to someone? Export them to HTML? Make a new Org entry with the contents and file it somewhere? Yours, Christian On 10/6/11 11:35 AM, Richard Parsons wrote: > Hi all > > I'm new to emacs and I'm new to org-mode, apologies if I should have > found this myself, but I have searched and come up blank. > > I have a node with properties and I would like to merge that data into > a template. For example: > > * Dogs > ** Fido > :PROPERTIES: > :BREED: West Highland Terrier > :COLOR: White > :AGE: 2 > :END: > * Templates > ** Dog Template > Your dog, called [HEADLINE], is a [COLOR] [BREED], who is [AGE] years old. > > I want to merge the item called "Fido" into the template called "Dog Template". > > Could someone point me to the right bit of the manual so I can learn > how to do this? Or should I be looking to use a different elisp > module to achieve this, something that plays nicely with org-mode? > > Many thanks > Richard > >