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.
This commit is contained in:
Carsten Dominik 2010-02-01 07:39:20 +01:00
parent 9321460f3e
commit b23f448431
2 changed files with 20 additions and 15 deletions

View File

@ -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

View File

@ -488,21 +488,6 @@ 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))
;; Simple %-escapes
(while (re-search-forward "%\\([tTuUaiAcxkKI]\\)" nil t)
(unless (org-remember-escaped-%)
(when (and initial (equal (match-string 0) "%i"))
(save-match-data
(let* ((lead (buffer-substring
(point-at-bol) (match-beginning 0))))
(setq v-i (mapconcat 'identity
(org-split-string initial "\n")
(concat "\n" lead))))))
(replace-match
(or (eval (intern (concat "v-" (match-string 1)))) "")
t t)))
;; %[] Insert contents of a file.
(goto-char (point-min))
@ -517,6 +502,21 @@ to be run from that hook to function properly."
(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"))
(save-match-data
(let* ((lead (buffer-substring
(point-at-bol) (match-beginning 0))))
(setq v-i (mapconcat 'identity
(org-split-string initial "\n")
(concat "\n" lead))))))
(replace-match
(or (eval (intern (concat "v-" (match-string 1)))) "")
t t)))
;; %() embedded elisp
(goto-char (point-min))
(while (re-search-forward "%\\((.+)\\)" nil t)