From mboxrd@z Thu Jan 1 00:00:00 1970 From: Toby Cubitt Subject: Re: [PATCH] Allow % escapes to capture templates, expanded to text entered in 'th prompt Date: Mon, 23 Apr 2012 17:29:47 +0200 Message-ID: <20120423152947.GA8960@c3po> References: <87ehre1nyk.fsf@gnu.org> Reply-To: Toby Cubitt Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="/04w6evG8XlLl3ft" Return-path: Received: from eggs.gnu.org ([208.118.235.92]:34235) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SMLDa-0008PT-HT for emacs-orgmode@gnu.org; Mon, 23 Apr 2012 11:30:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SMLDV-0001P9-Fg for emacs-orgmode@gnu.org; Mon, 23 Apr 2012 11:30:22 -0400 Received: from sanddollar.geekisp.com ([216.168.135.167]:40998) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SMLDV-0001OP-AY for emacs-orgmode@gnu.org; Mon, 23 Apr 2012 11:30:17 -0400 Content-Disposition: inline In-Reply-To: <87ehre1nyk.fsf@gnu.org> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org --/04w6evG8XlLl3ft Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Mon, Apr 23, 2012 at 05:12:51PM +0200, Bastien wrote: > Hi Toby, > > Toby Cubitt 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 --/04w6evG8XlLl3ft Content-Type: text/x-patch; charset=us-ascii Content-Disposition: attachment; filename="0001-org-capture.el-Fixed-bug-in-org-capture-templates-n-.patch" >From 4407cd46e3cf8339a9c90d4dde8337b7dbaca048 Mon Sep 17 00:00:00 2001 From: "Toby S. Cubitt" Date: Mon, 23 Apr 2012 17:20:19 +0200 Subject: [PATCH] org-capture.el: Fixed bug in org-capture-templates % expandos * lisp/org-capture.el (org-capture-fill-template): Fixed regexp for % 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.} -% @r{Insert the text entered for at the nth %^{prompt}, where } - @r{represents a digit, 1 to 9.} +% @r{Insert the text entered at the nth %^{prompt}, where 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. - % Insert the text entered for at the nth %^{prompt}, where - represents a digit, 1 to 9. + % Insert the text entered at the nth %^{prompt}, where 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 --/04w6evG8XlLl3ft--