diff options
author | Manuel Pégourié-Gonnard <mpg@elzevir.fr> | 2012-10-06 09:27:44 +0000 |
---|---|---|
committer | Manuel Pégourié-Gonnard <mpg@elzevir.fr> | 2012-10-06 09:27:44 +0000 |
commit | a9a23194b1cababcf9c24e48937a726cb465813a (patch) | |
tree | 23ec90526b8b1c9274216923e7494de498e159b1 /Master | |
parent | 2642cb8f94a8070118c06133cdd27f50abb894a2 (diff) |
xpatch update
git-svn-id: svn://tug.org/texlive/trunk@27897 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rw-r--r-- | Master/texmf-dist/doc/latex/xpatch/README | 11 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/xpatch/xpatch.pdf | bin | 433354 -> 450940 bytes | |||
-rw-r--r-- | Master/texmf-dist/source/latex/xpatch/xpatch.dtx | 299 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/xpatch/xpatch.sty | 140 |
4 files changed, 335 insertions, 115 deletions
diff --git a/Master/texmf-dist/doc/latex/xpatch/README b/Master/texmf-dist/doc/latex/xpatch/README index b1d86ddb2c5..e228ead5ccf 100644 --- a/Master/texmf-dist/doc/latex/xpatch/README +++ b/Master/texmf-dist/doc/latex/xpatch/README @@ -1,13 +1,12 @@ The xpatch package generalizes the macro patching commands provided by P. Lehmann's `etoolbox'. -This is version 0.2 of the package +This is version 0.3 of the package Changes from version 0.2 -o Added \...bibdriver macros for patching macros defined with - \DeclareBibliographyDriver -o Fixed a bug for control symbols defined with \newcommand - and an optional argument. +o Added \xpatch...format, \xpreto...format and \xappto...format macros + for patching internal biblatex macros defined \Declare...Format + (under kind request by Audrey Boruvka) Copyright 2012 Enrico Gregorio @@ -41,5 +40,5 @@ o move "xpatch.sty" to locations where LaTeX will find it (the FAQ on CTAN in /help/uktug-FAQ gives more information about this magic place -2012/01/23 +2012/10/02 Enrico Gregorio diff --git a/Master/texmf-dist/doc/latex/xpatch/xpatch.pdf b/Master/texmf-dist/doc/latex/xpatch/xpatch.pdf Binary files differindex 559f5d05203..f84680cc4f4 100644 --- a/Master/texmf-dist/doc/latex/xpatch/xpatch.pdf +++ b/Master/texmf-dist/doc/latex/xpatch/xpatch.pdf diff --git a/Master/texmf-dist/source/latex/xpatch/xpatch.dtx b/Master/texmf-dist/source/latex/xpatch/xpatch.dtx index 4f2d2e22f32..f901c32048b 100644 --- a/Master/texmf-dist/source/latex/xpatch/xpatch.dtx +++ b/Master/texmf-dist/source/latex/xpatch/xpatch.dtx @@ -24,7 +24,7 @@ \usepackage{bookmark} %</driver> %<*driver|package> -\GetIdInfo$Id: xpatch.dtx 0.2 2012-01-23 12:00:00Z Enrico $ +\GetIdInfo$Id: xpatch.dtx 0.3 2012-10-02 12:00:00Z Enrico $ {Extending etoolbox patching commands} %</driver|package> %<*driver> @@ -33,6 +33,9 @@ \end{document} %</driver> % \fi +% \changes{v0.2}{2012/01/13}{Added \texttt{\char`\\x...bibdriver} macros; fixed a bug for +% control symbols defined with \texttt{\char`\\newcommand} and an optional argument.} +% \changes{v0.3}{2012/10/01}{Added a bunch of biblatex related commands} % % \title{^^A % The \textsf{xpatch} package\\ Extending \textsf{etoolbox} patching @@ -68,7 +71,7 @@ % cannot be used to modify the workings of |\xyz|. The same happens % when a command has been defined with |\DeclareRobustCommand|. % -% The reason for this is \TeX{}nichal or, better, \LaTeX{}nichal. When +% The reason for this is \TeX{}nical or, better, \LaTeX{}nical. When % \LaTeX{} performs the above definition, the expansion of |\xyz| will % be %\begin{verbatim} @@ -132,14 +135,14 @@ %\begin{verbatim} % \expandafter\patchcmd\csname\string\xyz\space\endcsname{!}{-}{}{} %\end{verbatim} -% It's hard and error prone to remember all of these tricks, so this +% It's hard and error prone to remember all these tricks, so this % package comes to the rescue. % % \subsection*{Caveat} -% This package is still in a preliminary version, but relevant changes -% to the interface should not be introduced in later versions. A -% ``verbose'' mode is under testing, which will provide at request -% more information about the nature of the command to be patched. +% This package is still in a preliminary version, but no relevant +% changes to the interface should be introduced in later versions. A +% different and more powerful implementation is under testing, see the +% package \pkg{regexpatch}. % % % \section{Commands} @@ -217,25 +220,55 @@ % could use, for patching the driver |foo|, %\begin{verbatim} % \makeatletter -% \patchcmd{\blx@bbx@foo}{X}{Y}{success}{failure} +% \patchcmd{\blx@bbx@foo}{X}{Y}{<success>}{<failure>} % \preto{\blx@bbx@foo}{P} % \appto{\blx@bbx@foo}{A} % \makeatother %\end{verbatim} % but having a lighter interface can be handy. Since our macros use % |\pretocmd| and |\apptocmd| for consistency, remember to always use -% the |{success}| and |{failure}| arguments also with +% the \marg{success} and \marg{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| % \end{itemize} % that are the analog of |\show| to see the ``real'' definition of a % macro, be it defined with optional arguments or as a robust command; -% the |bib| ones are for the corresponding \pkg{biblatex} macros. +% the |\xshowbib...| and |\xshow...format| ones are for the +% corresponding \pkg{biblatex} macros. The last six have an optional +% first argument (default value |*|). % % % \section{Using the original commands} @@ -273,25 +306,73 @@ % \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}\\ +% |\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}\\ +% |\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|\marg{command}\\ % |\xshowbibname|\marg{name}\\ -% |\xshowbibdriver|\marg{name} +% |\xshowbibdriver|\marg{name}\\ +% |\xshowfieldformat|\oarg{entrytype}\marg{name}\\ +% |\xshownameformat|\oarg{entrytype}\marg{name}\\ +% |\xshowlistformat|\oarg{entrytype}\marg{name}\\ +% |\xshowindexfieldformat|\oarg{entrytype}\marg{name}\\ +% |\xshowindexnameformat|\oarg{entrytype}\marg{name}\\ +% |\xshowindexlistformat|\oarg{entrytype}\marg{name} % % \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 |*|. % % It's important to remember that patching commands that have -% |@|-commands in their replacement text must always be performed -% between |\makeatletter| and |\makeatother|. +% |@|-commands in their name or replacement text must always be +% performed between |\makeatletter| and |\makeatother|. % % \section{Limitations and warnings} % @@ -307,7 +388,7 @@ % if |\xyz| had been defined with an optional argument. For such % things it's better to use |\xpatchcmd| and friends or employ the % \pkg{letltxmacro} package by H.~Oberdiek, that provides -% |\LetLtxMacro| for purposes like this. +% |\LetLtxMacro| for purposes like this one. % % Although this package has been written with the experimental \LaTeX3 % macros, the commands \emph{can't} be used to patch commands defined @@ -324,8 +405,10 @@ % % \begin{itemize} % \item[Version 0.1] First public release. -% \item[Version 0.2] Added |\...bibdriver| macros; fixed a bug for +% \item[Version 0.2] Added |\x...bibdriver| macros; fixed a bug for % control symbols defined with |\newcommand| and an optional argument. +% \item[Version 0.3] Added |\x...format| macros (by kind request of the +% \pkg{biblatex} maintainers). % \end{itemize} % % \end{documentation} @@ -373,7 +456,7 @@ % \end{macrocode} % A boolean for the testing of robust commands. % \begin{macrocode} -\bool_new:N \l_xpatch_protect_bool +\bool_new:N \l__xpatch_protect_bool % \end{macrocode} % The constant |\c_backslash_str| is defined in |l3str| that's not % loaded at the moment, so we save a bit of memory not loading it. @@ -384,9 +467,15 @@ % A ``bizarre'' token list that's quite improbable to find in the % replacement text of a macro. % \begin{macrocode} -\tl_const:Nx \c_xpatch_bizarre_tl +\tl_const:Nx \c__xpatch_bizarre_tl { \tl_to_str:n { **)-(**/**]-[** } } % \end{macrocode} +% Internal token lists for storing the various parts of the command to be +% patched. +% \begin{macrocode} +\tl_new:N \l__xpatch_name_tl +\tl_new:N \l__xpatch_repl_tl +% \end{macrocode} % % \subsection{The main functions} % @@ -406,16 +495,22 @@ % \newrobustcmd\4[1][]{4 (newrobustcmd-opt)} %\end{verbatim} % Then the first level expansions are, respectively, -%\begin{verbatim*} -%+\protect \xaa + -%+\protect \xab + -%+\@protected@testopt \xac \\xac {}+ -%+\@testopt \\xad {}+ -%+\x@protect \1\protect \1 + -%+\x@protect \2\protect \2 + -%+\@protected@testopt \3\\3 {}+ -%+\@testopt \\4 {}+ -%\end{verbatim*} +% \iffalse +%<*mock> +% \fi +\begin{verbatim*} ++\protect \xaa + ++\protect \xab + ++\@protected@testopt \xac \\xac {}+ ++\@testopt \\xad {}+ ++\x@protect \1\protect \1 + ++\x@protect \2\protect \2 + ++\@protected@testopt \3\\3 {}+ ++\@testopt \\4 {}+ +\end{verbatim*} +% \iffalse +%</mock> +% \fi % where the |+| is used to delimit the expansions and show the % spaces. Remember that |\show| always adds a space after a control % word, but not after a control symbol such as |\1|. However, in lines @@ -435,11 +530,11 @@ % \end{macrocode} % We initialize the boolean to false. % \begin{macrocode} - \bool_set_false:N \l_xpatch_protect_bool + \bool_set_false:N \l__xpatch_protect_bool % \end{macrocode} % First of all we store the command-to-patch name. % \begin{macrocode} - \tl_set:Nx \l_xpatch_name_tl { \cs_to_str:N #2 } + \tl_set:Nx \l__xpatch_name_tl { \cs_to_str:N #2 } % \end{macrocode} % We store the replacement text of the command-to-patch, but adding % the bizarre token list in front of it which consists of all category @@ -447,38 +542,38 @@ % beginning.\footnote{This part will be reimplemented as soon as % \pkg{l3regex} stabilizes.} % \begin{macrocode} - \tl_set:Nx \l_xpatch_repl_tl - { \c_xpatch_bizarre_tl \token_get_replacement_spec:N #2 } + \tl_set:Nx \l__xpatch_repl_tl + { \c__xpatch_bizarre_tl \token_get_replacement_spec:N #2 } % \end{macrocode} % We look whether the token list contains the bizarre list followed by % |\protect| and the same name (with two spaces) which happens if |#2| % is a control sequence defined by |\DeclareRobustCommand|, so we add % a space to the command name. % \begin{macrocode} - \tl_if_in:NxT \l_xpatch_repl_tl + \tl_if_in:NxT \l__xpatch_repl_tl { - \c_xpatch_bizarre_tl + \c__xpatch_bizarre_tl \token_to_str:N \protect \c_space_tl - \c_backslash_str \l_xpatch_name_tl \c_space_tl \c_space_tl + \c_backslash_str \l__xpatch_name_tl \c_space_tl \c_space_tl } { - \bool_set_true:N \l_xpatch_protect_bool - \tl_put_right:Nn \l_xpatch_name_tl { \c_space_tl } + \bool_set_true:N \l__xpatch_protect_bool + \tl_put_right:Nn \l__xpatch_name_tl { \c_space_tl } } % \end{macrocode} % We look whether the token list contains the bizarre list followed by % |\x@protect| which happens if |#2| is a control symbol defined by % |\DeclareRobustCommand|, so we add a space to the command name. % \begin{macrocode} - \tl_if_in:NxT \l_xpatch_repl_tl + \tl_if_in:NxT \l__xpatch_repl_tl { - \c_xpatch_bizarre_tl + \c__xpatch_bizarre_tl \token_to_str:N \x@protect \c_space_tl - \c_backslash_str \l_xpatch_name_tl \c_backslash_str + \c_backslash_str \l__xpatch_name_tl \c_backslash_str } { - \bool_set_true:N \l_xpatch_protect_bool - \tl_put_right:Nn \l_xpatch_name_tl { \c_space_tl } + \bool_set_true:N \l__xpatch_protect_bool + \tl_put_right:Nn \l__xpatch_name_tl { \c_space_tl } } % \end{macrocode} % In both the preceding cases we have to do another check, so we set a @@ -488,75 +583,76 @@ % |\@protected@testopt| which happens if |#2| is a control word with an % optional argument (from |\newcommand|). % \begin{macrocode} - \tl_if_in:NxT \l_xpatch_repl_tl + \tl_if_in:NxT \l__xpatch_repl_tl { - \c_xpatch_bizarre_tl + \c__xpatch_bizarre_tl \token_to_str:N \@protected@testopt \c_space_tl - \c_backslash_str \l_xpatch_name_tl + \c_backslash_str \l__xpatch_name_tl \c_space_tl \c_backslash_str \c_backslash_str } { - \tl_put_left:Nn \l_xpatch_name_tl { \c_backslash_str } + \tl_put_left:Nn \l__xpatch_name_tl { \c_backslash_str } } +% \end{macrocode} % We look whether the token list contains the bizarre list followed by % |\@protected@testopt| which happens if |#2| is a control symbol with an % optional argument (from |\newcommand|). % \begin{macrocode} - \tl_if_in:NxT \l_xpatch_repl_tl + \tl_if_in:NxT \l__xpatch_repl_tl { - \c_xpatch_bizarre_tl + \c__xpatch_bizarre_tl \token_to_str:N \@protected@testopt \c_space_tl - \c_backslash_str \l_xpatch_name_tl + \c_backslash_str \l__xpatch_name_tl \c_backslash_str \c_backslash_str } { - \tl_put_left:Nn \l_xpatch_name_tl { \c_backslash_str } + \tl_put_left:Nn \l__xpatch_name_tl { \c_backslash_str } } % \end{macrocode} % We look whether the token list contains the bizarre list followed by % |\@testopt| which happens if |#2| is a command with an optional % argument (from |\newrobustcmd|). % \begin{macrocode} - \tl_if_in:NxT \l_xpatch_repl_tl + \tl_if_in:NxT \l__xpatch_repl_tl { - \c_xpatch_bizarre_tl + \c__xpatch_bizarre_tl \token_to_str:N \@testopt \c_space_tl - \c_backslash_str \c_backslash_str \l_xpatch_name_tl + \c_backslash_str \c_backslash_str \l__xpatch_name_tl } { - \tl_put_left:Nn \l_xpatch_name_tl { \c_backslash_str } + \tl_put_left:Nn \l__xpatch_name_tl { \c_backslash_str } } % \end{macrocode} % In both the preceding cases, we add a backslash in front of the % command's name. % % If the command-to-patch was defined by |\DeclareRobustCommand| we -% have to do another test, to check whether it has an optional -% argument and, in this case, we add a backslash in front of the name. +% have to do another test, namely checking whether it has an optional +% argument and, in this case, adding a backslash in front of the name. % We replicate the test for |\@protected@testopt|. % \begin{macrocode} - \bool_if:NT \l_xpatch_protect_bool + \bool_if:NT \l__xpatch_protect_bool { - \tl_set:Nx \l_xpatch_repl_tl - { \c_xpatch_bizarre_tl + \tl_set:Nx \l__xpatch_repl_tl + { \c__xpatch_bizarre_tl \exp_after:wN \token_get_replacement_spec:N - \cs:w \l_xpatch_name_tl \cs_end: } - \tl_if_in:NxT \l_xpatch_repl_tl + \cs:w \l__xpatch_name_tl \cs_end: } + \tl_if_in:NxT \l__xpatch_repl_tl { - \c_xpatch_bizarre_tl + \c__xpatch_bizarre_tl \token_to_str:N \@protected@testopt \c_space_tl - \c_backslash_str \l_xpatch_name_tl + \c_backslash_str \l__xpatch_name_tl \c_space_tl \c_backslash_str \c_backslash_str } { - \tl_put_left:Nn \l_xpatch_name_tl { \c_backslash_str } + \tl_put_left:Nn \l__xpatch_name_tl { \c_backslash_str } } } % \end{macrocode} % Finally, we pass the real command-to-patch name to the patching % macro. % \begin{macrocode} - \exp_after:wN #1 \cs:w \l_xpatch_name_tl \cs_end: + \exp_after:wN #1 \cs:w \l__xpatch_name_tl \cs_end: % \end{macrocode} % That's the last operation! % \begin{macrocode} @@ -594,6 +690,76 @@ \NewDocumentCommand{\xshowbibmacro} { m } { \xpatch_main:Nc \show { abx@macro@ \tl_to_str:n {#1} } } % \end{macrocode} +% +% The macros for patching commands defined with |\DeclareFieldFormat|; +% all that holds for the preceding commands is valid also for the +% following groups of similar commands. +% \begin{macrocode} +\NewDocumentCommand{\xpatchfieldformat} { O{*} m } + { \xpatch_main:Nc \patchcmd { abx@ffd@ \tl_to_str:n {#1} @ \tl_to_str:n {#2} } } +\NewDocumentCommand{\xpretofieldformat} { O{*} m } + { \xpatch_main:Nc \pretocmd { abx@ffd@ \tl_to_str:n {#1} @ \tl_to_str:n {#2} } } +\NewDocumentCommand{\xapptofieldformat} { O{*} m } + { \xpatch_main:Nc \apptocmd { abx@ffd@ \tl_to_str:n {#1} @ \tl_to_str:n {#2} } } +\NewDocumentCommand{\xshowfieldformat} { O{*} m } + { \xpatch_main:Nc \show { abx@ffd@ \tl_to_str:n {#1} @ \tl_to_str:n {#2} } } +% \end{macrocode} +% |\DeclareNameFormat|: +% \begin{macrocode} +\NewDocumentCommand{\xpatchnameformat} { O{*} m } + { \xpatch_main:Nc \patchcmd { abx@nfd@ \tl_to_str:n {#1} @ \tl_to_str:n {#2} } } +\NewDocumentCommand{\xpretonameformat} { O{*} m } + { \xpatch_main:Nc \pretocmd { abx@nfd@ \tl_to_str:n {#1} @ \tl_to_str:n {#2} } } +\NewDocumentCommand{\xapptonameformat} { O{*} m } + { \xpatch_main:Nc \apptocmd { abx@nfd@ \tl_to_str:n {#1} @ \tl_to_str:n {#2} } } +\NewDocumentCommand{\xshownameformat} { O{*} m } + { \xpatch_main:Nc \show { abx@ffd@ \tl_to_str:n {#1} @ \tl_to_str:n {#2} } } +% \end{macrocode} +% |\DeclareListFormat|: +% \begin{macrocode} +\NewDocumentCommand{\xpatchlistformat} { O{*} m } + { \xpatch_main:Nc \patchcmd { abx@lfd@ \tl_to_str:n {#1} @ \tl_to_str:n {#2} } } +\NewDocumentCommand{\xpretolistformat} { O{*} m } + { \xpatch_main:Nc \pretocmd { abx@lfd@ \tl_to_str:n {#1} @ \tl_to_str:n {#2} } } +\NewDocumentCommand{\xapptolistformat} { O{*} m } + { \xpatch_main:Nc \apptocmd { abx@lfd@ \tl_to_str:n {#1} @ \tl_to_str:n {#2} } } +\NewDocumentCommand{\xshowlistformat} { O{*} m } + { \xpatch_main:Nc \show { abx@lfd@ \tl_to_str:n {#1} @ \tl_to_str:n {#2} } } +% \end{macrocode} +% |\DeclareIndexFieldFormat|; +% \begin{macrocode} +\NewDocumentCommand{\xpatchindexfieldformat} { O{*} m } + { \xpatch_main:Nc \patchcmd { abx@fid@ \tl_to_str:n {#1} @ \tl_to_str:n {#2} } } +\NewDocumentCommand{\xpretoindexfieldformat} { O{*} m } + { \xpatch_main:Nc \pretocmd { abx@fid@ \tl_to_str:n {#1} @ \tl_to_str:n {#2} } } +\NewDocumentCommand{\xapptoindexfieldformat} { O{*} m } + { \xpatch_main:Nc \apptocmd { abx@fid@ \tl_to_str:n {#1} @ \tl_to_str:n {#2} } } +\NewDocumentCommand{\xshowindexfieldformat} { O{*} m } + { \xpatch_main:Nc \show { abx@fid@ \tl_to_str:n {#1} @ \tl_to_str:n {#2} } } +% \end{macrocode} +% |\DeclareIndexNameFormat|: +% \begin{macrocode} +\NewDocumentCommand{\xpatchindexnameformat} { O{*} m } + { \xpatch_main:Nc \patchcmd { abx@nid@ \tl_to_str:n {#1} @ \tl_to_str:n {#2} } } +\NewDocumentCommand{\xpretoindexnameformat} { O{*} m } + { \xpatch_main:Nc \pretocmd { abx@nid@ \tl_to_str:n {#1} @ \tl_to_str:n {#2} } } +\NewDocumentCommand{\xapptoindexnameformat} { O{*} m } + { \xpatch_main:Nc \apptocmd { abx@nid@ \tl_to_str:n {#1} @ \tl_to_str:n {#2} } } +\NewDocumentCommand{\xshowindexnameformat} { O{*} m } + { \xpatch_main:Nc \show { abx@nid@ \tl_to_str:n {#1} @ \tl_to_str:n {#2} } } +% \end{macrocode} +% |\DeclareIndexListFormat|: +% \begin{macrocode} +\NewDocumentCommand{\xpatchindexlistformat} { O{*} m } + { \xpatch_main:Nc \patchcmd { abx@lid@ \tl_to_str:n {#1} @ \tl_to_str:n {#2} } } +\NewDocumentCommand{\xpretoindexlistformat} { O{*} m } + { \xpatch_main:Nc \pretocmd { abx@lid@ \tl_to_str:n {#1} @ \tl_to_str:n {#2} } } +\NewDocumentCommand{\xappindextolistformat} { O{*} m } + { \xpatch_main:Nc \apptocmd { abx@lid@ \tl_to_str:n {#1} @ \tl_to_str:n {#2} } } +\NewDocumentCommand{\xshowindexlistformat} { O{*} m } + { \xpatch_main:Nc \show { abx@lid@ \tl_to_str:n {#1} @ \tl_to_str:n {#2} } } +% \end{macrocode} +% % Finally, the patching macros for \pkg{biblatex} drivers that don't % need the overhead of |\xpatch_main:NN|. % \begin{macrocode} @@ -612,3 +778,4 @@ % \end{implementation} % % \PrintIndex +% \PrintChanges
\ No newline at end of file diff --git a/Master/texmf-dist/tex/latex/xpatch/xpatch.sty b/Master/texmf-dist/tex/latex/xpatch/xpatch.sty index b26de40e4df..818e802ef43 100644 --- a/Master/texmf-dist/tex/latex/xpatch/xpatch.sty +++ b/Master/texmf-dist/tex/latex/xpatch/xpatch.sty @@ -24,7 +24,7 @@ %% The released version of this bundle is available from CTAN. %% \RequirePackage{expl3} -\GetIdInfo$Id: xpatch.dtx 0.2 2012-01-13 12:00:00Z Enrico $ +\GetIdInfo$Id: xpatch.dtx 0.3 2012-10-02 12:00:00Z Enrico $ {Extending etoolbox patching commands} \ProvidesExplPackage {\ExplFileName}{\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription} @@ -35,87 +35,93 @@ { Please~install~an~up~to~date~version~of~l3kernel~ using~your~TeX~package~manager~or~from~CTAN.\\ \\ - Loading~xparse~will~abort! + Loading~xpatch~will~abort! } \tex_endinput:D } \RequirePackage{xparse,etoolbox} \cs_generate_variant:Nn \tl_if_in:NnT { Nx } -\bool_new:N \l_xpatch_protect_bool +\bool_new:N \l__xpatch_protect_bool \cs_if_exist:NF \c_backslash_str { \tl_const:Nx \c_backslash_str { \cs_to_str:N \\ } } -\tl_const:Nx \c_xpatch_bizarre_tl +\tl_const:Nx \c__xpatch_bizarre_tl { \tl_to_str:n { **)-(**/**]-[** } } +\tl_new:N \l__xpatch_name_tl +\tl_new:N \l__xpatch_repl_tl \cs_new:Npn \xpatch_main:NN #1 #2 { - \bool_set_false:N \l_xpatch_protect_bool - \tl_set:Nx \l_xpatch_name_tl { \cs_to_str:N #2 } - \tl_set:Nx \l_xpatch_repl_tl - { \c_xpatch_bizarre_tl \token_get_replacement_spec:N #2 } - \tl_if_in:NxT \l_xpatch_repl_tl + \bool_set_false:N \l__xpatch_protect_bool + \tl_set:Nx \l__xpatch_name_tl { \cs_to_str:N #2 } + \tl_set:Nx \l__xpatch_repl_tl + { \c__xpatch_bizarre_tl \token_get_replacement_spec:N #2 } + \tl_if_in:NxT \l__xpatch_repl_tl { - \c_xpatch_bizarre_tl + \c__xpatch_bizarre_tl \token_to_str:N \protect \c_space_tl - \c_backslash_str \l_xpatch_name_tl \c_space_tl \c_space_tl + \c_backslash_str \l__xpatch_name_tl \c_space_tl \c_space_tl } { - \bool_set_true:N \l_xpatch_protect_bool - \xpatch_add_space: + \bool_set_true:N \l__xpatch_protect_bool + \tl_put_right:Nn \l__xpatch_name_tl { \c_space_tl } } - \tl_if_in:NxT \l_xpatch_repl_tl + \tl_if_in:NxT \l__xpatch_repl_tl { - \c_xpatch_bizarre_tl + \c__xpatch_bizarre_tl \token_to_str:N \x@protect \c_space_tl - \c_backslash_str \l_xpatch_name_tl \c_backslash_str + \c_backslash_str \l__xpatch_name_tl \c_backslash_str } { - \bool_set_true:N \l_xpatch_protect_bool - \xpatch_add_space: + \bool_set_true:N \l__xpatch_protect_bool + \tl_put_right:Nn \l__xpatch_name_tl { \c_space_tl } } - \tl_if_in:NxT \l_xpatch_repl_tl + \tl_if_in:NxT \l__xpatch_repl_tl { - \c_xpatch_bizarre_tl + \c__xpatch_bizarre_tl \token_to_str:N \@protected@testopt \c_space_tl - \c_backslash_str \l_xpatch_name_tl + \c_backslash_str \l__xpatch_name_tl \c_space_tl \c_backslash_str \c_backslash_str } - { \xpatch_add_backslash: } - \tl_if_in:NxT \l_xpatch_repl_tl { - \c_xpatch_bizarre_tl + \tl_put_left:Nn \l__xpatch_name_tl { \c_backslash_str } + } + \tl_if_in:NxT \l__xpatch_repl_tl + { + \c__xpatch_bizarre_tl \token_to_str:N \@protected@testopt \c_space_tl - \c_backslash_str \l_xpatch_name_tl + \c_backslash_str \l__xpatch_name_tl \c_backslash_str \c_backslash_str } - { \xpatch_add_backslash: } - \tl_if_in:NxT \l_xpatch_repl_tl { - \c_xpatch_bizarre_tl + \tl_put_left:Nn \l__xpatch_name_tl { \c_backslash_str } + } + \tl_if_in:NxT \l__xpatch_repl_tl + { + \c__xpatch_bizarre_tl \token_to_str:N \@testopt \c_space_tl - \c_backslash_str \c_backslash_str \l_xpatch_name_tl + \c_backslash_str \c_backslash_str \l__xpatch_name_tl } - { \xpatch_add_backslash: } - \bool_if:NT \l_xpatch_protect_bool { - \tl_set:Nx \l_xpatch_repl_tl - { \c_xpatch_bizarre_tl + \tl_put_left:Nn \l__xpatch_name_tl { \c_backslash_str } + } + \bool_if:NT \l__xpatch_protect_bool + { + \tl_set:Nx \l__xpatch_repl_tl + { \c__xpatch_bizarre_tl \exp_after:wN \token_get_replacement_spec:N - \cs:w \l_xpatch_name_tl \cs_end: } - \tl_if_in:NxT \l_xpatch_repl_tl + \cs:w \l__xpatch_name_tl \cs_end: } + \tl_if_in:NxT \l__xpatch_repl_tl { - \c_xpatch_bizarre_tl + \c__xpatch_bizarre_tl \token_to_str:N \@protected@testopt \c_space_tl - \c_backslash_str \l_xpatch_name_tl + \c_backslash_str \l__xpatch_name_tl \c_space_tl \c_backslash_str \c_backslash_str } - { \xpatch_add_backslash: } + { + \tl_put_left:Nn \l__xpatch_name_tl { \c_backslash_str } + } } - \exp_after:wN #1 \cs:w \l_xpatch_name_tl \cs_end: + \exp_after:wN #1 \cs:w \l__xpatch_name_tl \cs_end: } -\cs_new:Npn \xpatch_add_space: - { \tl_set:Nx \l_xpatch_name_tl { \l_xpatch_name_tl \c_space_tl } } -\cs_new:Npn \xpatch_add_backslash: - { \tl_set:Nx \l_xpatch_name_tl { \c_backslash_str \l_xpatch_name_tl } } \NewDocumentCommand{\xpatchcmd}{}{ \xpatch_main:NN \patchcmd } \NewDocumentCommand{\xpretocmd}{}{ \xpatch_main:NN \pretocmd } \NewDocumentCommand{\xapptocmd}{}{ \xpatch_main:NN \apptocmd } @@ -129,6 +135,54 @@ { \xpatch_main:Nc \apptocmd { abx@macro@ \tl_to_str:n {#1} } } \NewDocumentCommand{\xshowbibmacro} { m } { \xpatch_main:Nc \show { abx@macro@ \tl_to_str:n {#1} } } +\NewDocumentCommand{\xpatchfieldformat} { O{*} m } + { \xpatch_main:Nc \patchcmd { abx@ffd@ \tl_to_str:n {#1} @ \tl_to_str:n {#2} } } +\NewDocumentCommand{\xpretofieldformat} { O{*} m } + { \xpatch_main:Nc \pretocmd { abx@ffd@ \tl_to_str:n {#1} @ \tl_to_str:n {#2} } } +\NewDocumentCommand{\xapptofieldformat} { O{*} m } + { \xpatch_main:Nc \apptocmd { abx@ffd@ \tl_to_str:n {#1} @ \tl_to_str:n {#2} } } +\NewDocumentCommand{\xshowfieldformat} { O{*} m } + { \xpatch_main:Nc \show { abx@ffd@ \tl_to_str:n {#1} @ \tl_to_str:n {#2} } } +\NewDocumentCommand{\xpatchnameformat} { O{*} m } + { \xpatch_main:Nc \patchcmd { abx@nfd@ \tl_to_str:n {#1} @ \tl_to_str:n {#2} } } +\NewDocumentCommand{\xpretonameformat} { O{*} m } + { \xpatch_main:Nc \pretocmd { abx@nfd@ \tl_to_str:n {#1} @ \tl_to_str:n {#2} } } +\NewDocumentCommand{\xapptonameformat} { O{*} m } + { \xpatch_main:Nc \apptocmd { abx@nfd@ \tl_to_str:n {#1} @ \tl_to_str:n {#2} } } +\NewDocumentCommand{\xshownameformat} { O{*} m } + { \xpatch_main:Nc \show { abx@ffd@ \tl_to_str:n {#1} @ \tl_to_str:n {#2} } } +\NewDocumentCommand{\xpatchlistformat} { O{*} m } + { \xpatch_main:Nc \patchcmd { abx@lfd@ \tl_to_str:n {#1} @ \tl_to_str:n {#2} } } +\NewDocumentCommand{\xpretolistformat} { O{*} m } + { \xpatch_main:Nc \pretocmd { abx@lfd@ \tl_to_str:n {#1} @ \tl_to_str:n {#2} } } +\NewDocumentCommand{\xapptolistformat} { O{*} m } + { \xpatch_main:Nc \apptocmd { abx@lfd@ \tl_to_str:n {#1} @ \tl_to_str:n {#2} } } +\NewDocumentCommand{\xshowlistformat} { O{*} m } + { \xpatch_main:Nc \show { abx@lfd@ \tl_to_str:n {#1} @ \tl_to_str:n {#2} } } +\NewDocumentCommand{\xpatchindexfieldformat} { O{*} m } + { \xpatch_main:Nc \patchcmd { abx@fid@ \tl_to_str:n {#1} @ \tl_to_str:n {#2} } } +\NewDocumentCommand{\xpretoindexfieldformat} { O{*} m } + { \xpatch_main:Nc \pretocmd { abx@fid@ \tl_to_str:n {#1} @ \tl_to_str:n {#2} } } +\NewDocumentCommand{\xapptoindexfieldformat} { O{*} m } + { \xpatch_main:Nc \apptocmd { abx@fid@ \tl_to_str:n {#1} @ \tl_to_str:n {#2} } } +\NewDocumentCommand{\xshowindexfieldformat} { O{*} m } + { \xpatch_main:Nc \show { abx@fid@ \tl_to_str:n {#1} @ \tl_to_str:n {#2} } } +\NewDocumentCommand{\xpatchindexnameformat} { O{*} m } + { \xpatch_main:Nc \patchcmd { abx@nid@ \tl_to_str:n {#1} @ \tl_to_str:n {#2} } } +\NewDocumentCommand{\xpretoindexnameformat} { O{*} m } + { \xpatch_main:Nc \pretocmd { abx@nid@ \tl_to_str:n {#1} @ \tl_to_str:n {#2} } } +\NewDocumentCommand{\xapptoindexnameformat} { O{*} m } + { \xpatch_main:Nc \apptocmd { abx@nid@ \tl_to_str:n {#1} @ \tl_to_str:n {#2} } } +\NewDocumentCommand{\xshowindexnameformat} { O{*} m } + { \xpatch_main:Nc \show { abx@nid@ \tl_to_str:n {#1} @ \tl_to_str:n {#2} } } +\NewDocumentCommand{\xpatchindexlistformat} { O{*} m } + { \xpatch_main:Nc \patchcmd { abx@lid@ \tl_to_str:n {#1} @ \tl_to_str:n {#2} } } +\NewDocumentCommand{\xpretoindexlistformat} { O{*} m } + { \xpatch_main:Nc \pretocmd { abx@lid@ \tl_to_str:n {#1} @ \tl_to_str:n {#2} } } +\NewDocumentCommand{\xappindextolistformat} { O{*} m } + { \xpatch_main:Nc \apptocmd { abx@lid@ \tl_to_str:n {#1} @ \tl_to_str:n {#2} } } +\NewDocumentCommand{\xshowindexlistformat} { O{*} m } + { \xpatch_main:Nc \show { abx@lid@ \tl_to_str:n {#1} @ \tl_to_str:n {#2} } } \NewDocumentCommand{\xpatchbibdriver} { m } { \exp_args:Nc \patchcmd {blx@bbx@#1} } \NewDocumentCommand{\xpretobibdriver} { m } |