latex3 / latex2e

The LaTeX2e kernel
https://www.latex-project.org/
LaTeX Project Public License v1.3c
1.88k stars 261 forks source link

Single-branch forms of CamelCase conditionals, continued #1450

Open muzimuzhi opened 2 weeks ago

muzimuzhi commented 2 weeks ago

Brief outline of the bug

Following issue https://github.com/latex3/latex2e/issues/1262 which results in PRs https://github.com/latex3/latex2e/pull/1327 and https://github.com/latex3/latex2e/pull/1329, I find there're still some CamelCase conditionals (\If...TF) which don't have single-branch forms (\If...T and \If...F).

! [info] Have T-or-F forms
count: 16
\IfBlankTF 
\IfBooleanTF 
\IfClassAtLeastTF 
\IfClassLoadedTF 
\IfClassLoadedWithOptionsTF 
\IfFileAtLeastTF 
\IfFileLoadedTF 
\IfFormatAtLeastTF 
\IfInstanceExistsTF 
\IfLabelExistsTF 
\IfNoValueTF 
\IfPackageAtLeastTF 
\IfPackageLoadedTF 
\IfPackageLoadedWithOptionsTF 
\IfPropertyExistsTF 
\IfValueTF 

! [info] No T-or-F forms
count: 7
\IfDocumentMetadataTF 
\IfExplAtLeastTF 
\IfFontSeriesContextTF 
\IfHookEmptyTF 
\IfMarksEqualTF 
\IfPDFManagementActiveTF 
\IfPropertyRecordedTF

This is a more complete list than what I posted in https://github.com/latex3/latex2e/issues/1262#issuecomment-2051010867.

Minimal example showing the bug

Example

```latex \documentclass{article} \ExplSyntaxOn \tl_const:Nn \c_chkcond_false_matches_tl { \IfClassLoadedWithOptionTF % typo, s/Option/Options/ \IfHookExistsTF % defined but marked for removal % \IfInstanceExistTF % in xtemplate.sty \IfLabelExistTF % deprecated old name \IfNoMarkTF % only shown in doc example \IfPropertyExistTF % deprecated old name \IfSeriesContextTF % typo, s/Series/FontSeries/ } \cs_new_protected:Npn \chkcond_use_one:n #1 { \iow_log:n {#1} \tl_if_single:nT {#1} \token_to_str:N #1 \par } \cs_new_protected:Npn \chkcond_use_list:N #1 { \par \exp_args:Ne \chkcond_use_one:n { count:~ \tl_count:N #1 } { \ttfamily \tl_map_inline:Nn #1 { \chkcond_use_one:n {##1} } } } \NewDocumentCommand{\checkExistence}{m}{% \tl_clear:N \l_tmpa_tl \tl_clear:N \l_tmpb_tl \tl_clear_new:N \l_mytmp_tl \tl_map_inline:nn {#1} { \tl_if_in:NnF \c_chkcond_false_matches_tl {##1} { \tl_set:Ne \l_mytmp_tl { \cs_to_str:N ##1 \s_stop } \exp_args:NNo \tl_remove_once:Nn \l_mytmp_tl { \tl_to_str:n {TF} \s_stop } \bool_lazy_and:nnTF { \cs_if_exist_p:c { \l_mytmp_tl T } } { \cs_if_exist_p:c { \l_mytmp_tl F } } { \tl_put_right:Nn \l_tmpa_tl { ##1 } } { \tl_put_right:Nn \l_tmpb_tl { ##1 } } } } \par \iow_log:e { !~[info]~Have~T-or-F~forms } \noindent {\bfseries CamelCase~conditionals~that~have~single~T-or-F~forms} \chkcond_use_list:N \l_tmpa_tl \iow_log:n { } \iow_log:e { !~[info]~No~T-or-F~forms } \noindent {\bfseries CamelCase~conditionals~that~don't~have~single~T-or-F~forms} \par \chkcond_use_list:N \l_tmpb_tl } \ExplSyntaxOff \begin{document} \checkExistence{ % rg -oIN '(\\If\w+TF)\b' -r '$1' -g '!texmf' | sort -u % (-o/--only-matching, -I/--no-filename, -N/--no-line-number, % -r/--replace, -g/--glob) \IfBlankTF \IfBooleanTF \IfClassAtLeastTF \IfClassLoadedTF \IfClassLoadedWithOptionTF \IfClassLoadedWithOptionsTF \IfDocumentMetadataTF \IfExplAtLeastTF \IfFileAtLeastTF \IfFileLoadedTF \IfFontSeriesContextTF \IfFormatAtLeastTF \IfHookEmptyTF \IfHookExistsTF \IfInstanceExistsTF \IfLabelExistTF \IfLabelExistsTF \IfMarksEqualTF \IfNoMarkTF \IfNoValueTF \IfPDFManagementActiveTF \IfPackageAtLeastTF \IfPackageLoadedTF \IfPackageLoadedWithOptionsTF \IfPropertyExistTF \IfPropertyExistsTF \IfPropertyRecordedTF \IfSeriesContextTF \IfValueTF } \end{document} ```

muzimuzhi commented 2 weeks ago
! [info] No T-or-F forms
count: 7
\IfDocumentMetadataTF 
\IfExplAtLeastTF 
\IfFontSeriesContextTF 
\IfHookEmptyTF 
\IfMarksEqualTF 
\IfPDFManagementActiveTF 
\IfPropertyRecordedTF

Among these,