[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Orgmode] inserting files within remember templates
From: |
Adam Spiers |
Subject: |
Re: [Orgmode] inserting files within remember templates |
Date: |
Tue, 6 Nov 2007 22:39:50 +0000 |
User-agent: |
Mutt/1.5.14 (2007-02-12) |
On Tue, Nov 06, 2007 at 04:36:47PM +0000, Adam Spiers wrote:
[snip]
> This could easily be accomplished if remember templates allowed syntax
> such as
>
> ,------
> | * %T
> | %(shell-command-to-string "grep 'last full' /proc/acpi/battery/BAT0/info")
> `------
OK, it turns out that this was easy to implement, and I think the
patch is small enough that it could be accepted even though I haven't
got around to sending back the copyright assignment form yet (sorry -
this *will* happen at some point!)
Diff against 5.13i:
--- a/org.el Wed Oct 31 09:46:35 2007 +0000
+++ b/org.el Tue Nov 06 22:30:13 2007 +0000
@@ -12806,6 +12806,17 @@ to be run from that hook to fucntion pro
(replace-match
(or (eval (intern (concat "v-" (match-string 1)))) "")
t t))
+ ;; %() embedded elisp
+ (goto-char (point-min))
+ (while (re-search-forward "%\\((.+)\\)" nil t)
+ (goto-char (match-beginning 0))
+ (let ((template-start (point)))
+ (forward-char 1)
+ (condition-case error
+ (let ((result (eval (read (current-buffer)))))
+ (delete-region template-start (point))
+ (insert result))
+ (error (message "Error `%s' in remember template" error)))))
;; From the property list
(when plist-p
(goto-char (point-min))
There might need to be some debate about how to handle read errors in
the case of invalid syntax. Or perhaps some people already have
`%(...)' within their remember templates for some really unusual
reason, and don't want it interpreted? Though in the latter case, one
could argue that it might make sense to require `%' always to be
escaped as `%%' if used literally, to be on the safe side.
- [Orgmode] inserting files within remember templates, Adam Spiers, 2007/11/05
- Re: [Orgmode] inserting files within remember templates, Bastien, 2007/11/06
- Re: [Orgmode] inserting files within remember templates, Adam Spiers, 2007/11/07
- Re: [Orgmode] inserting files within remember templates, Bastien, 2007/11/07
- Re: [Orgmode] inserting files within remember templates, Adam Spiers, 2007/11/07
- Re: [Orgmode] inserting files within remember templates, Bastien, 2007/11/07