Browse Source

Introduce a new org-capture escape for arbitrarily defined time strings

* lisp/org-capture.el (org-capture-fill-template): Resolve new %<...>
template escape.
(org-capture-templates): Document new %<...> template escape.
* doc/org.texi (Template expansion): Document new %<...> template escape.
Carsten Dominik 14 years ago
parent
commit
8a831e8f6c
2 changed files with 7 additions and 0 deletions
  1. 1 0
      doc/org.texi
  2. 6 0
      lisp/org-capture.el

+ 1 - 0
doc/org.texi

@@ -6456,6 +6456,7 @@ dynamic insertion of content:
 %u, %U      @r{like the above, but inactive timestamps}
 %^t         @r{like @code{%t}, but prompt for date.  Similarly @code{%^T}, @code{%^u}, @code{%^U}}
             @r{You may define a prompt like @code{%^@{Birthday@}t}}
+%<...>      @r{the result of format-time-string on the ... format specification}
 %n          @r{user name (taken from @code{user-full-name})}
 %c          @r{Current kill ring head.}
 %x          @r{Content of the X clipboard.}

+ 6 - 0
lisp/org-capture.el

@@ -215,6 +215,7 @@ Furthermore, the following %-escapes will be replaced with content:
   %u, %U      like the above, but inactive time stamps
   %^t         like %t, but prompt for date.  Similarly %^T, %^u, %^U.
               You may define a prompt like %^{Please specify birthday
+  %<...>      the result of format-time-string on the ... format specification
   %n          user name (taken from `user-full-name')
   %a          annotation, normally the link created with `org-store-link'
   %i          initial content, copied from the active region.  If %i is
@@ -1299,6 +1300,11 @@ The template may still contain \"%?\" for cursor positioning."
 	      (delete-region template-start (point))
 	      (insert result)))))
 
+      ;; The current time
+      (goto-char (point-min))
+      (while (re-search-forward "%<\\([^>\n]+\\)>" nil t)
+	(replace-match (format-time-string (match-string 1)) t t))
+
       ;; Simple %-escapes
       (goto-char (point-min))
       (while (re-search-forward "%\\([tTuUaiAcxkKInfF]\\)" nil t)