emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Toby Cubitt <tsc25@cantab.net>
To: emacs-orgmode@gnu.org
Subject: Re: [PATCH] Allow %<num> escapes to capture templates, expanded	to text	entered in <num>'th prompt
Date: Mon, 23 Apr 2012 17:29:47 +0200	[thread overview]
Message-ID: <20120423152947.GA8960@c3po> (raw)
In-Reply-To: <87ehre1nyk.fsf@gnu.org>

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

On Mon, Apr 23, 2012 at 05:12:51PM +0200, Bastien wrote:
> Hi Toby,
> 
> Toby Cubitt <tsc25@cantab.net> writes:
> 
> > Ah, I forgot about the texinfo docs. Sorry. I'll try to remember them
> > next time.
> 
> No problem.
> 
> > - Change the regexp to "%\\([1-9][0-9]*\\)", to match any positive
> >   integer, and update the docs accordingly.
> 
> Please send a patch for this solution.

Attached (this time including a texinfo documentation update ;-)

Toby
-- 
Dr T. S. Cubitt
Mathematics and Quantum Information group
Department of Mathematics
Complutense University
Madrid, Spain

email: tsc25@cantab.net
web:   www.dr-qubit.org

[-- Attachment #2: 0001-org-capture.el-Fixed-bug-in-org-capture-templates-n-.patch --]
[-- Type: text/x-patch, Size: 2604 bytes --]

From 4407cd46e3cf8339a9c90d4dde8337b7dbaca048 Mon Sep 17 00:00:00 2001
From: "Toby S. Cubitt" <tsc25@cantab.net>
Date: Mon, 23 Apr 2012 17:20:19 +0200
Subject: [PATCH] org-capture.el: Fixed bug in org-capture-templates %<n>
 expandos

* lisp/org-capture.el (org-capture-fill-template): Fixed regexp for
  %<n> expandos to match any positive integer.
  (org-capture-templates): Updated docstring accordingly.

* doc/org.texi: Updated documentation accordingly.
---
 doc/org.texi        |    4 ++--
 lisp/org-capture.el |    6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/doc/org.texi b/doc/org.texi
index a25572d..bb98713 100644
--- a/doc/org.texi
+++ b/doc/org.texi
@@ -6700,8 +6700,8 @@ dynamic insertion of content.  The templates are expanded in the order given her
             @r{You may specify a default value and a completion table with}
             @r{%^@{prompt|default|completion2|completion3...@}.}
             @r{The arrow keys access a prompt-specific history.}
-%<n>        @r{Insert the text entered for at the nth %^{prompt}, where <n>}
-            @r{represents a digit, 1 to 9.}
+%<n>        @r{Insert the text entered at the nth %^{prompt}, where <n> is}
+            @r{a number, starting from 1.}
 %?          @r{After completing the template, position cursor here.}
 @end smallexample
 
diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index 7fbd438..d507cc2 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -248,8 +248,8 @@ be replaced with content and expanded in this order:
               A default value and a completion table ca be specified like this:
               %^{prompt|default|completion2|completion3|...}.
   %?          After completing the template, position cursor here.
-  %<n>        Insert the text entered for at the nth %^{prompt}, where <n>
-              represents a digit, 1 to 9.
+  %<n>        Insert the text entered at the nth %^{prompt}, where <n> is
+              a number, starting from 1.
 
 Apart from these general escapes, you can access information specific to the
 link type that is created.  For example, calling `org-capture' in emails
@@ -1480,7 +1480,7 @@ The template may still contain \"%?\" for cursor positioning."
       ;; Replace %n escapes with nth %^{...} string
       (setq strings (nreverse strings))
       (goto-char (point-min))
-      (while (re-search-forward "%\\([1-9]\\)+" nil t)
+      (while (re-search-forward "%\\([1-9][0-9]*\\)" nil t)
 	(unless (org-capture-escaped-%)
 	  (replace-match
 	   (nth (1- (string-to-number (match-string 1))) strings)
-- 
1.7.8.5


  reply	other threads:[~2012-04-23 15:30 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-22 22:47 [PATCH] Allow %<num> escapes to capture templates, expanded to text entered in <num>'th prompt Toby Cubitt
2012-04-23 12:54 ` Bastien
2012-04-23 15:08   ` Toby Cubitt
2012-04-23 15:12     ` Bastien
2012-04-23 15:29       ` Toby Cubitt [this message]
2012-04-23 15:34         ` Bastien
2012-04-24  9:57         ` Bastien
2012-04-24 11:05           ` Toby Cubitt
2012-04-24 12:51             ` Bastien
2012-04-24 13:37               ` Toby Cubitt

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=20120423152947.GA8960@c3po \
    --to=tsc25@cantab.net \
    --cc=emacs-orgmode@gnu.org \
    --cc=toby-dated-1336404614.831fac@dr-qubit.org \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public 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).