diff options
author | Carsten Dominik <carsten.dominik@gmail.com> | 2011-04-06 08:49:12 +0200 |
---|---|---|
committer | Carsten Dominik <carsten.dominik@gmail.com> | 2011-04-06 08:49:12 +0200 |
commit | 8a831e8f6c764dc0808f96f73dfc0e5db2455587 (patch) | |
tree | 982debe04a73e86e8567b51b82f5c24d7816a5b4 | |
parent | b869bc5a7e792843beda1fb86b157fbd0376eef0 (diff) | |
download | org-mode-8a831e8f6c764dc0808f96f73dfc0e5db2455587.tar.gz |
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.
-rw-r--r-- | doc/org.texi | 1 | ||||
-rw-r--r-- | lisp/org-capture.el | 6 |
2 files changed, 7 insertions, 0 deletions
diff --git a/doc/org.texi b/doc/org.texi index b32b822..5ab25b0 100644 --- a/doc/org.texi +++ b/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.} diff --git a/lisp/org-capture.el b/lisp/org-capture.el index eb7430b..2ae8a74 100644 --- a/lisp/org-capture.el +++ b/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) |