[latex3-commits] [latex3/latex2e] develop: Re-introduce \IfInstanceExist(TF) (41f33bc4)
github at latex-project.org
github at latex-project.org
Fri Feb 16 11:56:53 CET 2024
Repository : https://github.com/latex3/latex2e
On branch : develop
Link : https://github.com/latex3/latex2e/commit/41f33bc48d910d4af1d9c8702a1a17144449bc28
>---------------------------------------------------------------
commit 41f33bc48d910d4af1d9c8702a1a17144449bc28
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date: Thu Feb 15 13:39:16 2024 +0000
Re-introduce \IfInstanceExist(TF)
This reverts commit 10a330e5013d41f9d209a2f2ebaac91ffa18a62d.
>---------------------------------------------------------------
41f33bc48d910d4af1d9c8702a1a17144449bc28
base/changes.txt | 4 ++++
base/lttemplates.dtx | 15 ++++++++++++++-
base/testfiles-lttemplates/lttemplates003.lvt | 26 ++++++++++++++++++++++++++
base/testfiles-lttemplates/lttemplates003.tlg | 14 +++++++++++---
4 files changed, 55 insertions(+), 4 deletions(-)
diff --git a/base/changes.txt b/base/changes.txt
index dec230e8..1e76ddf9 100644
--- a/base/changes.txt
+++ b/base/changes.txt
@@ -6,6 +6,10 @@ to completeness or accuracy and it contains some references to files that are
not part of the distribution.
================================================================================
+2024-02-15 Joseph Wright <Joseph.Wright at latex-project.org>
+ * lttemplates.dtx
+ Re-introduce \IfInstanceExist(TF)
+
2024-01-30 David Carlisle <David.Carlisle at latex-project.org>
* ltclass.dtx: check that \RequirePackage, \documentclass, \usepackage
and related commands are at top level (gh/1185)
diff --git a/base/lttemplates.dtx b/base/lttemplates.dtx
index 844fb6fd..d27c232f 100644
--- a/base/lttemplates.dtx
+++ b/base/lttemplates.dtx
@@ -36,7 +36,7 @@
%<*driver>
% \fi
\ProvidesFile{lttemplates.dtx}
- [2024-02-11 v1.0a LaTeX Kernel (Prototype document functions)]
+ [2024-02-15 v1.0b LaTeX Kernel (Prototype document functions)]
% \iffalse
\documentclass{l3doc}
\GetFileInfo{lttemplates.dtx}
@@ -2653,6 +2653,19 @@
% \end{macro}
% \end{macro}
%
+% \begin{macro}{\IfInstanceExistT, \IfInstanceExistF, \IfInstanceExistTF}
+% \changes{2024-02-15}{v1.0b}{New macros}
+% More direct translation.
+% \begin{macrocode}
+\cs_new:Npn \IfInstanceExistTF #1#2
+ { \@@_if_instance_exist:nnTF {#1} {#2} }
+\cs_new:Npn \IfInstanceExistT #1#2
+ { \@@_if_instance_exist:nnT {#1} {#2} }
+\cs_new:Npn \IfInstanceExistF #1#2
+ { \@@_if_instance_exist:nnF {#1} {#2} }
+% \end{macrocode}
+% \end{macro}
+%
% \begin{macro}{\KeyValue}
% Simply dump the argument when executed: this should not happen.
% \begin{macrocode}
diff --git a/base/testfiles-lttemplates/lttemplates003.lvt b/base/testfiles-lttemplates/lttemplates003.lvt
index d16b95ea..9c3c2d21 100644
--- a/base/testfiles-lttemplates/lttemplates003.lvt
+++ b/base/testfiles-lttemplates/lttemplates003.lvt
@@ -317,6 +317,32 @@
}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% 17
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\TEST{Testing~instances:~existance~check}{
+
+ \IfInstanceExistTF {test} {nono} % instance unknwon, ok
+ {\typeout{Yes}} {\typeout{No}}
+
+ \IfInstanceExistTF {missingobjecttype} {nono} % objecttype unknown, ok
+ {\typeout{Yes}} {\typeout{No}}
+
+ \group_begin:
+
+ \DeclareInstance {test} {myinstance} {tname2} {}
+
+ \IfInstanceExistTF {test} {myinstance} % test inside group, ok
+ {\typeout{Yes}} {\typeout{No}}
+
+ \group_end:
+
+ \IfInstanceExistTF {test} {myinstance} % test outside group
+ {\typeout{Yes}} {\typeout{No}} % no longer defined, ok
+
+}
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 18
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
diff --git a/base/testfiles-lttemplates/lttemplates003.tlg b/base/testfiles-lttemplates/lttemplates003.tlg
index a7bed200..33cdf6ce 100644
--- a/base/testfiles-lttemplates/lttemplates003.tlg
+++ b/base/testfiles-lttemplates/lttemplates003.tlg
@@ -302,7 +302,15 @@ The template 'tname16' of type 'test' has variable mapping:
l. ...}
============================================================
============================================================
-TEST 17: Testing instances: declare instance
+TEST 17: Testing instances: existance check
+============================================================
+No
+No
+Yes
+No
+============================================================
+============================================================
+TEST 18: Testing instances: declare instance
============================================================
! LaTeX template Error: The template 'never-defined' of type 'test' is unknown
(template) or has no implementation.
@@ -317,7 +325,7 @@ huh
(Y-99)
============================================================
============================================================
-TEST 18: Edit template defaults
+TEST 19: Edit template defaults
============================================================
Defining key template/test/tname17/key on line ...
Defining key template/test/tname17/key/unknown on line ...
@@ -368,7 +376,7 @@ l. ...}
The key 'wrong' was not declared in the interface for the current template.
============================================================
============================================================
-TEST 19: Edit instance values
+TEST 20: Edit instance values
============================================================
The instance 'myinstance' of type 'test' has values:
> key => A
More information about the latex3-commits
mailing list.