[latex3-commits] [git/LaTeX3-latex3-latex3] main: Add \CopyInstance (55f3d64f2)

Joseph Wright joseph.wright at morningstar2.co.uk
Wed Feb 1 00:04:22 CET 2023


Repository : https://github.com/latex3/latex3
On branch  : main
Link       : https://github.com/latex3/latex3/commit/55f3d64f257a6252fed686482f918e86d130a89f

>---------------------------------------------------------------

commit 55f3d64f257a6252fed686482f918e86d130a89f
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Tue Jan 31 23:04:22 2023 +0000

    Add \CopyInstance


>---------------------------------------------------------------

55f3d64f257a6252fed686482f918e86d130a89f
 l3experimental/CHANGELOG.md        |  3 +++
 l3packages/xtemplate/xtemplate.dtx | 34 ++++++++++++++++++++++++++++++++++
 2 files changed, 37 insertions(+)

diff --git a/l3experimental/CHANGELOG.md b/l3experimental/CHANGELOG.md
index 2b4fd0905..1fd0d1f22 100644
--- a/l3experimental/CHANGELOG.md
+++ b/l3experimental/CHANGELOG.md
@@ -7,6 +7,9 @@ this project uses date-based 'snapshot' version identifiers.
 
 ## [Unreleased]
 
+### Added
+- `\CopyInstance`
+
 ### Changes
 - Set only known keys in `\SetTemplateKeys`
 
diff --git a/l3packages/xtemplate/xtemplate.dtx b/l3packages/xtemplate/xtemplate.dtx
index 22bdd972c..f1546399c 100644
--- a/l3packages/xtemplate/xtemplate.dtx
+++ b/l3packages/xtemplate/xtemplate.dtx
@@ -475,6 +475,15 @@
 %   then inserts the appropriate code into the input stream.
 % \end{function}
 %
+% \begin{function}{\CopyInstance}
+%   \begin{syntax}
+%     \cs{CopyInstance}
+%     ~~\Arg{object type} \Arg{instance1} \Arg{instance2}
+%   \end{syntax}
+%   Copies the \meta{values} for \meta{instance1} for an
+%   \meta{object type} to \meta{instance2}.
+% \end{function}
+%
 % \section{Document interface}
 %
 % After the instances have been chosen, document commands must be
@@ -1987,6 +1996,27 @@
 % \end{macro}
 % \end{macro}
 %
+% \begin{macro}{\@@_copy_instance:nnnn}
+%   Copy--paste an instance
+%    \begin{macrocode}
+\cs_new_protected:Npn \@@_copy_instance:nnnn #1#2#3#4
+  {
+    \@@_if_instance_exist:nnnTF {#1} {#2} {#3}
+      {
+        \@@_recover_values:n { #1 / #2 / #3 }
+        \@@_store_values:n { #1 / #2 / #4 }
+        \cs_set_eq:cc { \c_@@_instances_root_tl #1 / #2 / #4 }
+          { \c_@@_instances_root_tl #1 / #2 / #3 }
+      }
+      {
+        \msg_error:nnxx { xtemplate } { unknown-instance }
+          {#1} {#3}
+      }
+  }
+%    \end{macrocode}
+% \end{macro}
+%
+%
 % \begin{macro}{\@@_edit_instance:nnnn}
 % \begin{macro}{\@@_edit_instance_aux:nnnnn}
 % \begin{macro}{\@@_edit_instance_aux:nonnn}
@@ -2783,6 +2813,7 @@
 % \begin{macro}{\EditTemplateDefaults}
 % \begin{macro}{\DeclareInstance}
 % \begin{macro}{\DeclareCollectionInstance}
+% \begin{macro}{\CopyInstance}
 % \begin{macro}{\EditInstance}
 % \begin{macro}{\EditCollectionInstance}
 % \begin{macro}{\UseTemplate}
@@ -2803,6 +2834,8 @@
   { \@@_declare_instance:nnnnn {#1} {#3} { } {#2} {#4} }
 \cs_new_protected:Npn \DeclareCollectionInstance #1#2#3#4#5
   { \@@_declare_instance:nnnnn {#2} {#4} {#1} {#3} {#5} }
+\cs_new_protected:Npn \CopyInstance #1#2#3
+  { \@@_copy_instance:nnnn {#1} { } {#2} {#3} }
 \cs_new_protected:Npn \EditTemplateDefaults #1#2#3
   { \@@_edit_defaults:nnn {#1} {#2} {#3} }
 \cs_new_protected:Npn \EditInstance #1#2#3
@@ -2828,6 +2861,7 @@
 % \end{macro}
 % \end{macro}
 % \end{macro}
+% \end{macro}
 %
 % \begin{macro}{\ShowTemplateCode}
 % \begin{macro}{\ShowTemplateDefaults}





More information about the latex3-commits mailing list.