From dbdd041a6bcdeea639aeb756e051d8f95caccf11 Mon Sep 17 00:00:00 2001 From: Joseph Wright Date: Tue, 8 Mar 2022 19:03:59 +0000 Subject: [PATCH] Add interface for overridden instance keys --- required/latex-lab/latex-lab-prototype.dtx | 24 ++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/required/latex-lab/latex-lab-prototype.dtx b/required/latex-lab/latex-lab-prototype.dtx index b957ff5b8..ee971bab0 100644 --- a/required/latex-lab/latex-lab-prototype.dtx +++ b/required/latex-lab/latex-lab-prototype.dtx @@ -270,15 +270,19 @@ % calls instances directly, and this command should be used internally % in document-level mark-up. % -% \begin{function}{\prototype_use_instance:nn} +% \begin{function}{\prototype_use_instance:nn, \prototype_use_instance:nnn} % \begin{syntax} % \cs{prototype_use_instance:nn} % ~~\Arg{object type} \Arg{instance} \meta{arguments} +% \cs{prototype_use_instance:nn}n +% ~~\Arg{object type} \Arg{instance} \Arg{overrides} \meta{arguments} % \end{syntax} % Uses an \meta{instance} of the \meta{object type}, which will require % \meta{arguments} as determined by the number specified for the % \meta{object type}. The \meta{instance} must have been declared -% before it can be used, otherwise an error is raised. +% before it can be used, otherwise an error is raised. The \texttt{nnn} +% version allows for local overrides of the instance settings using the +% additional keyval argument. % \end{function} % % \begin{function}{\prototype_use_template:nnnn} @@ -460,14 +464,29 @@ % \end{macro} % % \begin{macro}{\prototype_use_instance:nn} +% \begin{macro}{\prototype_use_instance:nnn} % Recover the values and insert the code. % \begin{macrocode} \cs_new_protected:Npn \prototype_use_instance:nn #1#2 + { \prototype_use_instance:nnn {#1} {#2} { } } +\cs_new_protected:Npn \prototype_use_instance:nnn #1#2#3 { \tl_if_exist:cTF { l_@@_instance_ #1 _ #2 _template_tl } { \tl_set_eq:Nc \l_@@_assignments_tl { l_@@_instance_ #1 _ #2 _pars_tl } + \tl_if_blank:nF {#3} + { + \tl_set:Nx \l_@@_tmp_tl + { + prototype / #1 / + \tl_use:c { l_@@_instance_ #1 _ #2 _template_tl } + } + \exp_args:NNV \keys_precompile:Nnn + \l_@@_tmp_tl \l_@@_tmp_tl {#3} + \tl_put_right:NV \l_@@_assignments_tl + \l_@@_tmp_tl + } \use:c { @@_template_ #1 _ @@ -479,6 +498,7 @@ } % \end{macrocode} % \end{macro} +% \end{macro} % % \subsection{Messages} %