1
0
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-12-28 10:56:57 +00:00

org-capture.el: New template %l to insert the literal link.

* org-capture.el (org-capture-templates): New template %l to
insert the literal link pointing at the current buffer.

* org.texi (Template expansion): Document the new %l template.

Thanks to Eric Abrahamsen for this idea.
This commit is contained in:
Bastien Guerry 2012-08-02 17:06:22 +02:00
parent 2201d838a4
commit 21ec0159b8
2 changed files with 12 additions and 8 deletions

View File

@ -6771,7 +6771,7 @@ buffer again after capture is completed.
@subsubsection Template expansion
In the template itself, special @kbd{%}-escapes@footnote{If you need one of
these sequences literally, escape the @kbd{%} with a backslash.} allow
these sequences literally, escape the @kbd{%} with a backslash.} allow
dynamic insertion of content. The templates are expanded in the order given here:
@smallexample
@ -6782,11 +6782,12 @@ dynamic insertion of content. The templates are expanded in the order given her
%t @r{Timestamp, date only.}
%T @r{Timestamp, with date and time.}
%u, %U @r{Like the above, but inactive timestamps.}
%a @r{Annotation, normally the link created with @code{org-store-link}.}
%i @r{Initial content, the region when capture is called while the}
@r{region is active.}
@r{The entire text will be indented like @code{%i} itself.}
%a @r{Annotation, normally the link created with @code{org-store-link}.}
%A @r{Like @code{%a}, but prompt for the description part.}
%l @r{Like %a, but only insert the literal link.}
%c @r{Current kill ring head.}
%x @r{Content of the X clipboard.}
%k @r{Title of the currently clocked task.}

View File

@ -225,10 +225,11 @@ be replaced with content and expanded in this order:
%t time stamp, date only.
%T time stamp with date and time.
%u, %U like the above, but inactive time stamps.
%a annotation, normally the link created with `org-store-link'.
%i initial content, copied from the active region. If %i is
indented, the entire inserted text will be indented as well.
%a annotation, normally the link created with `org-store-link'.
%A like %a, but prompt for the description part.
%l like %a, but only insert the literal link.
%c current kill ring head.
%x content of the X clipboard.
%k title of currently clocked task.
@ -1318,10 +1319,12 @@ The template may still contain \"%?\" for cursor positioning."
(org-get-x-clipboard 'CLIPBOARD)
(org-get-x-clipboard 'SECONDARY)
v-c)))
(v-A (if (and v-a
(string-match
"\\[\\(\\[.*?\\]\\)\\(\\[.*?\\]\\)?\\]" v-a))
(replace-match "[\\1[%^{Link description}]]" nil nil v-a)
(l-re "\\[\\[\\(.*?\\)\\]\\(\\[.*?\\]\\)?\\]")
(v-A (if (and v-a (string-match l-re v-a))
(replace-match "[[\\1][%^{Link description}]]" nil nil v-a)
v-a))
(v-l (if (and v-a (string-match l-re v-a))
(replace-match "\\1" nil nil v-a)
v-a))
(v-n user-full-name)
(v-k (if (marker-buffer org-clock-marker)
@ -1386,7 +1389,7 @@ The template may still contain \"%?\" for cursor positioning."
;; Simple %-escapes
(goto-char (point-min))
(while (re-search-forward "%\\([tTuUaiAcxkKInfF]\\)" nil t)
(while (re-search-forward "%\\([tTuUaliAcxkKInfF]\\)" nil t)
(unless (org-capture-escaped-%)
(when (and initial (equal (match-string 0) "%i"))
(save-match-data