Debian Codegraph @

texmf-dist/source/latex/l3kernel/l3legacy.dtx

raw
1 % \iffalse meta-comment
2 %
3 %% File: l3legacy.dtx
4 %
5 % Copyright (C) 2019-2026 The LaTeX Project
6 %
7 % It may be distributed and/or modified under the conditions of the
8 % LaTeX Project Public License (LPPL), either version 1.3c of this
9 % license or (at your option) any later version. The latest version
10 % of this license is in the file
11 %
12 % https://www.latex-project.org/lppl.txt
13 %
14 % This file is part of the "l3kernel bundle" (The Work in LPPL)
15 % and all files in that bundle must be distributed together.
16 %
17 % -----------------------------------------------------------------------
18 %
19 % The development version of the bundle can be found at
20 %
21 % https://github.com/latex3/latex3
22 %
23 % for those people who are interested.
24 %
25 %<*driver>
26 \documentclass[full,kernel]{l3doc}
27 \begin{document}
28 \DocInput{\jobname.dtx}
29 \end{document}
30 %</driver>
31 % \fi
32 %
33 % \title{^^A
34 % The \pkg{l3legacy} module\\ Interfaces to legacy concepts^^A
35 % }
36 %
37 % \author{^^A
38 % The \LaTeX{} Project\thanks
39 % {^^A
40 % E-mail:
41 % \href{mailto:[email protected]}
42 % {[email protected]}^^A
43 % }^^A
44 % }
45 %
46 % \date{Released 2026-05-15}
47 %
48 % \maketitle
49 %
50 % \begin{documentation}
51 %
52 % There are a small number of \TeX{} or \LaTeXe{} concepts which are not used
53 % in \pkg{expl3} code but which need to be manipulated when working as a \LaTeXe{}
54 % package. To allow these to be integrated cleanly into \pkg{expl3} code, a set
55 % of legacy interfaces are provided here.
56 %
57 % \begin{function}[EXP,pTF]{\legacy_if:n}
58 % \begin{syntax}
59 % \cs{legacy_if_p:n} \Arg{name}
60 % \cs{legacy_if:nTF} \Arg{name} \Arg{true code} \Arg{false code}
61 % \end{syntax}
62 % Tests if the \LaTeXe{}/plain \TeX{} conditional (generated by \tn{newif})
63 % is \texttt{true} or \texttt{false} and branches accordingly. The
64 % \meta{name} of the conditional should \emph{omit} the leading \texttt{if}.
65 % \end{function}
66 %
67 % \begin{function}[added = 2021-05-10]
68 % {
69 % \legacy_if_set_true:n, \legacy_if_set_false:n,
70 % \legacy_if_gset_true:n, \legacy_if_gset_false:n
71 % }
72 % \begin{syntax}
73 % \cs{legacy_if_set_true:n} \Arg{name}
74 % \cs{legacy_if_set_false:n} \Arg{name}
75 % \end{syntax}
76 % Sets the \LaTeXe{}/plain \TeX{} conditional |\if|\meta{name}
77 % (generated by \tn{newif}) to be \texttt{true} or \texttt{false}.
78 % \end{function}
79 %
80 % \begin{function}[added = 2021-05-10]{\legacy_if_set:nn, \legacy_if_gset:nn}
81 % \begin{syntax}
82 % \cs{legacy_if_set:nn} \Arg{name} \Arg{boolexpr}
83 % \end{syntax}
84 % Sets the \LaTeXe{}/plain \TeX{} conditional |\if|\meta{name}
85 % (generated by \tn{newif}) to the result of evaluating the
86 % \meta{boolean expression}.
87 % \end{function}
88 %
89 % \end{documentation}
90 %
91 % \begin{implementation}
92 %
93 % \section{\pkg{l3legacy} implementation}
94 %
95 % \begin{macrocode}
96 %<*code>
97 % \end{macrocode}
98 %
99 % \begin{macrocode}
100 %<@@=legacy>
101 % \end{macrocode}
102 %
103 % \begin{macro}[EXP,pTF]{\legacy_if:n}
104 % A friendly wrapper. We need to use the \cs{if:w} approach here, rather than
105 % testing against \tn{iftrue}/\tn{iffalse} as the latter approach fails for
106 % primitive conditionals such as \tn{ifmmode}. The \cs{reverse_if:N} here
107 % means that we get a slightly more useful error if the name is undefined.
108 % \begin{macrocode}
109 \prg_new_conditional:Npnn \legacy_if:n #1 { p , T , F , TF }
110 {
111 \exp_after:wN \reverse_if:N
112 \cs:w if#1 \cs_end:
113 \prg_return_false:
114 \else:
115 \prg_return_true:
116 \fi:
117 }
118 % \end{macrocode}
119 % \end{macro}
120 %
121 % \begin{macro}
122 % {
123 % \legacy_if_set_true:n, \legacy_if_set_false:n,
124 % \legacy_if_gset_true:n, \legacy_if_gset_false:n
125 % }
126 % A friendly wrapper.
127 % \begin{macrocode}
128 \cs_new_protected:Npn \legacy_if_set_true:n #1
129 { \cs_set_eq:cN { if#1 } \if_true: }
130 \cs_new_protected:Npn \legacy_if_set_false:n #1
131 { \cs_set_eq:cN { if#1 } \if_false: }
132 \cs_new_protected:Npn \legacy_if_gset_true:n #1
133 { \cs_gset_eq:cN { if#1 } \if_true: }
134 \cs_new_protected:Npn \legacy_if_gset_false:n #1
135 { \cs_gset_eq:cN { if#1 } \if_false: }
136 % \end{macrocode}
137 % \end{macro}
138 %
139 % \begin{macro}{\legacy_if_set:nn, \legacy_if_gset:nn}
140 % A more elaborate wrapper.
141 % \begin{macrocode}
142 \cs_new_protected:Npn \legacy_if_set:nn #1#2
143 {
144 \bool_if:nTF {#2} \legacy_if_set_true:n \legacy_if_set_false:n
145 {#1}
146 }
147 \cs_new_protected:Npn \legacy_if_gset:nn #1#2
148 {
149 \bool_if:nTF {#2} \legacy_if_gset_true:n \legacy_if_gset_false:n
150 {#1}
151 }
152 % \end{macrocode}
153 % \end{macro}
154 %
155 % \begin{macrocode}
156 %</code>
157 % \end{macrocode}
158 %
159 % \end{implementation}
160 %
161 % \PrintIndex