From mboxrd@z Thu Jan 1 00:00:00 1970 From: Carsten Dominik Subject: Re: proposal: defconst/defcustom org-tags-regexp Date: Wed, 18 Jul 2007 23:24:40 +0200 Message-ID: <56626b2502c1e0ead302243cb947b0b2@science.uva.nl> References: <20070716132118.GA28297@atlantic.linksys.moosehall> Mime-Version: 1.0 (Apple Message framework v624) Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IBOAN-0001NL-PR for emacs-orgmode@gnu.org; Thu, 19 Jul 2007 01:03:07 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IBOAL-0001M4-Ks for emacs-orgmode@gnu.org; Thu, 19 Jul 2007 01:03:05 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IBOAL-0001Ly-DK for emacs-orgmode@gnu.org; Thu, 19 Jul 2007 01:03:05 -0400 Received: from korteweg.uva.nl ([146.50.98.70]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1IBOAK-0004uS-S9 for emacs-orgmode@gnu.org; Thu, 19 Jul 2007 01:03:05 -0400 In-Reply-To: <20070716132118.GA28297@atlantic.linksys.moosehall> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Adam Spiers Cc: org-mode mailing list On Jul 16, 2007, at 15:21, Adam Spiers wrote: > Hi again, > > There seem to be a number of hardcoded regexps currently used for > matching heading tags, all very similar looking, and typically > something like: > > [ \t]*\\(:[[:alnum:]_@:]+:\\)?[ \t]*\\($\\|\r\\) > > Is there any reason why these shouldn't be factored out into a new > defcustom org-tags-regexp? Well, one reason is efficiency. When a regular expression is a constant, Emacs is able to cache the compiled version of the regular expression, and this can speed up code that does a lot of matching quite a bit. The token you show above is usually part of a larger string, so the full regular expression would have to be make with concat and will therefore be recompiled all the time. However, we could use a macro to process the concat at compile time. This would still require that you have set the appropriate variables at compile time, and you would need to recompile the Lisp file after each change in this constant - not something that Emacs users do expect. Do you know a solution for this problem? Still, I agree that what I did is bad programming in the sense that things like this could/should be factored out. - Carsten -- Carsten Dominik Sterrenkundig Instituut "Anton Pannekoek" Universiteit van Amsterdam Kruislaan 403 NL-1098SJ Amsterdam phone: +31 20 525 7477