[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [AUCTeX-devel] Regex best practice

From: Mosè Giordano
Subject: Re: [AUCTeX-devel] Regex best practice
Date: Tue, 24 Nov 2015 21:58:22 +0100

Hi Arash,

2015-11-24 21:13 GMT+01:00 Arash Esbati <address@hidden>:
> Hi Mosè,
> Mosè Giordano <address@hidden> writes:
>> Probably yes: so you want to match the whole \declaretheoremstyle
>> macro, but saving only the mandatory argument, right?
> Yes, exactly.

The problem of your regex is that will match *everything* until the
last closing bracket.  This is good when you test your regex in a
simple case, but will fail in a real document with other commands
taking optional and mandatory arguments. Consider for example

--8<---------------cut here---------------start------------->8---
  key          = value               ,
  name         = {[Optional]Value}   ,
  anothername  = {valu-es[]}]{}      ,
  colframe     = red!75!black        ,
  fonttitle    = \bfseries           ,
  enhanced                           ,
  attach boxed = {yshift=-2mm}       ,
  title        = #2

--8<---------------cut here---------------end--------------->8---

`re-builder' highlights "mandatory", with your regex.  In addition, it
doesn't seem to work at all with XEmacs, but I don't know why.

Is the non paired "]" in

      anothername  = {valu-es[]}]{}      ,

intended?  If so, I don't have a solution at hand, otherwise, if
you're sure you have always paired brackets, you can use something

\t\n\r]*{[ \t\n\r]*\\(.*\\)[ \t\n\r]*}"

(I'm sorry for the hard-wrapping, replace the newline with a space)
which is inspired by `LaTeX-auto-index-regexp-list'.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]