From 41f33bc48d910d4af1d9c8702a1a17144449bc28 Mon Sep 17 00:00:00 2001 From: Joseph Wright Date: Thu, 15 Feb 2024 13:39:16 +0000 Subject: [PATCH] Re-introduce \IfInstanceExist(TF) This reverts commit 10a330e5013d41f9d209a2f2ebaac91ffa18a62d. --- 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 dec230e89..1e76ddf9e 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 + * lttemplates.dtx + Re-introduce \IfInstanceExist(TF) + 2024-01-30 David Carlisle * 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 844fb6fd3..d27c232fe 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 d16b95eaa..9c3c2d21d 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 a7bed2004..33cdf6ceb 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