Hi Mosè, Mosè Giordano <m...@gnu.org> writes:
> 2015-11-19 20:58 GMT+01:00 Arash Esbati <esb...@gmx.de>: >> looking at some packages, the optional arguments for some commands are >> getting more and more complex, e.g. >> >> --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 >> } >> --8<---------------cut here---------------end--------------->8--- >> >> I was thinking about a general regex-solution how to add these kind of >> beasts to AUCTeX parser. My solution is currently: >> >> --8<---------------cut here---------------start------------->8--- >> \\\\declaresomething[ \t\n\r%]*\\(?:\\[\\(?:[\t\n\r[:print:]]*\\)\\]\\)?[ >> \t\n\r%]*{[ \t\n\r%]*\\([[:print:]]+\\)[ \t\n\r%]*} >> --8<---------------cut here---------------end--------------->8--- >> >> Any comments? Admittedly, the last two `[ \t\n\r%]' are excessive, but >> you never know. > > Ehm, sorry but I didn't get what you want to match (re-builder > highlights "some1thing") and where you want to add this regex. My apologies for being brief and not clear. Please consider the following MWE: --8<---------------cut here---------------start------------->8--- \documentclass[a4paper,10pt]{article} \usepackage{amsthm} \usepackage{thmtools} \declaretheoremstyle[% spaceabove = 6pt , spacebelow = 6pt , headfont = \normalfont\bfseries , notefont = \mdseries\scshape , notebraces = {[}{]} , bodyfont = \normalfont\itshape , postheadspace = 1em , qed = \qedsymbol ]{mystyle} \declaretheorem[style=mystyle]{styledtheorem} \begin{document} \begin{styledtheorem}[Euclid] For every prime $p$\dots \end{styledtheorem} \end{document} --8<---------------cut here---------------end--------------->8--- Suppose I want to write a `thmtools.el'. If I want to catch and process user defined styles (in this case "mystyle"), I would currently do: --8<---------------cut here---------------start------------->8--- (defvar LaTeX-thmtools-declaretheoremstyle-regexp `(,(concat "\\\\declaretheoremstyle[ \t\n\r%]*" "\\(?:\\[\\(?:[\t\n\r[:print:]]*\\)\\]\\)?" "[ \t\n\r%]*" "{" "[ \t\n\r%]*\\([[:print:]]+\\)[ \t\n\r%]*" "}"))) (TeX-auto-add-type "thmtools-declaretheoremstyle" "LaTeX") (TeX-add-style-hook "thmtools" (lambda () (TeX-auto-add-regexp LaTeX-thmtools-declaretheoremstyle-regexp) ...)) --8<---------------cut here---------------end--------------->8--- My question is: Is there any other, better solution for this regexp? I am looking a general solution to handle this kind of cases. I hope it is more clear now. Cheers, Arash _______________________________________________ auctex-devel mailing list auctex-devel@gnu.org https://lists.gnu.org/mailman/listinfo/auctex-devel