Hi Arash, 2015-11-24 21:13 GMT+01:00 Arash Esbati <esb...@gmx.de>: > Hi Mosè, > > Mosè Giordano <m...@gnu.org> 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--- \declaresomething[% key = value , name = {[Optional]Value} , anothername = {valu-es[]}]{} , colframe = red!75!black , fonttitle = \bfseries , enhanced , attach boxed = {yshift=-2mm} , title = #2 ] { some1thing } \othercommand[optional]{mandatory} --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 like "\\\\declaresomething\\[\\(?:[^][]*\\(?:\\[[^][]*\\(?:\\[[^][]*\\(?:\\[[^][]*\\][^][]*\\)*\\][^][]*\\)*\\][^][]*\\)*\\)\\][ \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'. Bye, Mosè _______________________________________________ auctex-devel mailing list auctex-devel@gnu.org https://lists.gnu.org/mailman/listinfo/auctex-devel