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:08:15 +0200 Message-ID: <20120423150815.GA3139@c3po> References: <87d36y8v7c.fsf@gnu.org> Reply-To: Toby Cubitt Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from eggs.gnu.org ([208.118.235.92]:51935) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SMKsg-0005Hj-9y for emacs-orgmode@gnu.org; Mon, 23 Apr 2012 11:08:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SMKsd-0008Nz-K2 for emacs-orgmode@gnu.org; Mon, 23 Apr 2012 11:08:45 -0400 Received: from starfish.geekisp.com ([216.168.135.166]:34801) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SMKsd-0008Mu-GW for emacs-orgmode@gnu.org; Mon, 23 Apr 2012 11:08:43 -0400 Content-Disposition: inline In-Reply-To: <87d36y8v7c.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 On Mon, Apr 23, 2012 at 02:54:31PM +0200, Bastien wrote: > Toby Cubitt writes: > > > Currently, capture templates provide no way of prompting for some text, > > then inserting that text into multiple places in the template. > > Thanks for the patch, I applied it. > > I also updated the documentation in doc/org.texi -- please provide > documentation in the patch containing code changes if relevant next > times. Ah, I forgot about the texinfo docs. Sorry. I'll try to remember them next time. > One tiny thing: the documentation said that %0 would match the first > occurrence but while I tested the first occurrence was on %1, which > looks better to me. > > So I updated the documentation accordingly. Yes, you're right, it starts from 1. That's what comes of adding the documentation later, as an after-thought...(bad programming practice!) And now I look at it again, there's a bug in the regexp (my fault): the regexp "%\\([1-9]\\)+" currently matches any sequence of 1-9's, which is clearly wrong. The two possible fixes are: - Drop the final + from the regexp so that it reads "%\\([1-9]\\)", to match any single non-zero digit, as per the current docs. (The regexp group must be kept, because it's used later in the code.) - Change the regexp to "%\\([1-9][0-9]*\\)", to match any positive integer, and update the docs accordingly. It seems unlikely anyone would ever want to refer back to more than 9 prompts in a capture template. (I think back-references in Emacs regexps are similarly limited to single digits). On the other hand, whenever someone says "it seems unlikely anyone would ever want to..." about Emacs, up pops someone who wants to do exactly that ;-) Your call. If you tell me which fix you prefer, I can supply a patch if you want one (though the change is so small I imagine it'll be easier to do it manually). 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