[latex3-commits] [latex3/latex2e] property-expansion: expand label/property name consistently in LaTeX2e commands (214ce87a)
github at latex-project.org
github at latex-project.org
Wed Sep 13 12:46:07 CEST 2023
Repository : https://github.com/latex3/latex2e
On branch : property-expansion
Link : https://github.com/latex3/latex2e/commit/214ce87af713c0be230904c23a9e75bd43e6c8f8
>---------------------------------------------------------------
commit 214ce87af713c0be230904c23a9e75bd43e6c8f8
Author: Ulrike Fischer <fischer at troubleshooting-tex.de>
Date: Wed Sep 13 12:46:07 2023 +0200
expand label/property name consistently in LaTeX2e commands
>---------------------------------------------------------------
214ce87af713c0be230904c23a9e75bd43e6c8f8
base/changes.txt | 3 ++
base/ltproperties.dtx | 60 ++++++++++++++--------
base/testfiles/properties-008-expansion.lvt | 78 +++++++++++++++++++++++++++++
base/testfiles/properties-008-expansion.tlg | 37 ++++++++++++++
4 files changed, 157 insertions(+), 21 deletions(-)
diff --git a/base/changes.txt b/base/changes.txt
index 3df47331..3454f49a 100644
--- a/base/changes.txt
+++ b/base/changes.txt
@@ -5,6 +5,9 @@ It is provided for convenience only. It therefore makes no claims to
completeness or accuracy and it contains some references to files that
are not part of the distribution.
================================================================================
+2023-09-13 Ulrike Fischer <Ulrike.Fischer at latex-project.org>
+ * ltproperties.dtx:
+ expand consistently the label/property names in the LaTeX2e commands.
2023-09-13 Joseph Wright <Joseph.Wright at latex-project.org>
* ltmiscen.dtx:
diff --git a/base/ltproperties.dtx b/base/ltproperties.dtx
index 39b9fac3..71b6e2a1 100644
--- a/base/ltproperties.dtx
+++ b/base/ltproperties.dtx
@@ -22,8 +22,8 @@
%
% for those people who are interested.
% \begin{macrocode}
-\def\ltpropertiesversion{1.0a}
-\def\ltpropertiesdate{2023-09-05}
+\def\ltpropertiesversion{1.0b}
+\def\ltpropertiesdate{2023-09-13}
% \end{macrocode}
%<*driver>
@@ -188,7 +188,7 @@
% file with the \meta{label} specified.
% \end{function}
%
-% \begin{function}[EXP]{\property_ref:nn}
+% \begin{function}[EXP]{\property_ref:nn,\property_ref:ee}
% \begin{syntax}
% \cs{property_ref:nn} \Arg{label} \Arg{property}
% \end{syntax}
@@ -200,7 +200,7 @@
% if the reference can not be resolved.
% \end{function}
%
-% \begin{function}[EXP]{\property_ref:nnn}
+% \begin{function}[EXP]{\property_ref:nnn,\property_ref:een}
% \begin{syntax}
% \cs{property_ref:nnn} \Arg{label} \Arg{property} \Arg{local default}
% \end{syntax}
@@ -227,7 +227,7 @@
% or in some outer group!
% \end{function}
%
-% \begin{function}{\property_ref_undefined_warn:n}
+% \begin{function}{\property_ref_undefined_warn:n,\property_ref_undefined_warn:x}
% \begin{syntax}
% \cs{property_ref_undefined_warn:n} \Arg{label}
% \end{syntax}
@@ -241,7 +241,7 @@
% \texttt{Reference~`\meta{label}'~on~page~\meta{page}\space undefined}.
% \end{function}
%
-% \begin{function}{\property_ref_undefined_warn:nn}
+% \begin{function}{\property_ref_undefined_warn:nn,\property_ref_undefined_warn:xx}
% \begin{syntax}
% \cs{property_ref_undefined_warn:nn} \Arg{label} \Arg{property}
% \end{syntax}
@@ -261,7 +261,7 @@
% if the label is known but doesn't provide a value for the requested property.
% \end{function}
%
-% \begin{function}[pTF]{\property_if_exist:n}
+% \begin{function}[pTF]{\property_if_exist:n,\property_if_exist:e}
% \begin{syntax}
% \cs{property_if_exist_p:n} \Arg{property}
% \cs{property_if_exist:nTF} \Arg{property} \Arg{true code} \Arg{false code}
@@ -270,7 +270,7 @@
% Tests if the \meta{property} has been declared.
% \end{function}
%
-% \begin{function}[pTF]{\property_if_recorded:n}
+% \begin{function}[pTF]{\property_if_recorded:n,\property_if_recorded:e}
% \begin{syntax}
% \cs{property_if_recorded_p:n} \Arg{label}
% \cs{property_if_recorded:nTF} \Arg{label} \Arg{true code} \Arg{false code}
@@ -280,7 +280,7 @@
% set with the standard \cs{label} command.
% \end{function}
%
-% \begin{function}[pTF]{\property_if_recorded:nn}
+% \begin{function}[pTF]{\property_if_recorded:nn,\property_if_recorded:ee}
% \begin{syntax}
% \cs{property_if_recorded_p:nn} \Arg{label} \Arg{property}
% \cs{property_if_recorded:nnTF} \Arg{label} \Arg{property} \Arg{true code} \Arg{false code}
@@ -301,6 +301,8 @@
%
% \section{\LaTeXe{} interface}
%
+% The LaTeXe{} interfaces always expand label and property arguments.
+%
% \begin{function}{\NewProperty,\SetProperty}
% \begin{syntax}
% \cs{NewProperty} \Arg{property} \Arg{setpoint} \Arg{default} \Arg{code}
@@ -507,9 +509,17 @@
% \end{macro}
%
% \begin{macro}{\NewProperty,\SetProperty}
+% For consistency we expand the property name, but this doesn't warant a
+% variant of the L3-commands.
% \begin{macrocode}
-\cs_set_eq:NN \NewProperty\property_new:nnnn
-\cs_set_eq:NN \SetProperty\property_gset:nnnn
+\cs_new_protected:Npn \NewProperty #1#2#3#4
+ {
+ \exp_args:Nx \property_new:nnnn {#1}{#2}{#3}{#4}
+ }
+\cs_new_protected:Npn \SetProperty #1#2#3#4
+ {
+ \exp_args:Nx \property_gset:nnnn {#1}{#2}{#3}{#4}
+ }
% \end{macrocode}
% \end{macro}
%
@@ -589,7 +599,7 @@
% \end{macrocode}
% \end{variable}
%
-% \begin{macro}[EXP]{\property_ref:nn}
+% \begin{macro}[EXP]{\property_ref:nn,\property_ref:ee}
% Search for the label/property combination, and if not found fall back
% to the default of the property.
% \begin{macrocode}
@@ -600,10 +610,11 @@
{ \tl_to_str:n {#2} }
{ \tl_use:c { g_@@_default_ #2 _tl } }
}
+\cs_generate_variant:Nn \property_ref:nn {ee}
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}[EXP]{\property_ref:nnn, \@@_ref:nnn, \@@_ref:een}
+% \begin{macro}[EXP]{\property_ref:nnn,\property_ref:een, \@@_ref:nnn, \@@_ref:een}
% This allows to set a local default value which overrides the default value
% of the property.
% \begin{macrocode}
@@ -631,6 +642,7 @@
}
}
\cs_generate_variant:Nn \@@_ref:nnn { ee }
+\cs_generate_variant:Nn \property_ref:nnn {een}
% \end{macrocode}
% \end{macro}
%
@@ -642,10 +654,10 @@
{
\IfNoValueTF {#1}
{
- \property_ref:nn {#2}{#3}
+ \property_ref:ee {#2}{#3}
}
{
- \property_ref:nnn {#2}{#3}{#1}
+ \property_ref:een {#2}{#3}{#1}
}
}
% \end{macrocode}
@@ -678,7 +690,7 @@
}
% \end{macrocode}
%
-% This command is used in \cs{enddocument} to test if some label values haved changed.
+% This command is used in \cs{enddocument} to test if some label values have changed.
% \begin{macrocode}
\cs_new_protected:Npn \@kernel at new@label at record@testdef #1 #2
{
@@ -705,12 +717,13 @@
\prg_return_false:
}
}
+\prg_generate_conditional_variant:Nnn \property_if_exist:n {e} {TF}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{IfPropertyExistTF}
% \begin{macrocode}
-\cs_new_eq:NN \IfPropertyExistTF \property_if_exist:nTF
+\cs_new_eq:NN \IfPropertyExistTF \property_if_exist:eTF
% \end{macrocode}
% \end{macro}
%
@@ -729,12 +742,13 @@
\prg_return_false:
}
}
+\prg_generate_conditional_variant:Nnn \property_if_recorded:n {e} {TF}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\IfLabelExistTF}
% \begin{macrocode}
-\cs_new_eq:NN \IfLabelExistTF \property_if_recorded:nTF
+\cs_new_eq:NN \IfLabelExistTF \property_if_recorded:eTF
% \end{macrocode}
% \end{macro}
%
@@ -753,12 +767,13 @@
\prg_return_false:
}
}
+\prg_generate_conditional_variant:Nnn \property_if_recorded:nn {ee} {TF}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\IfPropertyRecordedTF}
% \begin{macrocode}
-\cs_new_eq:NN \IfPropertyRecordedTF \property_if_recorded:nnTF
+\cs_new_eq:NN \IfPropertyRecordedTF \property_if_recorded:eeTF
% \end{macrocode}
% \end{macro}
%
@@ -788,7 +803,9 @@
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}{\property_ref_undefined_warn:nn, \RefUndefinedWarn}
+% \begin{macro}{\property_ref_undefined_warn:nn,
+% \property_ref_undefined_warn:xx,
+% \RefUndefinedWarn}
% \begin{macrocode}
\cs_new_protected:Npn \property_ref_undefined_warn:nn #1#2 %#1 label, #2 property
{
@@ -806,7 +823,8 @@
\@latex at warning { Reference~`#1'~on~page~\thepage\space undefined }%
}
}
-\cs_set_eq:NN \RefUndefinedWarn \property_ref_undefined_warn:nn
+\cs_generate_variant:Nn \property_ref_undefined_warn:nn {xx}
+\cs_set_eq:NN \RefUndefinedWarn \property_ref_undefined_warn:xx
% \end{macrocode}
% \end{macro}
%
diff --git a/base/testfiles/properties-008-expansion.lvt b/base/testfiles/properties-008-expansion.lvt
new file mode 100644
index 00000000..0dcdc31d
--- /dev/null
+++ b/base/testfiles/properties-008-expansion.lvt
@@ -0,0 +1,78 @@
+\RequirePackage[enable-debug ,check-declarations]{expl3}
+\ExplSyntaxOn
+\debug_on:n { deprecation }
+\ExplSyntaxOff
+\documentclass{article}
+\input{regression-test}
+\START
+
+\SHOWFILE{\jobname.aux}
+
+\OMIT
+\begin{document}
+\TIMO
+\newcommand\labelsuffix{-LA}
+\newcommand\propsuffix{-PA}
+\newcommand\proppage{page}
+\newcommand\myname{Duck}
+\NewProperty{name\propsuffix}{now}{Doe}{\myname}
+
+\RecordProperties{label\labelsuffix}{\proppage,\proppage num,name\propsuffix}
+
+
+\ExplSyntaxOn
+xxxxx
+
+\TEST{Ref~by~string}
+ {
+ \ASSERT{1,1}
+ {
+ \RefProperty{label-LA}{page},\RefProperty{label-LA}{pagenum}
+ }
+ }
+
+\TEST{Ref~by~command}
+ {
+ \ASSERT{1,1,Duck}
+ {
+ \RefProperty{label\labelsuffix}{\proppage},
+ \RefProperty{label\labelsuffix}{\proppage num},
+ \RefProperty{label\labelsuffix}{name\propsuffix}
+ }
+ }
+\TEST{Test~property~by~command}
+ {
+ \ASSERT{true}
+ {
+ \IfPropertyExistTF {name\propsuffix}{true}{false}
+ }
+ }
+
+\TEST{Test~label~by~command}
+ {
+ \ASSERT{true}
+ {
+ \IfLabelExistTF {label\labelsuffix}{true}{false}
+ }
+ }
+
+
+\TEST{Test~label/property~by~command}
+ {
+
+ \ASSERT{true}
+ {
+ \IfPropertyRecordedTF {label\labelsuffix}{name\propsuffix} {true}{false}
+ }
+ }
+
+\RefUndefinedWarn { label\labelsuffix }{ name\propsuffix }
+
+\RefUndefinedWarn { label\labelsuffix }{ nameX\propsuffix }
+
+\RefUndefinedWarn { labelX\labelsuffix }{ nameX\propsuffix }
+
+\ExplSyntaxOff
+
+
+\end{document}
diff --git a/base/testfiles/properties-008-expansion.tlg b/base/testfiles/properties-008-expansion.tlg
new file mode 100644
index 00000000..07cfa3da
--- /dev/null
+++ b/base/testfiles/properties-008-expansion.tlg
@@ -0,0 +1,37 @@
+This is a generated file for the l3build validation system.
+Don't change this file in any respect.
+-------- properties-008-expansion.aux (start) ---------
+(properties-008-expansion.aux) \relax^^M
+\new at label@record{label-LA}{{page}{1}{pagenum}{1}{name-PA}{Duck}}^^M
+\gdef \@abspage at last{1}^^M
+-------- properties-008-expansion.aux (end) -----------
+============================================================
+TEST 1: Ref by string
+============================================================
+PASSED
+============================================================
+============================================================
+TEST 2: Ref by command
+============================================================
+PASSED
+============================================================
+============================================================
+TEST 3: Test property by command
+============================================================
+PASSED
+============================================================
+============================================================
+TEST 4: Test label by command
+============================================================
+PASSED
+============================================================
+============================================================
+TEST 5: Test label/property by command
+============================================================
+PASSED
+============================================================
+LaTeX Warning: Property `nameX-PA' undefined for reference `label-LA' on page 1 on input line ....
+LaTeX Warning: Reference `labelX-LA' on page 1 undefined on input line ....
+[1
+] (properties-008-expansion.aux)
+LaTeX Warning: There were undefined references.
More information about the latex3-commits
mailing list.