emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: swflint@flintfam.org (Samuel W. Flint)
To: "Org-Mode" <emacs-orgmode@gnu.org>
Subject: [PATCH] Add %L (the link content *not* as a full link) to Capture expansions
Date: Wed, 09 Sep 2020 19:13:22 -0500	[thread overview]
Message-ID: <87pn6uij4t.fsf@flintfam.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 459 bytes --]

Hello,

In an attempt at automating a part of my workflow, I found that
org-capture's %l didn't quite fit what I needed.  Normally,
org-store-link does the right thing, but for some capture tasks, I want
to custom generate the description, so %l doesn't work.  I've attached a
patch that adds %L, a version that doesn't add the link brackets.

Thanks,

Sam Flint

-- 
Samuel W. Flint
4096R/FA13D704
      (F50D 862B 4F65 5943 A8C2  EF0E 86C9 3E7A FA13 D704)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: org-capture.el.diff --]
[-- Type: text/x-patch, Size: 1694 bytes --]

diff --git i/lisp/org-capture.el w/lisp/org-capture.el
index 2cc1ce394..e638eabfa 100644
--- i/lisp/org-capture.el
+++ w/lisp/org-capture.el
@@ -308,6 +308,7 @@ be replaced with content and expanded:
   %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.
+  %L          Like %l, but no brackets (the link content itself).
   %c          Current kill ring head.
   %x          Content of the X clipboard.
   %k          Title of currently clocked task.
@@ -1574,6 +1575,9 @@ The template may still contain \"%?\" for cursor positioning."
 	 (v-l (if (and v-a (string-match l-re v-a))
 		  (replace-match "[[\\1]]" nil nil v-a)
 		v-a))
+	 (v-L (if (or 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)
 		  (org-no-properties org-clock-heading)
@@ -1626,7 +1630,7 @@ The template may still contain \"%?\" for cursor positioning."
       ;; Mark %() embedded elisp for later evaluation.
       (org-capture-expand-embedded-elisp 'mark)
       ;; Expand non-interactive templates.
-      (let ((regexp "%\\(:[-A-Za-z]+\\|<\\([^>\n]+\\)>\\|[aAcfFikKlntTuUx]\\)"))
+      (let ((regexp "%\\(:[-A-Za-z]+\\|<\\([^>\n]+\\)>\\|[aAcfFikKlLntTuUx]\\)"))
 	(save-excursion
 	  (while (re-search-forward regexp nil t)
 	    ;; `org-capture-escaped-%' may modify buffer and cripple
@@ -1663,6 +1667,7 @@ The template may still contain \"%?\" for cursor positioning."
 			  (?k v-k)
 			  (?K v-K)
 			  (?l v-l)
+			  (?L v-L)
 			  (?n v-n)
 			  (?t v-t)
 			  (?T v-T)

             reply	other threads:[~2020-09-10  0:15 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-10  0:13 Samuel W. Flint [this message]
2020-09-13 20:25 ` Bastien
2020-09-14 14:47   ` Samuel W. Flint
2020-09-14 15:12     ` Samuel W. Flint
2020-09-22 13:04       ` Samuel W. Flint
2020-09-22 13:21         ` Bastien
2020-09-23  8:58       ` Bastien
2020-09-24 23:00         ` Samuel W. Flint
2020-09-24 23:27           ` Kyle Meyer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87pn6uij4t.fsf@flintfam.org \
    --to=swflint@flintfam.org \
    --cc=emacs-orgmode@gnu.org \
    --subject='Re: [PATCH] Add %L (the link content *not* as a full link) to Capture expansions' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Code repositories for project(s) associated with this inbox:

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).