From: Christian Moe <mail@christianmoe.com>
To: Richard Parsons <richard.lee.parsons@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: Merge Properties into Template
Date: Thu, 06 Oct 2011 22:52:13 +0200 [thread overview]
Message-ID: <4E8E14FD.2010409@christianmoe.com> (raw)
In-Reply-To: <CAB+=1LGGpeyoQ4e9ZMTgnsfQiUf5sUbb7WQUSb_548z80DWzGA@mail.gmail.com>
Hi,
On 10/6/11 5:56 PM, Richard Parsons wrote:
(...)
> Firstly, thank you so much for taking the time to write some code,
> which (even as a newbie) I was able to get running quickly and easily.
My pleasure. I'm finding my legs in elisp myself, and I often find a
better solution to a problem I've been grappling with when I think
about someone else's request. So it was in this case -- I had worked
on an insanely complicated mail-merge setup, your post made me realize
it could be done more simply.
> Of practical benefit to me would be either: (a) make a new Org entry
> and file it (as you suggest) or (b) simply put it in the kill ring, so
> that I can yank it wherever I want.
I enclose a new version (below) that does (b), add to the kill ring.
We could also do (a), make an entry and refile it, but if this is what
you want to do, I'd be more interested in looking into ways to do it
with org-capture and avoid reinventing the wheel -- even if setting up
org-capture templates is a little more involved than what you had in mind.
> Again, thanks so much for your help, and also the other replies I
> received. I'm very impressed by the org-mode community responding so
> quickly to my question.
Pass it forward!
Yours,
Christian
#+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) t)
(setq template (org-get-entry)))
(dolist (p props)
(setq template
(replace-regexp-in-string
(format "\\[%s\\]" (car p))
(cdr p)
template t)))
(kill-new template)
(message template)))
#+end_src
next prev parent reply other threads:[~2011-10-06 20:50 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-06 9:35 Merge Properties into Template Richard Parsons
2011-10-06 10:40 ` Merge Properties into Template; [babel] Giovanni Ridolfi
2011-10-06 11:35 ` Merge Properties into Template suvayu ali
2011-10-06 12:50 ` Christian Moe
2011-10-06 15:56 ` Richard Parsons
2011-10-06 20:52 ` Christian Moe [this message]
2011-10-07 7:04 ` Christian Moe
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=4E8E14FD.2010409@christianmoe.com \
--to=mail@christianmoe.com \
--cc=emacs-orgmode@gnu.org \
--cc=richard.lee.parsons@gmail.com \
/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).