%% %% This is file `xpatch.sty', %% generated with the docstrip utility. %% %% The original source files were: %% %% xpatch.dtx (with options: `package') %% %% Do not distribute this file without also distributing the %% source files specified above. %% %% File: xpatch.dtx (C) Copyright 2012 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 %% license or (at your option) any later version. The latest version %% of this license is in the file %% %% http://www.latex-project.org/lppl.txt %% %% This file is part of the "xpatch bundle" (The Work in LPPL) %% and all files in that bundle must be distributed together. %% %% 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 $ {Extending etoolbox patching commands} \ProvidesExplPackage {\ExplFileName}{\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription} \@ifpackagelater { expl3 } { 2011/10/09 } { } { \PackageError { xpatch } { Support~package~l3kernel~too~old. } { Please~install~an~up~to~date~version~of~l3kernel~ using~your~TeX~package~manager~or~from~CTAN.\\ \\ Loading~xparse~will~abort! } \tex_endinput:D } \RequirePackage{xparse,etoolbox} \cs_generate_variant:Nn \tl_if_in:NnT { Nx } \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_to_str:n { **)-(**/**]-[** } } \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 { \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 } { \bool_set_true:N \l_xpatch_protect_bool \xpatch_add_space: } \tl_if_in:NxT \l_xpatch_repl_tl { \c_xpatch_bizarre_tl \token_to_str:N \x@protect \c_space_tl \c_backslash_str \l_xpatch_name_tl \c_backslash_str } { \bool_set_true:N \l_xpatch_protect_bool \xpatch_add_space: } \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_space_tl \c_backslash_str \c_backslash_str } { \xpatch_add_backslash: } \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 \c_backslash_str } { \xpatch_add_backslash: } \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 } { \xpatch_add_backslash: } \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 { \c_xpatch_bizarre_tl \token_to_str:N \@protected@testopt \c_space_tl \c_backslash_str \l_xpatch_name_tl \c_space_tl \c_backslash_str \c_backslash_str } { \xpatch_add_backslash: } } \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 } \NewDocumentCommand{\xshowcmd} {}{ \xpatch_main:NN \show } \cs_generate_variant:Nn \xpatch_main:NN { Nc } \NewDocumentCommand{\xpatchbibmacro} { m } { \xpatch_main:Nc \patchcmd { abx@macro@ \tl_to_str:n {#1} } } \NewDocumentCommand{\xpretobibmacro} { m } { \xpatch_main:Nc \pretocmd { abx@macro@ \tl_to_str:n {#1} } } \NewDocumentCommand{\xapptobibmacro} { m } { \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{\xpatchbibdriver} { m } { \exp_args:Nc \patchcmd {blx@bbx@#1} } \NewDocumentCommand{\xpretobibdriver} { m } { \exp_args:Nc \pretocmd {blx@bbx@#1} } \NewDocumentCommand{\xapptobibdriver} { m } { \exp_args:Nc \apptocmd {blx@bbx@#1} } \NewDocumentCommand{\xshowbibdriver} { m } { \exp_args:Nc \show {blx@bbx@#1} } %% %% %% End of file `xpatch.sty'.