summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/regexpatch
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2013-03-28 23:11:17 +0000
committerKarl Berry <karl@freefriends.org>2013-03-28 23:11:17 +0000
commitb4c8139007078b0a07b19aa44f430f7bfd37c43a (patch)
tree209bea2b42d0a6b1484eec25178048d4a84da89c /Master/texmf-dist/source/latex/regexpatch
parent00633214cca4f6c180bfb4707bcd752e0258b472 (diff)
regexpatch (28mar13)
git-svn-id: svn://tug.org/texlive/trunk@29543 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/regexpatch')
-rw-r--r--Master/texmf-dist/source/latex/regexpatch/regexpatch.dtx883
-rw-r--r--Master/texmf-dist/source/latex/regexpatch/regexpatch.ins2
2 files changed, 679 insertions, 206 deletions
diff --git a/Master/texmf-dist/source/latex/regexpatch/regexpatch.dtx b/Master/texmf-dist/source/latex/regexpatch/regexpatch.dtx
index 0d09d90aa1b..9aa54c4aa13 100644
--- a/Master/texmf-dist/source/latex/regexpatch/regexpatch.dtx
+++ b/Master/texmf-dist/source/latex/regexpatch/regexpatch.dtx
@@ -1,6 +1,6 @@
% \iffalse meta-comment
%
-%% File: regexpatch.dtx (C) Copyright 2012 Enrico Gregorio
+%% File: regexpatch.dtx (C) Copyright 2012-2013 Enrico Gregorio
%%
%% It may be distributed and/or modified under the conditions of the
%% LaTeX Project Public License (LPPL), either version 1.3c of this
@@ -25,7 +25,7 @@
\newcommand{\sv}{[\texttt{*}]}
%</driver>
%<*driver|package>
-\GetIdInfo$Id: regexpatch.dtx 0.1b 2012-07-24 12:00:00Z Enrico $
+\GetIdInfo$Id: regexpatch.dtx 0.2 2013-03-28 12:00:00Z Enrico $
{Extending etoolbox patching commands}
%</driver|package>
%<*driver>
@@ -55,6 +55,10 @@
%
% \maketitle
%
+% \changes{v0.2}{2013/03/28}{Polished code and documentation}
+% \changes{v0.2}{2013/03/28}{Additional biblatex related macros}
+% \changes{v0.1c}{2013/03/25}{Replaced obsolete command \texttt{\string\prg\string_case\string_str:onn}}
+% \changes{v0.1c}{2013/03/25}{Replaced \texttt{\string\msg\string_term:x} with \texttt{\string\msg\string_term:n}}
% \changes{v0.1b}{2012/07/24}{Fixed bugs in the `bibmacro' functions}
% \changes{v0.1a}{2012/06/07}{Fixed bugs in success/failure code}
% \changes{v0.1}{2012-04-15}{First public release}
@@ -65,10 +69,11 @@
% Important preliminary notice
% \end{center}
% \medskip
+%
% This is an experimental version and it might cease to work if the
-% commands in the package \textsf{l3regex} are modified. When that
+% commands in the package \pkg{l3regex} are modified. When that
% \LaTeX3 package will be declared stable, this package will replace
-% \textsf{xpatch} and calling |\usepackage{regexpatch}| will load the
+% \pkg{xpatch} and calling |\usepackage{regexpatch}| will load the
% main package. Use at own risk.
% \end{quotation}
%
@@ -119,7 +124,7 @@
%\begin{verbatim}
% \DeclareRobustCommand{\xyz}{something}
%\end{verbatim}
-% A |\show\xyz| would show the cryptic
+% A |\show\xyz| instruction would show the cryptic
%\begin{verbatim}
% > \xyz=macro:
% ->\protect \xyz .
@@ -161,7 +166,7 @@
% The \pkg{regexpatch} package uses many features of the \LaTeX3
% experimental packages, in particular of \pkg{l3regex}. This has a
% clear advantage: we can have a *-variant of |\xpatchcmd| that does a
-% ``replace~all'' that can avoid multiple uses of |\patchcmd| on the
+% ``replace~all'' which can avoid multiple uses of |\patchcmd| on the
% same macro. Moreover there's a very powerful |\regexpatchcmd|
% function that uses regular expression syntax for search and replace
% which can even patch commands defined under different category code
@@ -206,19 +211,22 @@
%
% If the command to be patched contains `|@|-commands' in its
% replacement text, \emph{always} ensure that the patching code is
-% enclosed between |\makeatletter| and |\makeatother|. It's
-% recommended to turn on |\tracingxpatches| when testing a patch, to
-% get maximum information.
+% enclosed between |\makeatletter| and |\makeatother|; this is
+% different from what \pkg{etoolbox} requires. It's recommended to
+% turn on |\tracingxpatches| when testing a patch, to get maximum
+% information.
+%
+% Some people like to add informative messages to the \meta{failure}
+% code in the patching commands. Usually I'm lazy and don't do it;
+% when testing I find it better to trace the patchings or add |\ddt|
+% to the \meta{failure} code. Adding warnings to the \meta{success}
+% code is annoying for the user.
%
-% In the present version, commands that have been redefined via the
-% \pkg{etoolbox} command |\robustify| are \emph{not} patchable, in
-% general. The next version will probably provide a new way for
-% robustifying commands.
%
% \section{Acknowledgment}
%
-% This package would not exist without the \textsf{l3regex} package
-% and Bruno Le Floch. Some parts of \textsf{l3regex} were added just
+% This package would not exist without the \pkg{l3regex} package
+% and Bruno Le Floch. Some parts of \pkg{l3regex} were added just
% because I asked for them while developing the present package.
% Thanks also to Joseph Wright and all the \LaTeX3 team.
%
@@ -320,11 +328,38 @@
% the |{success}| and |{failure}| arguments also with
% |\xpretobibdriver| and |\xapptobibdriver|.
%
+% Under the same philosophy, one can use the macros
+% \begin{itemize}
+% \item |\xpatchfieldformat|,\\ |\xpretofieldformat|,\\ |\xapptofieldformat|,
+% \item |\xpatchnameformat|,\\ |\xpretonameformat|,\\ |\xapptonameformat|,
+% \item |\xpatchlistformat|,\\ |\xpretonameformat|,\\ |\xapptonameformat|,
+% \item |\xpatchindexfieldformat|,\\ |\xpretoindexfieldformat|,\\ |\xapptoindexfieldformat|,
+% \item |\xpatchindexnameformat|,\\ |\xpretoindexnameformat|,\\ |\xapptoindexnameformat|,
+% \item |\xpatchindexlistformat|,\\ |\xpretoindexlistformat|,\\ |\xapptoindexlistformat|,
+% \end{itemize}
+% for the \pkg{biblatex} internal macro defined respectively with
+% \begin{flushleft}
+% |\DeclareFieldFormat|,
+% |\DeclareNameFormat|,
+% |\DeclareListFormat|,\\
+% |\DeclareIndexFieldFormat|,
+% |\DeclareIndexNameFormat|,
+% |\DeclareIndexListFormat|.
+% \end{flushleft}
+% All the eighteen |\x...format| commands take a first optional argument, with
+% default value |*|, see later on.
+%
% Finally, the package defines the commands
% \begin{itemize}
% \item |\xshowcmd|
% \item |\xshowbibmacro|
% \item |\xshowbibdriver|
+% \item |\xshowfieldformat|
+% \item |\xshownameformat|
+% \item |\xshowlistformat|
+% \item |\xshowindexfieldformat|
+% \item |\xshowindexnameformat|
+% \item |\xshowindexlistformat|
% \item |\tracingxpatches|
% \end{itemize}
% The first three are the analog of |\show| to see the ``real''
@@ -344,29 +379,63 @@
%
% \section{Syntax}
%
+% Here is the formal syntax of the commands.
+%
+% \medskip
+% {\small\noindent
+% |\xpatchcmd|\marg{command}\marg{search}\marg{replace}^^A
+% \marg{success}\marg{failure}\\
% |\xpretocmd|\marg{command}\marg{prepend}^^A
% \marg{success}\marg{failure}\\
% |\xapptocmd|\marg{command}\marg{append}^^A
-% \marg{success}\marg{failure}\\
-% |\xpatchcmd|\sv\marg{command}\marg{search}\marg{replace}^^A
-% \marg{success}\marg{failure}\\
-% |\regexpatchcmd|\sv\marg{command}\marg{search}\marg{replace}^^A
% \marg{success}\marg{failure}\\[\medskipamount]
+% |\xpatchbibmacro|\marg{name}\marg{search}\marg{replace}^^A
+% \marg{success}\marg{failure}\\
% |\xpretobibmacro|\marg{name}\marg{prepend}^^A
% \marg{success}\marg{failure}\\
% |\xapptobibmacro|\marg{name}\marg{append}^^A
-% \marg{success}\marg{failure}\\
-% |\xpatchbibmacro|\sv\marg{name}\marg{search}\marg{replace}^^A
-% \marg{success}\marg{failure}\\
-% |\regexpatchbibmacro|\sv\marg{name}\marg{search}\marg{replace}^^A
% \marg{success}\marg{failure}\\[\medskipamount]
+% |\xpatchbibdriver|\marg{name}\marg{search}\marg{replace}^^A
+% \marg{success}\marg{failure}\\
% |\xpretobibdriver|\marg{name}\marg{prepend}^^A
% \marg{success}\marg{failure}\\
% |\xapptobibdriver|\marg{name}\marg{append}^^A
+% \marg{success}\marg{failure}\\[\medskipamount]
+% |\xpatchfieldformat|\oarg{entrytype}\marg{name}\marg{search}\marg{replace}^^A
+% \marg{success}\marg{failure}\\
+% |\xpretofieldformat|\oarg{entrytype}\marg{name}\marg{prepend}^^A
+% \marg{success}\marg{failure}\\
+% |\xapptofieldformat|\oarg{entrytype}\marg{name}\marg{append}^^A
+% \marg{success}\marg{failure}\\[\medskipamount]
+% |\xpatchnameformat|\oarg{entrytype}\marg{name}\marg{search}\marg{replace}^^A
+% \marg{success}\marg{failure}\\
+% |\xpretonameformat|\oarg{entrytype}\marg{name}\marg{prepend}^^A
+% \marg{success}\marg{failure}\\
+% |\xapptonameformat|\oarg{entrytype}\marg{name}\marg{append}^^A
+% \marg{success}\marg{failure}\\[\medskipamount]
+% |\xpatchlistformat|\oarg{entrytype}\marg{name}\marg{search}\marg{replace}^^A
+% \marg{success}\marg{failure}\\
+% |\xpretolistformat|\oarg{entrytype}\marg{name}\marg{prepend}^^A
+% \marg{success}\marg{failure}\\
+% |\xapptolistformat|\oarg{entrytype}\marg{name}\marg{append}^^A
+% \marg{success}\marg{failure}\\[\medskipamount]
+% |\xpatchindexfieldformat|\oarg{entrytype}\marg{name}\marg{search}\marg{replace}^^A
+% \marg{success}\marg{failure}\\
+% |\xpretoindexfieldformat|\oarg{entrytype}\marg{name}\marg{prepend}^^A
% \marg{success}\marg{failure}\\
-% |\xpatchbibdriver|\sv\marg{name}\marg{search}\marg{replace}^^A
+% |\xapptoindexfieldformat|\oarg{entrytype}\marg{name}\marg{append}^^A
+% \marg{success}\marg{failure}\\[\medskipamount]
+% |\xpatchindexnameformat|\oarg{entrytype}\marg{name}\marg{search}\marg{replace}^^A
+% \marg{success}\marg{failure}\\
+% |\xpretoindexnameformat|\oarg{entrytype}\marg{name}\marg{prepend}^^A
% \marg{success}\marg{failure}\\
-% |\regexpatchbibdriver|\sv\marg{name}\marg{search}\marg{replace}^^A
+% |\xapptoindexnameformat|\oarg{entrytype}\marg{name}\marg{append}^^A
+% \marg{success}\marg{failure}\\[\medskipamount]
+% |\xpatchindexlistformat|\oarg{entrytype}\marg{name}\marg{search}\marg{replace}^^A
+% \marg{success}\marg{failure}\\
+% |\xpretoindexlistformat|\oarg{entrytype}\marg{name}\marg{prepend}^^A
+% \marg{success}\marg{failure}\\
+% |\xapptoindexlistformat|\oarg{entrytype}\marg{name}\marg{append}^^A
% \marg{success}\marg{failure}\\[\medskipamount]
% |\xshowcmd|\sv\marg{command}\\
% |\xshowbibname|\marg{name}\\
@@ -377,21 +446,30 @@
% |\checkifpatchable|\marg{name}\\
% |\tracingxpatches|\oarg{number}
%
+% }
+%
% \medskip
%
+% \begingroup\emergencystretch=.5\textwidth
% Here \meta{command} is the command's name (with the backslash),
% while \meta{name} is the string that appears as the argument to
-% |\newbibmacro| or |\DeclareBibliographyDriver| respectively;
+% |\newbibmacro|, |\DeclareBibliographyDriver|, |\DeclareFieldFormat|,
+% |\DeclareNameFormat|, |\DeclareListFormat|, |\DeclareIndexFieldFormat|,
+% |\DeclareIndexNameFormat| or |\DeclareIndexListFormat| respectively;
% \meta{search}, \meta{replace}, \meta{prepend} and \meta{append} are
% the list of tokens that are to be used for the specific tasks;
% \meta{success} and \meta{failure} are token lists to be executed if
% the patching succeeds or fails respectively. I find it useful to use
% |\ddt| as \meta{failure}, so that \TeX{} will stop for the undefined
-% control sequence when the patching fails.
+% control sequence when the patching fails.\par\endgroup
+%
+% All the |\x...format| macros have an optional argument that by
+% default is |*|.
%
% In the commands whose name contains the string |regex|, both
% \meta{search} and \meta{replace} are understood to represent regular
-% expressions.
+% expressions. Check with the documentation of \pkg{l3regex} for
+% details.
%
% The *-variants of the |patch| type commands means that the
% replacement is performed on \emph{all} matches. With
@@ -497,7 +575,7 @@
% \makeatother
%\end{verbatim}
% We want to add |\gdef\cont@name@part{#2}| at the end of the
-% replacement text, distinguishing when \textsf{hyperref} is loaded or
+% replacement text, distinguishing when \pkg{hyperref} is loaded or
% not. So we patch the command by doing just what's requested. The
% example is a bit contrived, as using |\ifdefined| instead of the
% argument form wrapper would allow the traditional |\apptocmd|.
@@ -738,29 +816,45 @@
}
% \end{macrocode}
% We use the information gathered with |\xpatch_main_check:N| to
-% perform the patch; the macro to patch is |#3|, the function to
-% execute is |#1|; |#2| is a function that gobbles the next items in
-% case the macro's name is misspelled.
+% perform the patch; the macro to patch is |#2|, the function to
+% execute is |#1|; in case the macro's name is misspelled, the
+% following arguments will be ignored because they have already been
+% absorbed. The main function is |\xpatch_main_four:NNnnnn|, where the
+% |four| refers to the number of braced arguments for the |patch| and
+% |regexpatch| type macros; we define also a |three| function for
+% |preto| and |appto| macros, and a |zero| function for the |show|
+% macros. We also define the variants taking a name as their second
+% argument.
% \begin{macrocode}
-\cs_new_protected:Npn \xpatch_main:NNN #1 #2 #3
+\cs_new_protected:Npn \xpatch_main_four:NNnnnn #1 #2 #3 #4 #5 #6
{
- \cs_if_exist:NTF #3
+ \cs_if_exist:NTF #2
{
- \xpatch_main_check:N #3
+ \xpatch_main_check:N #2
\bool_if:NT \l_xpatch_tracing_bool
- { \xpatch_message_cstype:N #3 }
- \exp_after:wN #1 \cs:w \l_xpatch_name_tl \cs_end:
+ { \xpatch_message_cstype:N #2 }
+ \exp_after:wN #1 \cs:w \l_xpatch_name_tl \cs_end: {#3}{#4}{#5}{#6}
}
{
- \msg_term:x
+ \msg_term:n
{
xpatch~message \\
- `\token_to_str:N #3'~is~undefined;~
+ `\token_to_str:N #2'~is~undefined;~
I'll~ignore~the~request.
}
- #2
}
}
+\cs_new_protected:Npn \xpatch_main_three:NNnnn #1 #2 #3 #4 #5
+ {
+ \xpatch_main_four:NNnnnn #1 #2 { #3 } { #4 } { #5 } { }
+ }
+\cs_new_protected:Npn \xpatch_main_zero:NN #1 #2
+ {
+ \xpatch_main_four:NNnnnn #1 #2 { } { } { } { }
+ }
+\cs_generate_variant:Nn \xpatch_main_zero:NN {Nc}
+\cs_generate_variant:Nn \xpatch_main_three:NNnnn {Nc}
+\cs_generate_variant:Nn \xpatch_main_four:NNnnnn {Nc}
% \end{macrocode}
%
% Now we define the patching functions. We get all the parts in which
@@ -782,14 +876,15 @@
% After possible modifications to the replacement text, we can call
% |\xpatch_rebuild:N| to redo the definition of |#1|; we can also use
% it for checking if |#1| is patchable. Of course we need to use
-% |\tex_def:D| at this point.
+% |\tex_def:D| at this point. Apologies to the developers of \LaTeX3
+% that recommend never using |:D| functions.
% \begin{macrocode}
\cs_new_protected:Npn \xpatch_rebuild:N #1
{
\use:x
{
\exp_not:V \l_xpatch_prefix_tl
- \tex_def:D
+ \tex_def:D % unavoidable
\exp_not:N #1
\exp_not:V \l_xpatch_arg_tl
{ \exp_not:V \l_xpatch_replacement_tl }
@@ -836,7 +931,9 @@
%
% Defining the internal versions of |\xpretocmd| and |\xapptocmd| is
% easy: we check if the command is patchable and, if so, we prepend or append
-% the second argument to the replacement text and rebuild the macro.
+% the second argument to the replacement text and rebuild the
+% macro, then we execute the \meta{success} code. If the patch isn't
+% possible we just execute the \meta{failure} code.
% \begin{macrocode}
\cs_new_protected:Npn \xpatch_pretocmd:Nnnn #1 #2 #3 #4
{
@@ -951,12 +1048,12 @@
{
\bool_if:NT \l_xpatch_tracing_bool
{
- \msg_term:x { xpatch~message \\ #1 }
+ \msg_term:n { xpatch~message \\ #1 }
}
}
\cs_new:Npn \xpatch_message_cstype:N #1
{
- \prg_case_str:onn { \l_xpatch_type_tl }
+ \str_case:onn { \l_xpatch_type_tl }
{
{ DRCw } {
\xpatch_message:n
@@ -1025,161 +1122,536 @@
% \subsection{The user level functions}
%
% Here are the functions for patching usual macros; the *-variants for
-% |\xpatchcmd| and |\regexpatchcmd| do a `replace all'.
-% \changes{v0.1a}{2012/06/07}{Fixed bug in success/failure code
-% (missing final \texttt{n})}
+% |\xpatchcmd| and |\regexpatchcmd| do a `replace all'. All arguments
+% are declared `long' with |+m| because we may need |\par| in them.
+% \changes{v0.1a}{2012/06/07}{Fixed bug in success/failure code (missing final \texttt{n})}
% \begin{macrocode}
-\NewDocumentCommand{\xshowcmd} { s m }
- {
- \IfBooleanT{#1}
- {
- \group_begin:
- \bool_set_true:N \l_xpatch_tracing_bool
- }
- \xpatch_main:NNN \cs_show:N \prg_do_nothing: #2
- \IfBooleanT{#1}
- {
- \group_end:
- }
- }
-\NewDocumentCommand{\xpretocmd}{ }
- { \xpatch_main:NNN \xpatch_pretocmd:Nnnn \use_none:nn }
-\NewDocumentCommand{\xapptocmd}{ }
- { \xpatch_main:NNN \xpatch_apptocmd:Nnnn \use_none:nn }
-\NewDocumentCommand{\regexpatchcmd}{ s }
- {
- \IfBooleanTF{#1}
- { \xpatch_main:NNN \xpatch_regexpatchcmd_all:Nnnnn \use_none:nnn }
- { \xpatch_main:NNN \xpatch_regexpatchcmd_once:Nnnnn \use_none:nnn }
- }
-\NewDocumentCommand{\xpatchcmd}{ s }
- {
- \IfBooleanTF{#1}
- { \xpatch_main:NNN \xpatch_patchcmd_all:Nnnnn \use_none:nnn }
- { \xpatch_main:NNN \xpatch_patchcmd_once:Nnnnn \use_none:nnn }
- }
+\NewDocumentCommand{\xshowcmd} { s +m }
+ {
+ \IfBooleanT{#1}
+ {
+ \group_begin:
+ \bool_set_true:N \l_xpatch_tracing_bool
+ }
+ \xpatch_main_zero:NN \cs_show:N #2
+ \IfBooleanT{#1}
+ {
+ \group_end:
+ }
+ }
+\NewDocumentCommand{\xpretocmd}{ +m +m +m +m }
+ { \xpatch_main_three:NNnnn \xpatch_pretocmd:Nnnn #1 {#2} {#3} {#4} }
+\NewDocumentCommand{\xapptocmd}{ +m +m +m +m }
+ { \xpatch_main_three:NNnnn \xpatch_apptocmd:Nnnn #1 {#2} {#3} {#4} }
+\NewDocumentCommand{\regexpatchcmd}{ s +m +m +m +m +m }
+ {
+ \IfBooleanTF{#1}
+ { \xpatch_main_four:NNnnnn \xpatch_regexpatchcmd_all:Nnnnn #2 {#3}{#4}{#5}{#6} }
+ { \xpatch_main_four:NNnnnn \xpatch_regexpatchcmd_once:Nnnnn #2 {#3}{#4}{#5}{#6} }
+ }
+\NewDocumentCommand{\xpatchcmd}{ s +m +m +m +m +m }
+ {
+ \IfBooleanTF{#1}
+ { \xpatch_main_four:NNnnnn \xpatch_patchcmd_all:Nnnnn #2 {#3}{#4}{#5}{#6} }
+ { \xpatch_main_four:NNnnnn \xpatch_patchcmd_once:Nnnnn #2 {#3}{#4}{#5}{#6} }
+ }
% \end{macrocode}
%
% The functions for patching \pkg{biblatex} related macros that are
-% given by name. We need a variant of |\xpatch_main:NN|.
+% given by name and we'll use the already defined variants.
% \begin{macrocode}
-\cs_generate_variant:Nn \xpatch_main:NNN {NNc}
-\NewDocumentCommand{\xshowbibmacro} { s m }
- {
- \IfBooleanT{#1}
- {
- \group_begin:
- \bool_set_true:N \l_xpatch_tracing_bool
- }
- \xpatch_main:NNc \cs_show:N \prg_do_nothing: { abx@macro@ \tl_to_str:n {#2} }
- \IfBooleanT{#1}
- {
- \group_end:
- }
- }
-\NewDocumentCommand{\xpretobibmacro} { m }
- {
- \xpatch_main:NNc \xpatch_pretocmd:Nnnn \use_none:nn
- { abx@macro@ \tl_to_str:n {#1} }
- }
-\NewDocumentCommand{\xapptobibmacro} { m }
- {
- \xpatch_main:NNc \xpatch_apptocmd:Nnnn \use_none:nn
- { abx@macro@ \tl_to_str:n {#1} }
- }
-\NewDocumentCommand{\xpatchbibmacro} { s m }
- {
- \IfBooleanTF{#1}
- {
- \xpatch_main:NNc \xpatch_patchcmd_all:Nnnnn \use_none:nnn
- { abx@macro@ \tl_to_str:n {#2} }
- }
- {
- \xpatch_main:NNc \xpatch_patchcmd_once:Nnnnn \use_none:nnn
- { abx@macro@ \tl_to_str:n {#2} }
- }
- }
-\NewDocumentCommand{\regexpatchbibmacro} { s m }
- {
- \IfBooleanTF{#1}
- {
- \xpatch_main:NNc \xpatch_regexpatchcmd_all:Nnnnn \use_none:nnn
- { abx@macro@ \tl_to_str:n {#2} }
- }
- {
- \xpatch_main:NNc \xpatch_regexpatchcmd_once:Nnnnn \use_none:nnn
- { abx@macro@ \tl_to_str:n {#2} }
- }
- }
-\NewDocumentCommand{\xshowbibdriver} { s m }
- {
- \IfBooleanT{#1}
- {
- \group_begin:
- \bool_set_true:N \l_xpatch_tracing_bool
- }
- \xpatch_main:NNc \cs_show:N \prg_do_nothing: { blx@bbx@#2 }
- \IfBooleanT{#1}
- {
- \group_end:
- }
- }
-\NewDocumentCommand{\xpretobibdriver} { m }
- { \exp_args:Nc \xpatch_pretocmd:Nnnn {blx@bbx@#1} }
-\NewDocumentCommand{\xapptobibdriver} { m }
- { \exp_args:Nc \xpatch_apptocmd:Nnnn {blx@bbx@#1} }
-\NewDocumentCommand{\xpatchbibdriver} { s m }
- {
- \IfBooleanTF{#1}
- { \exp_args:Nc \xpatch_patchcmd_all:Nnnnn {blx@bbx@#2} }
- { \exp_args:Nc \xpatch_patchcmd_once:Nnnnn {blx@bbx@#2} }
- }
-\NewDocumentCommand{\regexpatchbibdriver} { s m }
- {
- \IfBooleanTF{#1}
- { \exp_args:Nc \xpatch_regexpatchcmd_all:Nnnnn {blx@bbx@#2} }
- { \exp_args:Nc \xpatch_regexpatchcmd_once:Nnnnn {blx@bbx@#2} }
- }
+\NewDocumentCommand{\xshowbibmacro} { s +m }
+ {
+ \IfBooleanT{#1}
+ {
+ \group_begin:
+ \bool_set_true:N \l_xpatch_tracing_bool
+ }
+ \xpatch_main_zero:Nc \cs_show:N { abx@macro@ \tl_to_str:n {#2} }
+ \IfBooleanT{#1}
+ {
+ \group_end:
+ }
+ }
+\NewDocumentCommand{\xpretobibmacro} { +m +m +m +m }
+ {
+ \xpatch_main_three:Ncnnn \xpatch_pretocmd:Nnnn
+ { abx@macro@ \tl_to_str:n {#1} } {#2}{#3}{#4}
+ }
+\NewDocumentCommand{\xapptobibmacro} { +m +m +m +m }
+ {
+ \xpatch_main_three:Ncnnn \xpatch_apptocmd:Nnnn
+ { abx@macro@ \tl_to_str:n {#1} } {#2}{#3}{#4}
+ }
+\NewDocumentCommand{\xpatchbibmacro} { s +m +m +m +m +m }
+ {
+ \IfBooleanTF{#1}
+ {
+ \xpatch_main_four:Ncnnnn \xpatch_patchcmd_all:Nnnnn
+ { abx@macro@ \tl_to_str:n {#2} } {#3}{#4}{#5}{#6}
+ }
+ {
+ \xpatch_main:Ncnnnn \xpatch_patchcmd_once:Nnnnn
+ { abx@macro@ \tl_to_str:n {#2} } {#3}{#4}{#5}{#6}
+ }
+ }
+\NewDocumentCommand{\regexpatchbibmacro} { s +m +m +m +m +m }
+ {
+ \IfBooleanTF{#1}
+ {
+ \xpatch_main_four:Ncnnnn \xpatch_regexpatchcmd_all:Nnnnn
+ { abx@macro@ \tl_to_str:n {#2} } {#3}{#4}{#5}{#6}
+ }
+ {
+ \xpatch_main_four:Ncnnnn \xpatch_regexpatchcmd_once:Nnnnn
+ { abx@macro@ \tl_to_str:n {#2} } {#3}{#4}{#5}{#6}
+ }
+ }
+\NewDocumentCommand{\xshowbibdriver} { s +m }
+ {
+ \IfBooleanT{#1}
+ {
+ \group_begin:
+ \bool_set_true:N \l_xpatch_tracing_bool
+ }
+ \xpatch_main_zero:Nc \cs_show:N { blx@bbx@#2 }
+ \IfBooleanT{#1}
+ {
+ \group_end:
+ }
+ }
+\NewDocumentCommand{\xpretobibdriver} { +m +m +m +m }
+ { \exp_args:Nc \xpatch_pretocmd:Nnnn {blx@bbx@#1} {#2}{#3}{#4} }
+\NewDocumentCommand{\xapptobibdriver} { +m +m +m +m }
+ { \exp_args:Nc \xpatch_apptocmd:Nnnn {blx@bbx@#1} {#2}{#3}{#4} }
+\NewDocumentCommand{\xpatchbibdriver} { s +m +m +m +m +m }
+ {
+ \IfBooleanTF{#1}
+ { \exp_args:Nc \xpatch_patchcmd_all:Nnnnn {blx@bbx@#2} {#2}{#3}{#4}{#5} }
+ { \exp_args:Nc \xpatch_patchcmd_once:Nnnnn {blx@bbx@#2} {#2}{#3}{#4}{#5} }
+ }
+\NewDocumentCommand{\regexpatchbibdriver} { s +m +m +m +m +m }
+ {
+ \IfBooleanTF{#1}
+ { \exp_args:Nc \xpatch_regexpatchcmd_all:Nnnnn {blx@bbx@#2} {#2}{#3}{#4}{#5} }
+ { \exp_args:Nc \xpatch_regexpatchcmd_once:Nnnnn {blx@bbx@#2} {#2}{#3}{#4}{#5} }
+ }
+% \end{macrocode}
+% Other \pkg{biblatex} related macros, added by request of the
+% maintainers.
+% \changes{v0.2}{2013/03/28}{Additional biblatex related macros}
+% \begin{macrocode}
+\NewDocumentCommand{\xshowfieldformat} { s O{*} +m }
+ {
+ \IfBooleanT{#1}
+ {
+ \group_begin:
+ \bool_set_true:N \l_xpatch_tracing_bool
+ }
+ \xpatch_main_zero:Nc \cs_show:N { abx@ffd@ \tl_to_str:n {#2} @ \tl_to_str:n {#3} }
+ \IfBooleanT{#1}
+ {
+ \group_end:
+ }
+ }
+\NewDocumentCommand{\xpretofieldformat} { s O{*} +m +m +m +m }
+ {
+ \IfBooleanTF{#1}
+ {
+ \xpatch_main_three:Ncnnn \xpatch_pretocmd_all:Nnnn
+ { abx@ffd@ \tl_to_str:n {#2} @ \tl_to_str:n {#3} } {#4}{#5}{#6}
+ }
+ {
+ \xpatch_main_three:Ncnnn \xpatch_pretocmd_once:Nnnn
+ { abx@ffd@ \tl_to_str:n {#2} @ \tl_to_str:n {#3} } {#4}{#5}{#6}
+ }
+ }
+\NewDocumentCommand{\xapptofieldformat} { s O{*} +m +m +m +m }
+ {
+ \IfBooleanTF{#1}
+ {
+ \xpatch_main_three:Ncnnn \xpatch_apptocmd_all:Nnnn
+ { abx@ffd@ \tl_to_str:n {#2} @ \tl_to_str:n {#3} } {#4}{#5}{#6}
+ }
+ {
+ \xpatch_main_three:Ncnnn \xpatch_apptocmd_once:Nnnn
+ { abx@ffd@ \tl_to_str:n {#2} @ \tl_to_str:n {#3} } {#4}{#5}{#6}
+ }
+ }
+\NewDocumentCommand{\xpatchfieldformat} { s O{*} +m +m +m +m +m }
+ {
+ \IfBooleanTF{#1}
+ {
+ \xpatch_main_four:Ncnnnn \xpatch_patchcmd_all:Nnnnn
+ { abx@ffd@ \tl_to_str:n {#2} @ \tl_to_str:n {#3} } {#4}{#5}{#6}{#7}
+ }
+ {
+ \xpatch_main_four:Ncnnnn \xpatch_patchcmd_once:Nnnnn
+ { abx@ffd@ \tl_to_str:n {#2} @ \tl_to_str:n {#3} } {#4}{#5}{#6}{#7}
+ }
+ }
+\NewDocumentCommand{\regexpatchfieldformat} { s O{*} +m +m +m +m +m }
+ {
+ \IfBooleanTF{#1}
+ {
+ \xpatch_main_four:Ncnnnn \xpatch_regexpatchcmd_all:Nnnnn
+ { abx@ffd@ \tl_to_str:n {#2} @ \tl_to_str:n {#3} } {#4}{#5}{#6}{#7}
+ }
+ {
+ \xpatch_main_four:Ncnnnn \xpatch_regexpatchcmd_once:Nnnnn
+ { abx@ffd@ \tl_to_str:n {#2} @ \tl_to_str:n {#3} } {#4}{#5}{#6}{#7}
+ }
+ }
+
+\NewDocumentCommand{\xshownameformat} { s O{*} +m }
+ {
+ \IfBooleanT{#1}
+ {
+ \group_begin:
+ \bool_set_true:N \l_xpatch_tracing_bool
+ }
+ \xpatch_main_zero:Nc \cs_show:N { abx@nfd@ \tl_to_str:n {#1} @ \tl_to_str:n {#2} }
+ \IfBooleanT{#1}
+ {
+ \group_end:
+ }
+ }
+\NewDocumentCommand{\xpretonameformat} { s O{*} +m +m +m +m }
+ {
+ \IfBooleanTF{#1}
+ {
+ \xpatch_main_three:Ncnnn \xpatch_pretocmd_all:Nnnn
+ { abx@nfd@ \tl_to_str:n {#2} @ \tl_to_str:n {#3} } {#4}{#5}{#6}
+ }
+ {
+ \xpatch_main_three:Ncnnn \xpatch_pretocmd_once:Nnnn
+ { abx@nfd@ \tl_to_str:n {#2} @ \tl_to_str:n {#3} } {#4}{#5}{#6}
+ }
+ }
+\NewDocumentCommand{\xapptonameformat} { s O{*} +m +m +m +m }
+ {
+ \IfBooleanTF{#1}
+ {
+ \xpatch_main_three:Ncnnn \xpatch_apptocmd_all:Nnnn
+ { abx@nfd@ \tl_to_str:n {#2} @ \tl_to_str:n {#3} } {#4}{#5}{#6}
+ }
+ {
+ \xpatch_main_three:Ncnnn \xpatch_apptocmd_once:Nnnn
+ { abx@nfd@ \tl_to_str:n {#2} @ \tl_to_str:n {#3} } {#4}{#5}{#6}
+ }
+ }
+\NewDocumentCommand{\xpatchnameformat} { s O{*} +m +m +m +m +m }
+ {
+ \IfBooleanTF{#1}
+ {
+ \xpatch_main_four:Ncnnnn \xpatch_patchcmd_all:Nnnnn
+ { abx@nfd@ \tl_to_str:n {#2} @ \tl_to_str:n {#3} } {#4}{#5}{#6}{#7}
+ }
+ {
+ \xpatch_main_four:Ncnnnn \xpatch_patchcmd_once:Nnnnn
+ { abx@nfd@ \tl_to_str:n {#2} @ \tl_to_str:n {#3} } {#4}{#5}{#6}{#7}
+ }
+ }
+\NewDocumentCommand{\regexpatchnameformat} { s O{*} +m +m +m +m +m }
+ {
+ \IfBooleanTF{#1}
+ {
+ \xpatch_main_four:Ncnnnn \xpatch_regexpatchcmd_all:Nnnnn
+ { abx@nfd@ \tl_to_str:n {#2} @ \tl_to_str:n {#3} } {#4}{#5}{#6}{#7}
+ }
+ {
+ \xpatch_main_four:Ncnnnn \xpatch_regexpatchcmd_once:Nnnnn
+ { abx@nfd@ \tl_to_str:n {#2} @ \tl_to_str:n {#3} } {#4}{#5}{#6}{#7}
+ }
+ }
+
+\NewDocumentCommand{\xshowlistformat} { s O{*} +m }
+ {
+ \IfBooleanT{#1}
+ {
+ \group_begin:
+ \bool_set_true:N \l_xpatch_tracing_bool
+ }
+ \xpatch_main_zero:Nc \cs_show:N { abx@lfd@ \tl_to_str:n {#1} @ \tl_to_str:n {#2} }
+ \IfBooleanT{#1}
+ {
+ \group_end:
+ }
+ }
+\NewDocumentCommand{\xpretolistformat} { s O{*} +m +m +m +m }
+ {
+ \IfBooleanTF{#1}
+ {
+ \xpatch_main_three:Ncnnn \xpatch_pretocmd_all:Nnnn
+ { abx@lfd@ \tl_to_str:n {#2} @ \tl_to_str:n {#3} } {#4}{#5}{#6}
+ }
+ {
+ \xpatch_main_three:Ncnnn \xpatch_pretocmd_once:Nnnn
+ { abx@lfd@ \tl_to_str:n {#2} @ \tl_to_str:n {#3} } {#4}{#5}{#6}
+ }
+ }
+\NewDocumentCommand{\xapptolistformat} { s O{*} +m +m +m +m }
+ {
+ \IfBooleanTF{#1}
+ {
+ \xpatch_main_three:Ncnnn \xpatch_apptocmd_all:Nnnn
+ { abx@lfd@ \tl_to_str:n {#2} @ \tl_to_str:n {#3} } {#4}{#5}{#6}
+ }
+ {
+ \xpatch_main_three:Ncnnn \xpatch_apptocmd_once:Nnnn
+ { abx@lfd@ \tl_to_str:n {#2} @ \tl_to_str:n {#3} } {#4}{#5}{#6}
+ }
+ }
+\NewDocumentCommand{\xpatchlistformat} { s O{*} +m +m +m +m +m }
+ {
+ \IfBooleanTF{#1}
+ {
+ \xpatch_main_four:Ncnnnn \xpatch_patchcmd_all:Nnnnn
+ { abx@lfd@ \tl_to_str:n {#2} @ \tl_to_str:n {#3} } {#4}{#5}{#6}{#7}
+ }
+ {
+ \xpatch_main_four:Ncnnnn \xpatch_patchcmd_once:Nnnnn
+ { abx@lfd@ \tl_to_str:n {#2} @ \tl_to_str:n {#3} } {#4}{#5}{#6}{#7}
+ }
+ }
+\NewDocumentCommand{\regexpatchlistformat} { s O{*} +m +m +m +m +m }
+ {
+ \IfBooleanTF{#1}
+ {
+ \xpatch_main_four:Ncnnnn \xpatch_regexpatchcmd_all:Nnnnn
+ { abx@lfd@ \tl_to_str:n {#2} @ \tl_to_str:n {#3} } {#4}{#5}{#6}{#7}
+ }
+ {
+ \xpatch_main_four:Ncnnnn \xpatch_regexpatchcmd_once:Nnnnn
+ { abx@lfd@ \tl_to_str:n {#2} @ \tl_to_str:n {#3} } {#4}{#5}{#6}{#7}
+ }
+ }
+
+\NewDocumentCommand{\xshowindexfieldformat} { s O{*} +m }
+ {
+ \IfBooleanT{#1}
+ {
+ \group_begin:
+ \bool_set_true:N \l_xpatch_tracing_bool
+ }
+ \xpatch_main_zero:Nc \cs_show:N { abx@fid@ \tl_to_str:n {#1} @ \tl_to_str:n {#2} }
+ \IfBooleanT{#1}
+ {
+ \group_end:
+ }
+ }
+\NewDocumentCommand{\xpretoindexfieldformat} { s O{*} +m +m +m +m }
+ {
+ \IfBooleanTF{#1}
+ {
+ \xpatch_main_three:Ncnnn \xpatch_pretocmd_all:Nnnn
+ { abx@fid@ \tl_to_str:n {#2} @ \tl_to_str:n {#3} } {#4}{#5}{#6}
+ }
+ {
+ \xpatch_main_three:Ncnnn \xpatch_pretocmd_once:Nnnn
+ { abx@fid@ \tl_to_str:n {#2} @ \tl_to_str:n {#3} } {#4}{#5}{#6}
+ }
+ }
+\NewDocumentCommand{\xapptoindexfieldformat} { s O{*} +m +m +m +m }
+ {
+ \IfBooleanTF{#1}
+ {
+ \xpatch_main_three:Ncnnn \xpatch_apptocmd_all:Nnnn
+ { abx@fid@ \tl_to_str:n {#2} @ \tl_to_str:n {#3} } {#4}{#5}{#6}
+ }
+ {
+ \xpatch_main_three:Ncnnn \xpatch_apptocmd_once:Nnnn
+ { abx@fid@ \tl_to_str:n {#2} @ \tl_to_str:n {#3} } {#4}{#5}{#6}
+ }
+ }
+\NewDocumentCommand{\xpatchindexfieldformat} { s O{*} +m +m +m +m +m }
+ {
+ \IfBooleanTF{#1}
+ {
+ \xpatch_main_four:Ncnnnn \xpatch_patchcmd_all:Nnnnn
+ { abx@fid@ \tl_to_str:n {#2} @ \tl_to_str:n {#3} } {#4}{#5}{#6}{#7}
+ }
+ {
+ \xpatch_main_four:Ncnnnn \xpatch_patchcmd_once:Nnnnn
+ { abx@fid@ \tl_to_str:n {#2} @ \tl_to_str:n {#3} } {#4}{#5}{#6}{#7}
+ }
+ }
+\NewDocumentCommand{\regexpatchindexfieldformat} { s O{*} +m +m +m +m +m }
+ {
+ \IfBooleanTF{#1}
+ {
+ \xpatch_main_four:Ncnnnn \xpatch_regexpatchcmd_all:Nnnnn
+ { abx@fid@ \tl_to_str:n {#2} @ \tl_to_str:n {#3} } {#4}{#5}{#6}{#7}
+ }
+ {
+ \xpatch_main_four:Ncnnnn \xpatch_regexpatchcmd_once:Nnnnn
+ { abx@fid@ \tl_to_str:n {#2} @ \tl_to_str:n {#3} } {#4}{#5}{#6}{#7}
+ }
+ }
+
+\NewDocumentCommand{\xshowindexnameformat} { s O{*} +m }
+ {
+ \IfBooleanT{#1}
+ {
+ \group_begin:
+ \bool_set_true:N \l_xpatch_tracing_bool
+ }
+ \xpatch_main_zero:Nc \cs_show:N { abx@nid@ \tl_to_str:n {#1} @ \tl_to_str:n {#2} }
+ \IfBooleanT{#1}
+ {
+ \group_end:
+ }
+ }
+\NewDocumentCommand{\xpretoindexnameformat} { s O{*} +m +m +m +m }
+ {
+ \IfBooleanTF{#1}
+ {
+ \xpatch_main_three:Ncnnn \xpatch_pretocmd_all:Nnnn
+ { abx@nid@ \tl_to_str:n {#2} @ \tl_to_str:n {#3} } {#4}{#5}{#6}
+ }
+ {
+ \xpatch_main_three:Ncnnn \xpatch_pretocmd_once:Nnnn
+ { abx@nid@ \tl_to_str:n {#2} @ \tl_to_str:n {#3} } {#4}{#5}{#6}
+ }
+ }
+\NewDocumentCommand{\xapptoindexnameformat} { s O{*} +m +m +m +m }
+ {
+ \IfBooleanTF{#1}
+ {
+ \xpatch_main_three:Ncnnn \xpatch_apptocmd_all:Nnnn
+ { abx@nid@ \tl_to_str:n {#2} @ \tl_to_str:n {#3} } {#4}{#5}{#6}
+ }
+ {
+ \xpatch_main_three:Ncnnn \xpatch_apptocmd_once:Nnnn
+ { abx@nid@ \tl_to_str:n {#2} @ \tl_to_str:n {#3} } {#4}{#5}{#6}
+ }
+ }
+\NewDocumentCommand{\xpatchindexnameformat} { s O{*} +m +m +m +m +m }
+ {
+ \IfBooleanTF{#1}
+ {
+ \xpatch_main_four:Ncnnnn \xpatch_patchcmd_all:Nnnnn
+ { abx@nid@ \tl_to_str:n {#2} @ \tl_to_str:n {#3} } {#4}{#5}{#6}{#7}
+ }
+ {
+ \xpatch_main_four:Ncnnnn \xpatch_patchcmd_once:Nnnnn
+ { abx@nid@ \tl_to_str:n {#2} @ \tl_to_str:n {#3} } {#4}{#5}{#6}{#7}
+ }
+ }
+\NewDocumentCommand{\regexpatchindexnameformat} { s O{*} +m +m +m +m +m }
+ {
+ \IfBooleanTF{#1}
+ {
+ \xpatch_main_four:Ncnnnn \xpatch_regexpatchcmd_all:Nnnnn
+ { abx@nid@ \tl_to_str:n {#2} @ \tl_to_str:n {#3} } {#4}{#5}{#6}{#7}
+ }
+ {
+ \xpatch_main_four:Ncnnnn \xpatch_regexpatchcmd_once:Nnnnn
+ { abx@nid@ \tl_to_str:n {#2} @ \tl_to_str:n {#3} } {#4}{#5}{#6}{#7}
+ }
+ }
+
+\NewDocumentCommand{\xshowindexlistformat} { s O{*} +m }
+ {
+ \IfBooleanT{#1}
+ {
+ \group_begin:
+ \bool_set_true:N \l_xpatch_tracing_bool
+ }
+ \xpatch_main_zero:Nc \cs_show:N { abx@lid@ \tl_to_str:n {#1} @ \tl_to_str:n {#2} }
+ \IfBooleanT{#1}
+ {
+ \group_end:
+ }
+ }
+\NewDocumentCommand{\xpretoindexlistformat} { s O{*} +m +m +m +m }
+ {
+ \IfBooleanTF{#1}
+ {
+ \xpatch_main_three:Ncnnn \xpatch_pretocmd_all:Nnnn
+ { abx@lid@ \tl_to_str:n {#2} @ \tl_to_str:n {#3} } {#4}{#5}{#6}
+ }
+ {
+ \xpatch_main_three:Ncnnn \xpatch_pretocmd_once:Nnnn
+ { abx@lid@ \tl_to_str:n {#2} @ \tl_to_str:n {#3} } {#4}{#5}{#6}
+ }
+ }
+\NewDocumentCommand{\xapptoindexlistformat} { s O{*} +m +m +m +m }
+ {
+ \IfBooleanTF{#1}
+ {
+ \xpatch_main_three:Ncnnn \xpatch_apptocmd_all:Nnnn
+ { abx@lid@ \tl_to_str:n {#2} @ \tl_to_str:n {#3} } {#4}{#5}{#6}
+ }
+ {
+ \xpatch_main_three:Ncnnn \xpatch_apptocmd_once:Nnnn
+ { abx@lid@ \tl_to_str:n {#2} @ \tl_to_str:n {#3} } {#4}{#5}{#6}
+ }
+ }
+\NewDocumentCommand{\xpatchindexlistformat} { s O{*} +m +m +m +m +m }
+ {
+ \IfBooleanTF{#1}
+ {
+ \xpatch_main_four:Ncnnnn \xpatch_patchcmd_all:Nnnnn
+ { abx@lid@ \tl_to_str:n {#2} @ \tl_to_str:n {#3} } {#4}{#5}{#6}{#7}
+ }
+ {
+ \xpatch_main_four:Ncnnnn \xpatch_patchcmd_once:Nnnnn
+ { abx@lid@ \tl_to_str:n {#2} @ \tl_to_str:n {#3} } {#4}{#5}{#6}{#7}
+ }
+ }
+\NewDocumentCommand{\regexpatchindexlistformat} { s O{*} +m +m +m +m +m }
+ {
+ \IfBooleanTF{#1}
+ {
+ \xpatch_main_four:Ncnnnn \xpatch_regexpatchcmd_all:Nnnnn
+ { abx@lid@ \tl_to_str:n {#2} @ \tl_to_str:n {#3} } {#4}{#5}{#6}{#7}
+ }
+ {
+ \xpatch_main_four:Ncnnnn \xpatch_regexpatchcmd_once:Nnnnn
+ { abx@lid@ \tl_to_str:n {#2} @ \tl_to_str:n {#3} } {#4}{#5}{#6}{#7}
+ }
+ }
% \end{macrocode}
% A macro to check if the macro is patchable. It just prints a message
% on the terminal and in the log file.
% \begin{macrocode}
-\NewDocumentCommand{\checkpatchable}{ m }
- {
- \group_begin:
- \bool_set_true:N \l_xpatch_tracing_bool
- \xpatch_check_patchable:N #1
- \group_end:
- }
+\NewDocumentCommand{\checkpatchable}{ +m }
+ {
+ \group_begin:
+ \bool_set_true:N \l_xpatch_tracing_bool
+ \xpatch_check_patchable:N #1
+ \group_end:
+ }
% \end{macrocode}
% The last user level command: a macro for changing the optional
% argument in a macro that has one.
% \begin{macrocode}
\cs_generate_variant:Nn \xpatch_get_all:N {c}
\cs_generate_variant:Nn \xpatch_rebuild:N {c}
-\NewDocumentCommand{\xpatchoptarg}{ m m }
- {
- \xpatch_main_check:N #1
- \bool_if:NTF \l_xpatch_optional_bool
- {
+\NewDocumentCommand{\xpatchoptarg}{ +m +m }
+ {
+ \xpatch_main_check:N #1
+ \bool_if:NTF \l_xpatch_optional_bool
+ {
% \end{macrocode}
% We have a macro with optional argument; so we strip off
% the first backslash from the name and proceed.
% \begin{macrocode}
- \tl_set:Nx \l_xpatch_name_tl { \tl_tail:V \l_xpatch_name_tl }
+ \tl_set:Nx \l_xpatch_name_tl { \tl_tail:V \l_xpatch_name_tl }
% \end{macrocode}
% Gather the prefix (it is |\protected| when |#1| has been defined
% with |\newrobustcmd|).
% \begin{macrocode}
- \tl_set:Nf \l_xpatch_prefix_tl { \token_get_prefix_spec:N #1 }
- \tl_clear:N \l_xpatch_prefix_tl
- \tl_set_rescan:Nnx \l_xpatch_prefix_tl { } \l_xpatch_prefix_tl
+ \tl_set:Nf \l_xpatch_prefix_tl { \token_get_prefix_spec:N #1 }
+ \tl_clear:N \l_xpatch_prefix_tl
+ \tl_set_rescan:Nnx \l_xpatch_prefix_tl { } \l_xpatch_prefix_tl
% \end{macrocode}
% Get the replacement text in tokenized form: the control sequences
% have spaces in their names, so we can't rely on
% |\token_get_replacement_spec:N| because the spaces would be lost.
% \begin{macrocode}
- \tl_set_eq:Nc \l_xpatch_replacement_tl { \l_xpatch_name_tl }
+ \tl_set_eq:Nc \l_xpatch_replacement_tl { \l_xpatch_name_tl }
% \end{macrocode}
% Now we have to change the last item in the token list: we just store
% the new optional argument in a token list variable and do a regex
@@ -1187,55 +1659,56 @@
% of control sequences, an open brace, the optional argument and a
% closed brace, so we anchor at the end of the token list.
% \begin{macrocode}
- \tl_set:Nn \l_tmpa_tl { { #2 } }
- \regex_replace_once:nnN { \cB. .* \cE. \Z} { \u{l_tmpa_tl} }
- \l_xpatch_replacement_tl
+ \tl_set:Nn \l_tmpa_tl { { #2 } }
+ \regex_replace_once:nnN { \cB. .* \cE. \Z} { \u{l_tmpa_tl} }
+ \l_xpatch_replacement_tl
% \end{macrocode}
% Now we rebuild the control sequence.
% \begin{macrocode}
- \xpatch_rebuild:c { \l_xpatch_name_tl }
- }
+ \xpatch_rebuild:c { \l_xpatch_name_tl }
+ }
% \end{macrocode}
% If the macro hasn't an optional argument we issue a message.
% \begin{macrocode}
+ {
+ \group_begin:
+ \bool_set_true:N \l_xpatch_tracing_bool
+ \xpatch_message:n
{
- \group_begin:
- \bool_set_true:N \l_xpatch_tracing_bool
- \xpatch_message:n
- {
- Macro~`\token_to_str:N #1'~ has~no~optional~argument~
- or~it~has~been~defined~with~`xparse'~and~operating~
- on~such~commands~is~(still)~not~supported
- }
- \group_end:
+ Macro~`\token_to_str:N #1'~ has~no~optional~argument~
+ or~it~has~been~defined~with~`xparse'~and~operating~
+ on~such~commands~is~(still)~not~supported
}
- }
+ \group_end:
+ }
+ }
% \end{macrocode}
% Just one more thing: enabling or disabling the tracing system.
% \begin{macrocode}
\NewDocumentCommand{\tracingxpatches}{ O{1} }
- {
- \int_compare:nTF { #1 > 0 }
- { \bool_set_true:N \l_xpatch_tracing_bool }
- { \bool_set_false:N \l_xpatch_tracing_bool }
- }
+ {
+ \int_compare:nTF { #1 > 0 }
+ { \bool_set_true:N \l_xpatch_tracing_bool }
+ { \bool_set_false:N \l_xpatch_tracing_bool }
+ }
% \end{macrocode}
% One more thing: patching the parameter text!
% \begin{macrocode}
-\NewDocumentCommand{\xpatchparametertext}{m m m m m}
- {
- \xpatch_check_patchable:N #1
- \bool_if:NTF \l_xpatch_patchable_bool
- {
- \regex_replace_once:nnN { #2 } { #3 } \l_xpatch_arg_tl
- \xpatch_rebuild:N #1
- #4
- }
- {
- #5
- }
- }
+\NewDocumentCommand{\xpatchparametertext}{ +m +m +m +m +m }
+ {
+ \xpatch_check_patchable:N #1
+ \bool_if:NTF \l_xpatch_patchable_bool
+ {
+ \regex_replace_once:nnN { #2 } { #3 } \l_xpatch_arg_tl
+ \xpatch_rebuild:N #1
+ #4
+ }
+ {
+ #5
+ }
+ }
% \end{macrocode}
+%
% \iffalse
%</package>
% \fi
diff --git a/Master/texmf-dist/source/latex/regexpatch/regexpatch.ins b/Master/texmf-dist/source/latex/regexpatch/regexpatch.ins
index 8e8f3e675cf..ef0e52ac236 100644
--- a/Master/texmf-dist/source/latex/regexpatch/regexpatch.ins
+++ b/Master/texmf-dist/source/latex/regexpatch/regexpatch.ins
@@ -1,6 +1,6 @@
\iffalse meta-comment
-File regexpatch.ins Copyright (C) 2012 Enrico Gregorio
+File regexpatch.ins Copyright (C) 2012-2013 Enrico Gregorio
It may be distributed and/or modified under the conditions of the
LaTeX Project Public License (LPPL), either version 1.3c of this