all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [PATCH] Add %L (the link content *not* as a full link) to Capture expansions
@ 2020-09-10  0:13 Samuel W. Flint
  2020-09-13 20:25 ` Bastien
  0 siblings, 1 reply; 9+ messages in thread
From: Samuel W. Flint @ 2020-09-10  0:13 UTC (permalink / raw)
  To: Org-Mode

[-- 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)

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH] Add %L (the link content *not* as a full link) to Capture expansions
  2020-09-10  0:13 [PATCH] Add %L (the link content *not* as a full link) to Capture expansions Samuel W. Flint
@ 2020-09-13 20:25 ` Bastien
  2020-09-14 14:47   ` Samuel W. Flint
  0 siblings, 1 reply; 9+ messages in thread
From: Bastien @ 2020-09-13 20:25 UTC (permalink / raw)
  To: Samuel W. Flint; +Cc: Org-Mode

Hi Samuel,

swflint@flintfam.org (Samuel W. Flint) writes:

> 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.

It looks good to me for Org 9.5.  Can you add a Changelog entry to
your patch and also patch the tests and the manual, if needed?

See <https://orgmode.org/worg/org-contribute.html#commit-messages> 
for the format of the Changelog.

Thanks,

-- 
 Bastien


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] Add %L (the link content *not* as a full link) to Capture expansions
  2020-09-13 20:25 ` Bastien
@ 2020-09-14 14:47   ` Samuel W. Flint
  2020-09-14 15:12     ` Samuel W. Flint
  0 siblings, 1 reply; 9+ messages in thread
From: Samuel W. Flint @ 2020-09-14 14:47 UTC (permalink / raw)
  To: Bastien; +Cc: Org-Mode

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

>>>>> Bastien  writes:

    B> Hi Samuel, swflint@flintfam.org (Samuel W. Flint) writes:

    >> 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.

    B> It looks good to me for Org 9.5.  Can you add a Changelog entry
    B> to your patch and also patch the tests and the manual, if needed?

Apologies for spamming you with multiple copies Bastien.

Certainly!  Hopefully this looks better.  I didn't see any tests for %a,
%A or %l already, and I don't have time atm to write them, otherwise I'd
have done so.

I can mark this as TINYCHANGE, if necessary, as I don't have a copyright
assignment on file, though I'm willing to do so.

Thanks,

Sam


    B> See
    B> <https://orgmode.org/worg/org-contribute.html#commit-messages>
    B> for the format of the Changelog.

    B> Thanks,

    B> -- Bastien

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

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Add-in-support-for-filling-in-the-bare-link-in-org-c.patch --]
[-- Type: text/x-patch, Size: 2702 bytes --]

From 02de43c3457419f1031f4988d6c95fac535134e7 Mon Sep 17 00:00:00 2001
From: "Samuel W. Flint" <swflint@flintfam.org>
Date: Mon, 14 Sep 2020 09:07:07 -0500
Subject: [PATCH] Add in support for filling in the bare link in org capture

* doc/org-manual.org: Document new %L capture template formatting
directive.
* lisp/org-capture.el: (org-capture-templates) Document new %L capture
template formatting directive.
* lisp/org-capture.el: (org-capture-fill-template) Add in support for
%L, bare link formatting, in org-capture-fill-template.
---
 doc/org-manual.org  | 4 ++++
 lisp/org-capture.el | 7 ++++++-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/doc/org-manual.org b/doc/org-manual.org
index 7ab7d1c94..229575b13 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -7799,6 +7799,10 @@ here:
 
   Like =%a=, but only insert the literal link.
 
+- =%L= ::
+
+  Like =%l=, but without brackets (the link content itself).
+
 - =%c= ::
 
   Current kill ring head.
diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index d73e927fc..2ef55cd5c 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -315,6 +315,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 without brackets (the link content itself).
   %c          Current kill ring head.
   %x          Content of the X clipboard.
   %k          Title of currently clocked task.
@@ -1592,6 +1593,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)
@@ -1644,7 +1648,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
@@ -1681,6 +1685,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)
-- 
2.18.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH] Add %L (the link content *not* as a full link) to Capture expansions
  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-23  8:58       ` Bastien
  0 siblings, 2 replies; 9+ messages in thread
From: Samuel W. Flint @ 2020-09-14 15:12 UTC (permalink / raw)
  To: Bastien; +Cc: Org-Mode

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

Marked as TINYCHANGE.

Sam


>>>>> Samuel W Flint writes:

>>>>> Bastien  writes:
    B> Hi Samuel, swflint@flintfam.org (Samuel W. Flint) writes:

    >>> 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.

    B> It looks good to me for Org 9.5.  Can you add a Changelog entry
    B> to your patch and also patch the tests and the manual, if needed?

    SWF> Apologies for spamming you with multiple copies Bastien.

    SWF> Certainly!  Hopefully this looks better.  I didn't see any
    SWF> tests for %a, %A or %l already, and I don't have time atm to
    SWF> write them, otherwise I'd have done so.

    SWF> I can mark this as TINYCHANGE, if necessary, as I don't have a
    SWF> copyright assignment on file, though I'm willing to do so.

    SWF> Thanks,

    SWF> Sam


    B> See
    B> <https://orgmode.org/worg/org-contribute.html#commit-messages>
    B> for the format of the Changelog.

    B> Thanks,

    B> -- Bastien

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



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

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Add-in-support-for-filling-in-the-bare-link-in-org-c.patch --]
[-- Type: text/x-patch, Size: 2714 bytes --]

From 02de43c3457419f1031f4988d6c95fac535134e7 Mon Sep 17 00:00:00 2001
From: "Samuel W. Flint" <swflint@flintfam.org>
Date: Mon, 14 Sep 2020 09:07:07 -0500
Subject: [PATCH] Add in support for filling in the bare link in org capture

* doc/org-manual.org: Document new %L capture template formatting
directive.
* lisp/org-capture.el: (org-capture-templates) Document new %L capture
template formatting directive.
* lisp/org-capture.el: (org-capture-fill-template) Add in support for
%L, bare link formatting, in org-capture-fill-template.

TINYCHANGE
---
 doc/org-manual.org  | 4 ++++
 lisp/org-capture.el | 7 ++++++-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/doc/org-manual.org b/doc/org-manual.org
index 7ab7d1c94..229575b13 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -7799,6 +7799,10 @@ here:
 
   Like =%a=, but only insert the literal link.
 
+- =%L= ::
+
+  Like =%l=, but without brackets (the link content itself).
+
 - =%c= ::
 
   Current kill ring head.
diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index d73e927fc..2ef55cd5c 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -315,6 +315,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 without brackets (the link content itself).
   %c          Current kill ring head.
   %x          Content of the X clipboard.
   %k          Title of currently clocked task.
@@ -1592,6 +1593,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)
@@ -1644,7 +1648,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
@@ -1681,6 +1685,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)
-- 
2.18.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH] Add %L (the link content *not* as a full link) to Capture expansions
  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
  1 sibling, 1 reply; 9+ messages in thread
From: Samuel W. Flint @ 2020-09-22 13:04 UTC (permalink / raw)
  To: Bastien; +Cc: Org-Mode

Is there anything I can do to move this forward?

Thanks,

Sam


>>>>> Samuel W Flint writes:

    SWF> Marked as TINYCHANGE.  Sam


>>>>> Samuel W Flint writes:

>>>>> Bastien  writes:
    B> Hi Samuel, swflint@flintfam.org (Samuel W. Flint) writes:

    >>>> 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.

    B> It looks good to me for Org 9.5.  Can you add a Changelog entry
    B> to your patch and also patch the tests and the manual, if needed?

    SWF> Apologies for spamming you with multiple copies Bastien.

    SWF> Certainly!  Hopefully this looks better.  I didn't see any
    SWF> tests for %a, %A or %l already, and I don't have time atm to
    SWF> write them, otherwise I'd have done so.

    SWF> I can mark this as TINYCHANGE, if necessary, as I don't have a
    SWF> copyright assignment on file, though I'm willing to do so.

    SWF> Thanks,

    SWF> Sam


    B> See
    B> <https://orgmode.org/worg/org-contribute.html#commit-messages>
    B> for the format of the Changelog.

    B> Thanks,

    B> -- Bastien

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



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



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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] Add %L (the link content *not* as a full link) to Capture expansions
  2020-09-22 13:04       ` Samuel W. Flint
@ 2020-09-22 13:21         ` Bastien
  0 siblings, 0 replies; 9+ messages in thread
From: Bastien @ 2020-09-22 13:21 UTC (permalink / raw)
  To: Samuel W. Flint; +Cc: Org-Mode

Hi Samuel,

"Samuel W. Flint" <swflint@flintfam.org> writes:

> Is there anything I can do to move this forward?

You just need to be patient.  Either I will have some free time
at some point to help with this, either someone else will.

But the contribution is not forgotten, don't worry.

-- 
 Bastien


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] Add %L (the link content *not* as a full link) to Capture expansions
  2020-09-14 15:12     ` Samuel W. Flint
  2020-09-22 13:04       ` Samuel W. Flint
@ 2020-09-23  8:58       ` Bastien
  2020-09-24 23:00         ` Samuel W. Flint
  1 sibling, 1 reply; 9+ messages in thread
From: Bastien @ 2020-09-23  8:58 UTC (permalink / raw)
  To: Samuel W. Flint; +Cc: Org-Mode

Hi Samuel,

"Samuel W. Flint" <swflint@flintfam.org> writes:

> Marked as TINYCHANGE.

Applied as d06aa486d, thanks!

Can you provide a patch to announce this in etc/ORG-NEWS?

-- 
 Bastien


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] Add %L (the link content *not* as a full link) to Capture expansions
  2020-09-23  8:58       ` Bastien
@ 2020-09-24 23:00         ` Samuel W. Flint
  2020-09-24 23:27           ` Kyle Meyer
  0 siblings, 1 reply; 9+ messages in thread
From: Samuel W. Flint @ 2020-09-24 23:00 UTC (permalink / raw)
  To: Bastien; +Cc: Org-Mode

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

>>>>> Bastien  writes:

    B> Hi Samuel, "Samuel W. Flint" <swflint@flintfam.org> writes:

    >> Marked as TINYCHANGE.

    B> Applied as d06aa486d, thanks!

Thanks!

    B> Can you provide a patch to announce this in etc/ORG-NEWS?

Please see the attached patch.

    B> -- Bastien

Sam

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

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Describe-new-L-formatting-for-org-capture.patch --]
[-- Type: text/x-patch, Size: 1021 bytes --]

From b1242c2af3d5ab16ddcec52d3b3f47bb60895d9a Mon Sep 17 00:00:00 2001
From: "Samuel W. Flint" <swflint@flintfam.org>
Date: Thu, 24 Sep 2020 17:57:32 -0500
Subject: [PATCH] Describe new %L formatting for org-capture

* etc/ORG-NEWS (New formatting directive ~%L~ for org-capture):

Describe new %L formatting for org-capture

TINYCHANGE
---
 etc/ORG-NEWS | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index eed3871d4..f036aa6a5 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -11,6 +11,12 @@ See the end of the file for license conditions.
 Please send Org bug reports to mailto:emacs-orgmode@gnu.org.
 
 * Version 9.5 (not yet released)
+** New options and settings
+*** New formatting directive ~%L~ for org-capture
+
+The new ~%L~ formatting directive contains the bare link target, and
+may be used to create links with programmatically generated
+descriptions.
 * Version 9.4
 ** Incompatible changes
 *** Possibly broken internal file links: please check and fix
-- 
2.18.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH] Add %L (the link content *not* as a full link) to Capture expansions
  2020-09-24 23:00         ` Samuel W. Flint
@ 2020-09-24 23:27           ` Kyle Meyer
  0 siblings, 0 replies; 9+ messages in thread
From: Kyle Meyer @ 2020-09-24 23:27 UTC (permalink / raw)
  To: Samuel W. Flint; +Cc: Bastien, Org-Mode

Samuel W. Flint writes:

>>>>>> Bastien  writes:
>
>     B> Can you provide a patch to announce this in etc/ORG-NEWS?
>
> Please see the attached patch.

Thanks.  Applied (488076e0a).


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2020-09-24 23:28 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-09-10  0:13 [PATCH] Add %L (the link content *not* as a full link) to Capture expansions Samuel W. Flint
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

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.