Browse Source

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.
Carsten Dominik 15 years ago
parent
commit
b23f448431
2 changed files with 19 additions and 14 deletions
  1. 5 0
      lisp/ChangeLog
  2. 14 14
      lisp/org-remember.el

+ 5 - 0
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

+ 14 - 14
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)