diff options
author | Carsten Dominik <carsten.dominik@gmail.com> | 2010-02-01 07:39:20 +0100 |
---|---|---|
committer | Carsten Dominik <carsten.dominik@gmail.com> | 2010-02-01 07:42:18 +0100 |
commit | b23f4484314f3cb476266cc136942bbd89ad7add (patch) | |
tree | 58b343df74649102e0c9969881af8e25b61257c1 | |
parent | 9321460f3ef21c14e28ca59e504b53c2073829c3 (diff) | |
download | org-mode-b23f4484314f3cb476266cc136942bbd89ad7add.tar.gz |
When expanding remember templates, do file insertion first
zwz writes:
> I use org-remember for my contact records.
>
> This is a template in org-remember-templates
> ("Contact" ?c "* %^{Name} \n%[~/.contact]\n" "contact.org" "Contacts")
>
> the content of the file "~/.contact":
> :PROPERTIES:
> :Mobile: %^{mobile}
> :Email:
> :Added: %u
> :END:
>
> I found that the prompt "%^{mobile}" works, but *the inactive time stamp "%u"
> does not.* It is not replaced.
>
> I guess it is a bug.
-rwxr-xr-x | lisp/ChangeLog | 5 | ||||
-rw-r--r-- | lisp/org-remember.el | 28 |
2 files changed, 19 insertions, 14 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 8666f60..34d94a3 100755 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2010-02-01 Carsten Dominik <carsten.dominik@gmail.com> + + * org-remember.el (org-remember-apply-template): Do file insertion + first. + 2010-01-31 Carsten Dominik <carsten.dominik@gmail.com> * org-habit.el (org-habit-insert-consistency-graphs): Fix a diff --git a/lisp/org-remember.el b/lisp/org-remember.el index 4a17994..c229946 100644 --- a/lisp/org-remember.el +++ b/lisp/org-remember.el @@ -488,9 +488,22 @@ to be run from that hook to function properly." (or (cdr org-remember-previous-location) "???") (if org-remember-store-without-prompt "C-1 C-c C-c" " C-c C-c")))) (insert tpl) - (goto-char (point-min)) + ;; %[] Insert contents of a file. + (goto-char (point-min)) + (while (re-search-forward "%\\[\\(.+\\)\\]" nil t) + (unless (org-remember-escaped-%) + (let ((start (match-beginning 0)) + (end (match-end 0)) + (filename (expand-file-name (match-string 1)))) + (goto-char start) + (delete-region start end) + (condition-case error + (insert-file-contents filename) + (error (insert (format "%%![Couldn't insert %s: %s]" + filename error))))))) ;; Simple %-escapes + (goto-char (point-min)) (while (re-search-forward "%\\([tTuUaiAcxkKI]\\)" nil t) (unless (org-remember-escaped-%) (when (and initial (equal (match-string 0) "%i")) @@ -504,19 +517,6 @@ to be run from that hook to function properly." (or (eval (intern (concat "v-" (match-string 1)))) "") t t))) - ;; %[] Insert contents of a file. - (goto-char (point-min)) - (while (re-search-forward "%\\[\\(.+\\)\\]" nil t) - (unless (org-remember-escaped-%) - (let ((start (match-beginning 0)) - (end (match-end 0)) - (filename (expand-file-name (match-string 1)))) - (goto-char start) - (delete-region start end) - (condition-case error - (insert-file-contents filename) - (error (insert (format "%%![Couldn't insert %s: %s]" - filename error))))))) ;; %() embedded elisp (goto-char (point-min)) (while (re-search-forward "%\\((.+)\\)" nil t) |