From 53beee10f86ccded4c4ce93250ea5f203d9c4e45 Mon Sep 17 00:00:00 2001 From: Henri Menke Date: Sun, 22 May 2022 19:03:33 +0200 Subject: [PATCH 1/7] fix: add shortcuts to uninstallcommands Signed-off-by: Henri Menke --- tex/generic/pgf/frontendlayer/tikz/tikz.code.tex | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tex/generic/pgf/frontendlayer/tikz/tikz.code.tex b/tex/generic/pgf/frontendlayer/tikz/tikz.code.tex index 9b76858b3..8be767e30 100644 --- a/tex/generic/pgf/frontendlayer/tikz/tikz.code.tex +++ b/tex/generic/pgf/frontendlayer/tikz/tikz.code.tex @@ -1900,16 +1900,24 @@ % #2: real command name \def\tikzaddtikzonlycommandshortcutlet#1#2{% \expandafter\def\expandafter\tikz@installcommands\expandafter{\tikz@installcommands + \expandafter\let\csname tikz@orig\detokenize{#1}\expandafter\endcsname=#1% \let#1=#2% }% + \expandafter\def\expandafter\tikz@uninstallcommands\expandafter{\tikz@uninstallcommands + \expandafter\let\expandafter#1\csname tikz@orig\detokenize{#1}\endcsname + }% }% % Has the same effect as \tikzaddtikzonlycommandshortcutlet but uses % \def#1{#2} instead of \let. \def\tikzaddtikzonlycommandshortcutdef#1#2{% \expandafter\def\expandafter\tikz@installcommands\expandafter{\tikz@installcommands + \expandafter\let\csname tikz@orig\detokenize{#1}\endcsname=#1% \def#1{#2}% }% + \expandafter\def\expandafter\tikz@uninstallcommands\expandafter{\tikz@uninstallcommands + \expandafter\let\expandafter#1\csname tikz@orig\detokenize{#1}\endcsname + }% }% % From c137091d0f7f665a50ef65d14eef53bfc2889f65 Mon Sep 17 00:00:00 2001 From: muzimuzhi Date: Mon, 23 May 2022 06:49:04 +0800 Subject: [PATCH 2/7] fixup! fix: add shortcuts to uninstallcommands Signed-off-by: muzimuzhi --- .../pgf/frontendlayer/tikz/tikz.code.tex | 46 +++++++++++++------ 1 file changed, 32 insertions(+), 14 deletions(-) diff --git a/tex/generic/pgf/frontendlayer/tikz/tikz.code.tex b/tex/generic/pgf/frontendlayer/tikz/tikz.code.tex index 8be767e30..10d985945 100644 --- a/tex/generic/pgf/frontendlayer/tikz/tikz.code.tex +++ b/tex/generic/pgf/frontendlayer/tikz/tikz.code.tex @@ -1899,25 +1899,43 @@ % #1: shortcut command inside of tikzpicture % #2: real command name \def\tikzaddtikzonlycommandshortcutlet#1#2{% - \expandafter\def\expandafter\tikz@installcommands\expandafter{\tikz@installcommands - \expandafter\let\csname tikz@orig\detokenize{#1}\expandafter\endcsname=#1% - \let#1=#2% - }% - \expandafter\def\expandafter\tikz@uninstallcommands\expandafter{\tikz@uninstallcommands - \expandafter\let\expandafter#1\csname tikz@orig\detokenize{#1}\endcsname - }% + \ifdefined#1% + \expandafter\def\expandafter\tikz@installcommands\expandafter{\tikz@installcommands + \expandafter\let\csname tikz@orig\detokenize{#1}\endcsname=#1% + \let#1=#2% + }% + \expandafter\def\expandafter\tikz@uninstallcommands\expandafter{\tikz@uninstallcommands + \expandafter\let\expandafter#1\csname tikz@orig\detokenize{#1}\endcsname + }% + \else + \expandafter\def\expandafter\tikz@installcommands\expandafter{\tikz@installcommands + \let#1=#2% + }% + \expandafter\def\expandafter\tikz@uninstallcommands\expandafter{\tikz@uninstallcommands + \let#1\pgfutil@undefined + }% + \fi }% % Has the same effect as \tikzaddtikzonlycommandshortcutlet but uses % \def#1{#2} instead of \let. \def\tikzaddtikzonlycommandshortcutdef#1#2{% - \expandafter\def\expandafter\tikz@installcommands\expandafter{\tikz@installcommands - \expandafter\let\csname tikz@orig\detokenize{#1}\endcsname=#1% - \def#1{#2}% - }% - \expandafter\def\expandafter\tikz@uninstallcommands\expandafter{\tikz@uninstallcommands - \expandafter\let\expandafter#1\csname tikz@orig\detokenize{#1}\endcsname - }% + \ifdefined#1% + \expandafter\def\expandafter\tikz@installcommands\expandafter{\tikz@installcommands + \expandafter\let\csname tikz@orig\detokenize{#1}\endcsname=#1% + \def#1{#2}% + }% + \expandafter\def\expandafter\tikz@uninstallcommands\expandafter{\tikz@uninstallcommands + \expandafter\let\expandafter#1\csname tikz@orig\detokenize{#1}\endcsname + }% + \else + \expandafter\def\expandafter\tikz@installcommands\expandafter{\tikz@installcommands + \def#1{#2}% + }% + \expandafter\def\expandafter\tikz@uninstallcommands\expandafter{\tikz@uninstallcommands + \let#1\pgfutil@undefined + }% + \fi }% % From 76d708c8b50f8e9b032cd6da677c2d611dbe96ab Mon Sep 17 00:00:00 2001 From: muzimuzhi Date: Mon, 23 May 2022 08:37:05 +0800 Subject: [PATCH 3/7] fixup! fix: add shortcuts to uninstallcommands Signed-off-by: muzimuzhi --- doc/generic/pgf/CHANGELOG.md | 2 + testfiles/gh-pull-1160.lvt | 53 +++++++++++++++++ testfiles/gh-pull-1160.tlg | 22 +++++++ .../pgf/frontendlayer/tikz/tikz.code.tex | 58 +++++++++---------- 4 files changed, 103 insertions(+), 32 deletions(-) create mode 100644 testfiles/gh-pull-1160.lvt create mode 100644 testfiles/gh-pull-1160.tlg diff --git a/doc/generic/pgf/CHANGELOG.md b/doc/generic/pgf/CHANGELOG.md index 5b4cff84c..bbffe35d4 100644 --- a/doc/generic/pgf/CHANGELOG.md +++ b/doc/generic/pgf/CHANGELOG.md @@ -81,6 +81,8 @@ lot of contributed changes. Thanks to everyone who volunteered their time! - Make `graphdrawing` work with `name prefix` and `name suffix` options #1087 - pgfkeys was a bit too relaxed around `\relax` #1132 - Remove spurious spaces for `3d view` #1151 +- Add shortcuts defined by `\tikzaddtikzonlycommandshortcut(def|let)` to + uninstallcommands #1160 ### Changed diff --git a/testfiles/gh-pull-1160.lvt b/testfiles/gh-pull-1160.lvt new file mode 100644 index 000000000..81eb9e561 --- /dev/null +++ b/testfiles/gh-pull-1160.lvt @@ -0,0 +1,53 @@ +\documentclass{minimal} +\input{pgf-regression-test} + +\RequirePackage{tikz} + +\begin{document} + +\START + +\def\myspecialsauce{\node{specialsauce}} + +\protected\long\def\ASSERTEQUAL{% + \ifx#1#2\TRUE\else\FALSE\fi +} +\let\UNDEFINED\undefined +\def\specialsauceOUTER{outer definition} + + +\BEGINTEST{\tikzaddtikzonlycommandshortcutlet, undefined} + \tikzaddtikzonlycommandshortcutlet{\specialsauce}{\myspecialsauce} + \begin{tikzpicture} + \specialsauce; + \node at (0,1) {\ASSERTEQUAL\specialsauce\UNDEFINED}; + \end{tikzpicture} +\ENDTEST + +\BEGINTEST{\tikzaddtikzonlycommandshortcutlet, defined} + \let\specialsauce\specialsauceOUTER + \tikzaddtikzonlycommandshortcutlet{\specialsauce}{\myspecialsauce} + \begin{tikzpicture} + \specialsauce; + \node at (0,1) {\ASSERTEQUAL\specialsauce\specialsauceOUTER}; + \end{tikzpicture} +\ENDTEST + +\BEGINTEST{\tikzaddtikzonlycommandshortcutdef, undefined} + \tikzaddtikzonlycommandshortcutdef{\specialsauce}{\myspecialsauce} + \begin{tikzpicture} + \specialsauce; + \node at (0,1) {\ASSERTEQUAL\specialsauce\UNDEFINED}; + \end{tikzpicture} +\ENDTEST + +\BEGINTEST{\tikzaddtikzonlycommandshortcutdef, defined} + \let\specialsauce\specialsauceOUTER + \tikzaddtikzonlycommandshortcutdef{\specialsauce}{\myspecialsauce} + \begin{tikzpicture} + \specialsauce; + \node at (0,1) {\ASSERTEQUAL\specialsauce\specialsauceOUTER}; + \end{tikzpicture} +\ENDTEST + +\END diff --git a/testfiles/gh-pull-1160.tlg b/testfiles/gh-pull-1160.tlg new file mode 100644 index 000000000..8e9eb6a31 --- /dev/null +++ b/testfiles/gh-pull-1160.tlg @@ -0,0 +1,22 @@ +This is a generated file for the l3build validation system. +Don't change this file in any respect. +============================================================ +TEST 1: \tikzaddtikzonlycommandshortcutlet , undefined +============================================================ +TRUE +============================================================ +============================================================ +TEST 2: \tikzaddtikzonlycommandshortcutlet , defined +============================================================ +TRUE +============================================================ +============================================================ +TEST 3: \tikzaddtikzonlycommandshortcutdef , undefined +============================================================ +TRUE +============================================================ +============================================================ +TEST 4: \tikzaddtikzonlycommandshortcutdef , defined +============================================================ +TRUE +============================================================ diff --git a/tex/generic/pgf/frontendlayer/tikz/tikz.code.tex b/tex/generic/pgf/frontendlayer/tikz/tikz.code.tex index 10d985945..aaaeebf48 100644 --- a/tex/generic/pgf/frontendlayer/tikz/tikz.code.tex +++ b/tex/generic/pgf/frontendlayer/tikz/tikz.code.tex @@ -1899,43 +1899,37 @@ % #1: shortcut command inside of tikzpicture % #2: real command name \def\tikzaddtikzonlycommandshortcutlet#1#2{% - \ifdefined#1% - \expandafter\def\expandafter\tikz@installcommands\expandafter{\tikz@installcommands - \expandafter\let\csname tikz@orig\detokenize{#1}\endcsname=#1% - \let#1=#2% - }% - \expandafter\def\expandafter\tikz@uninstallcommands\expandafter{\tikz@uninstallcommands - \expandafter\let\expandafter#1\csname tikz@orig\detokenize{#1}\endcsname - }% - \else - \expandafter\def\expandafter\tikz@installcommands\expandafter{\tikz@installcommands - \let#1=#2% - }% - \expandafter\def\expandafter\tikz@uninstallcommands\expandafter{\tikz@uninstallcommands - \let#1\pgfutil@undefined - }% - \fi + \edef\tikz@installcommands{\pgfutil@unexpanded\expandafter{\tikz@installcommands}% + \ifdefined#1% + \let\expandafter\noexpand\csname tikz@orig\detokenize{#1}\endcsname=\noexpand#1% + \fi + \pgfutil@unexpanded{\let#1=#2}% + }% + \edef\tikz@uninstallcommands{\pgfutil@unexpanded\expandafter{\tikz@uninstallcommands}% + \ifdefined#1% + \let\noexpand#1\expandafter\noexpand\csname tikz@orig\detokenize{#1}\endcsname + \else + \pgfutil@unexpanded{\let#1=\pgfutil@undefined}% + \fi + }% }% % Has the same effect as \tikzaddtikzonlycommandshortcutlet but uses % \def#1{#2} instead of \let. \def\tikzaddtikzonlycommandshortcutdef#1#2{% - \ifdefined#1% - \expandafter\def\expandafter\tikz@installcommands\expandafter{\tikz@installcommands - \expandafter\let\csname tikz@orig\detokenize{#1}\endcsname=#1% - \def#1{#2}% - }% - \expandafter\def\expandafter\tikz@uninstallcommands\expandafter{\tikz@uninstallcommands - \expandafter\let\expandafter#1\csname tikz@orig\detokenize{#1}\endcsname - }% - \else - \expandafter\def\expandafter\tikz@installcommands\expandafter{\tikz@installcommands - \def#1{#2}% - }% - \expandafter\def\expandafter\tikz@uninstallcommands\expandafter{\tikz@uninstallcommands - \let#1\pgfutil@undefined - }% - \fi + \edef\tikz@installcommands{\pgfutil@unexpanded\expandafter{\tikz@installcommands}% + \ifdefined#1% + \let\expandafter\noexpand\csname tikz@orig\detokenize{#1}\endcsname=\noexpand#1% + \fi + \pgfutil@unexpanded{\def#1{#2}}% + }% + \edef\tikz@uninstallcommands{\pgfutil@unexpanded\expandafter{\tikz@uninstallcommands}% + \ifdefined#1% + \let\noexpand#1\expandafter\noexpand\csname tikz@orig\detokenize{#1}\endcsname + \else + \pgfutil@unexpanded{\let#1=\pgfutil@undefined}% + \fi + }% }% % From a26ef26466090ee80c6050c22abcff9453496705 Mon Sep 17 00:00:00 2001 From: muzimuzhi Date: Mon, 23 May 2022 08:41:21 +0800 Subject: [PATCH 4/7] fixup! fix: add shortcuts to uninstallcommands Signed-off-by: muzimuzhi --- testfiles/gh-pull-1160.lvt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testfiles/gh-pull-1160.lvt b/testfiles/gh-pull-1160.lvt index 81eb9e561..6b4e76da0 100644 --- a/testfiles/gh-pull-1160.lvt +++ b/testfiles/gh-pull-1160.lvt @@ -9,7 +9,7 @@ \def\myspecialsauce{\node{specialsauce}} -\protected\long\def\ASSERTEQUAL{% +\protected\long\def\ASSERTEQUAL#1#2{% \ifx#1#2\TRUE\else\FALSE\fi } \let\UNDEFINED\undefined From d39c2a402f071405251847ff864fc82112848f76 Mon Sep 17 00:00:00 2001 From: muzimuzhi Date: Tue, 24 May 2022 05:10:30 +0800 Subject: [PATCH 5/7] fixup! fix: add shortcuts to uninstallcommands Signed-off-by: muzimuzhi --- testfiles/gh-pull-1160.lvt | 47 ++++++++++++------- testfiles/gh-pull-1160.tlg | 16 +++++-- .../pgf/frontendlayer/tikz/tikz.code.tex | 36 +++++++------- 3 files changed, 62 insertions(+), 37 deletions(-) diff --git a/testfiles/gh-pull-1160.lvt b/testfiles/gh-pull-1160.lvt index 6b4e76da0..6a2779366 100644 --- a/testfiles/gh-pull-1160.lvt +++ b/testfiles/gh-pull-1160.lvt @@ -15,39 +15,50 @@ \let\UNDEFINED\undefined \def\specialsauceOUTER{outer definition} +\def\test#1{% + \begin{tikzpicture} + \specialsauce; + \node at (0,1) {\ASSERTEQUAL\specialsauce#1}; + \end{tikzpicture}% +} \BEGINTEST{\tikzaddtikzonlycommandshortcutlet, undefined} \tikzaddtikzonlycommandshortcutlet{\specialsauce}{\myspecialsauce} - \begin{tikzpicture} - \specialsauce; - \node at (0,1) {\ASSERTEQUAL\specialsauce\UNDEFINED}; - \end{tikzpicture} + \test{\UNDEFINED} \ENDTEST -\BEGINTEST{\tikzaddtikzonlycommandshortcutlet, defined} +\BEGINTEST{\tikzaddtikzonlycommandshortcutlet, defined before} + \def\myspecialsauce{\node{specialsauce}} \let\specialsauce\specialsauceOUTER \tikzaddtikzonlycommandshortcutlet{\specialsauce}{\myspecialsauce} - \begin{tikzpicture} - \specialsauce; - \node at (0,1) {\ASSERTEQUAL\specialsauce\specialsauceOUTER}; - \end{tikzpicture} + \test{\specialsauceOUTER} +\ENDTEST + +\BEGINTEST{\tikzaddtikzonlycommandshortcutlet, defined after} + \def\myspecialsauce{\node{specialsauce}} + \tikzaddtikzonlycommandshortcutlet{\specialsauce}{\myspecialsauce} + \let\specialsauce\specialsauceOUTER + \test{\specialsauceOUTER} \ENDTEST \BEGINTEST{\tikzaddtikzonlycommandshortcutdef, undefined} + \def\myspecialsauce{\node{specialsauce}} \tikzaddtikzonlycommandshortcutdef{\specialsauce}{\myspecialsauce} - \begin{tikzpicture} - \specialsauce; - \node at (0,1) {\ASSERTEQUAL\specialsauce\UNDEFINED}; - \end{tikzpicture} + \test{\UNDEFINED} \ENDTEST -\BEGINTEST{\tikzaddtikzonlycommandshortcutdef, defined} +\BEGINTEST{\tikzaddtikzonlycommandshortcutdef, defined before} + \def\myspecialsauce{\node{specialsauce}} \let\specialsauce\specialsauceOUTER \tikzaddtikzonlycommandshortcutdef{\specialsauce}{\myspecialsauce} - \begin{tikzpicture} - \specialsauce; - \node at (0,1) {\ASSERTEQUAL\specialsauce\specialsauceOUTER}; - \end{tikzpicture} + \test{\specialsauceOUTER} +\ENDTEST + +\BEGINTEST{\tikzaddtikzonlycommandshortcutdef, defined after} + \def\myspecialsauce{\node{specialsauce}} + \tikzaddtikzonlycommandshortcutdef{\specialsauce}{\myspecialsauce} + \let\specialsauce\specialsauceOUTER + \test{\specialsauceOUTER} \ENDTEST \END diff --git a/testfiles/gh-pull-1160.tlg b/testfiles/gh-pull-1160.tlg index 8e9eb6a31..e0c6f6d64 100644 --- a/testfiles/gh-pull-1160.tlg +++ b/testfiles/gh-pull-1160.tlg @@ -6,17 +6,27 @@ TEST 1: \tikzaddtikzonlycommandshortcutlet , undefined TRUE ============================================================ ============================================================ -TEST 2: \tikzaddtikzonlycommandshortcutlet , defined +TEST 2: \tikzaddtikzonlycommandshortcutlet , defined before ============================================================ TRUE ============================================================ ============================================================ -TEST 3: \tikzaddtikzonlycommandshortcutdef , undefined +TEST 3: \tikzaddtikzonlycommandshortcutlet , defined after ============================================================ TRUE ============================================================ ============================================================ -TEST 4: \tikzaddtikzonlycommandshortcutdef , defined +TEST 4: \tikzaddtikzonlycommandshortcutdef , undefined +============================================================ +TRUE +============================================================ +============================================================ +TEST 5: \tikzaddtikzonlycommandshortcutdef , defined before +============================================================ +TRUE +============================================================ +============================================================ +TEST 6: \tikzaddtikzonlycommandshortcutdef , defined after ============================================================ TRUE ============================================================ diff --git a/tex/generic/pgf/frontendlayer/tikz/tikz.code.tex b/tex/generic/pgf/frontendlayer/tikz/tikz.code.tex index aaaeebf48..6cb246e61 100644 --- a/tex/generic/pgf/frontendlayer/tikz/tikz.code.tex +++ b/tex/generic/pgf/frontendlayer/tikz/tikz.code.tex @@ -1899,37 +1899,41 @@ % #1: shortcut command inside of tikzpicture % #2: real command name \def\tikzaddtikzonlycommandshortcutlet#1#2{% + \ifcsname tikz@orig\detokenize{#1}\endcsname + \let\pgfutil@tempa=\pgfutil@empty + \else + \def\pgfutil@tempa{% + \expandafter\let\csname tikz@orig\detokenize{#1}\endcsname\pgfutil@undefined + } + \fi \edef\tikz@installcommands{\pgfutil@unexpanded\expandafter{\tikz@installcommands}% - \ifdefined#1% - \let\expandafter\noexpand\csname tikz@orig\detokenize{#1}\endcsname=\noexpand#1% - \fi + \let\expandafter\noexpand\csname tikz@orig\detokenize{#1}\endcsname=\noexpand#1% \pgfutil@unexpanded{\let#1=#2}% }% \edef\tikz@uninstallcommands{\pgfutil@unexpanded\expandafter{\tikz@uninstallcommands}% - \ifdefined#1% - \let\noexpand#1\expandafter\noexpand\csname tikz@orig\detokenize{#1}\endcsname - \else - \pgfutil@unexpanded{\let#1=\pgfutil@undefined}% - \fi + \let\noexpand#1\expandafter\noexpand\csname tikz@orig\detokenize{#1}\endcsname }% + \pgfutil@tempa }% % Has the same effect as \tikzaddtikzonlycommandshortcutlet but uses % \def#1{#2} instead of \let. \def\tikzaddtikzonlycommandshortcutdef#1#2{% + \ifcsname tikz@orig\detokenize{#1}\endcsname + \let\pgfutil@tempa=\pgfutil@empty + \else + \def\pgfutil@tempa{% + \expandafter\let\csname tikz@orig\detokenize{#1}\endcsname\pgfutil@undefined + } + \fi \edef\tikz@installcommands{\pgfutil@unexpanded\expandafter{\tikz@installcommands}% - \ifdefined#1% - \let\expandafter\noexpand\csname tikz@orig\detokenize{#1}\endcsname=\noexpand#1% - \fi + \let\expandafter\noexpand\csname tikz@orig\detokenize{#1}\endcsname=\noexpand#1% \pgfutil@unexpanded{\def#1{#2}}% }% \edef\tikz@uninstallcommands{\pgfutil@unexpanded\expandafter{\tikz@uninstallcommands}% - \ifdefined#1% - \let\noexpand#1\expandafter\noexpand\csname tikz@orig\detokenize{#1}\endcsname - \else - \pgfutil@unexpanded{\let#1=\pgfutil@undefined}% - \fi + \let\noexpand#1\expandafter\noexpand\csname tikz@orig\detokenize{#1}\endcsname }% + \pgfutil@tempa }% % From e26218b12c678f7e82c5458a0dea54a4d612512c Mon Sep 17 00:00:00 2001 From: muzimuzhi Date: Thu, 9 Jun 2022 15:47:38 +0800 Subject: [PATCH 6/7] fixup! fix: add shortcuts to uninstallcommands Signed-off-by: muzimuzhi --- testfiles/gh-pull-1160.lvt | 8 ++------ testfiles/gh-pull-1160.tlg | 12 ++++++------ testfiles/support/pgf-regression-test.tex | 18 ++++++++++++++++++ 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/testfiles/gh-pull-1160.lvt b/testfiles/gh-pull-1160.lvt index 6a2779366..c3f1e048a 100644 --- a/testfiles/gh-pull-1160.lvt +++ b/testfiles/gh-pull-1160.lvt @@ -8,17 +8,13 @@ \START \def\myspecialsauce{\node{specialsauce}} - -\protected\long\def\ASSERTEQUAL#1#2{% - \ifx#1#2\TRUE\else\FALSE\fi -} -\let\UNDEFINED\undefined \def\specialsauceOUTER{outer definition} +\let\UNDEFINED\undefined \def\test#1{% \begin{tikzpicture} \specialsauce; - \node at (0,1) {\ASSERTEQUAL\specialsauce#1}; + \node at (0,1) {\AssertEquals\specialsauce#1}; \end{tikzpicture}% } diff --git a/testfiles/gh-pull-1160.tlg b/testfiles/gh-pull-1160.tlg index e0c6f6d64..1ddc1f493 100644 --- a/testfiles/gh-pull-1160.tlg +++ b/testfiles/gh-pull-1160.tlg @@ -3,30 +3,30 @@ Don't change this file in any respect. ============================================================ TEST 1: \tikzaddtikzonlycommandshortcutlet , undefined ============================================================ -TRUE +PASSED ============================================================ ============================================================ TEST 2: \tikzaddtikzonlycommandshortcutlet , defined before ============================================================ -TRUE +PASSED ============================================================ ============================================================ TEST 3: \tikzaddtikzonlycommandshortcutlet , defined after ============================================================ -TRUE +PASSED ============================================================ ============================================================ TEST 4: \tikzaddtikzonlycommandshortcutdef , undefined ============================================================ -TRUE +PASSED ============================================================ ============================================================ TEST 5: \tikzaddtikzonlycommandshortcutdef , defined before ============================================================ -TRUE +PASSED ============================================================ ============================================================ TEST 6: \tikzaddtikzonlycommandshortcutdef , defined after ============================================================ -TRUE +PASSED ============================================================ diff --git a/testfiles/support/pgf-regression-test.tex b/testfiles/support/pgf-regression-test.tex index 9b2aa9573..8df928f9a 100644 --- a/testfiles/support/pgf-regression-test.tex +++ b/testfiles/support/pgf-regression-test.tex @@ -38,4 +38,22 @@ \ENDTEST } +% more typeout commands +\def\PASSED {\TYPE{PASSED}} +\def\FAILED {\TYPE{FAILED}} +\long\def\FAILEDAT#1{\TYPE{FAILED at #1}} + +% more assert commands, which if fails will typeout more diagnostic info +\protected\long\def\AssertEquals#1#2{% + \ifx#1#2% + \PASSED + \else + \FAILEDAT{\string\AssertEquals\detokenize{{#1}{#2}}}% + \TYPE{% + - Expected: \meaning#1^^J% + - Actual: \space\space \meaning#2% + }% + \fi +} + \TIMO From 2f09b26041287fc653e105e29e2fb6a040ecbe6a Mon Sep 17 00:00:00 2001 From: muzimuzhi Date: Fri, 10 Jun 2022 02:03:26 +0800 Subject: [PATCH 7/7] feat: allow simple picture nesting Signed-off-by: muzimuzhi --- testfiles/gh-pull-1160.lvt | 61 ++++++++++++------- testfiles/gh-pull-1160.tlg | 60 ++++++++++++++++-- .../pgf/frontendlayer/tikz/tikz.code.tex | 6 +- 3 files changed, 99 insertions(+), 28 deletions(-) diff --git a/testfiles/gh-pull-1160.lvt b/testfiles/gh-pull-1160.lvt index c3f1e048a..9845cbaa5 100644 --- a/testfiles/gh-pull-1160.lvt +++ b/testfiles/gh-pull-1160.lvt @@ -8,53 +8,72 @@ \START \def\myspecialsauce{\node{specialsauce}} -\def\specialsauceOUTER{outer definition} \let\UNDEFINED\undefined -\def\test#1{% +\def\AssertInner{\AssertEquals\specialsauce\specialsauceINNER} +\def\AssertOuter{\AssertEquals\specialsauce\specialsauceOUTER} + +\def\test{% + \AssertOuter \begin{tikzpicture} + \AssertInner \specialsauce; - \node at (0,1) {\AssertEquals\specialsauce#1}; - \end{tikzpicture}% + \node at (0,1) + {\AssertOuter \tikz {\AssertInner\node {\AssertOuter};} \AssertOuter}; + \tikz {\AssertInner \node {\AssertOuter};} + \end{tikzpicture} + \AssertOuter } -\BEGINTEST{\tikzaddtikzonlycommandshortcutlet, undefined} +% shortcut is \specialsauce +\BEGINTEST{shortcutlet, shortcut undefined ouside} + \let\specialsauceINNER=\myspecialsauce \tikzaddtikzonlycommandshortcutlet{\specialsauce}{\myspecialsauce} - \test{\UNDEFINED} + + \test \ENDTEST -\BEGINTEST{\tikzaddtikzonlycommandshortcutlet, defined before} - \def\myspecialsauce{\node{specialsauce}} +\BEGINTEST{shortcutlet, shortcut defined outside before doing shortcutlet} + \let\specialsauceINNER=\myspecialsauce + \def\specialsauceOUTER{outer definition} \let\specialsauce\specialsauceOUTER \tikzaddtikzonlycommandshortcutlet{\specialsauce}{\myspecialsauce} - \test{\specialsauceOUTER} + + \test \ENDTEST -\BEGINTEST{\tikzaddtikzonlycommandshortcutlet, defined after} - \def\myspecialsauce{\node{specialsauce}} +\BEGINTEST{shortcutlet, shortcut defined outside after doing shortcutlet} + \let\specialsauceINNER=\myspecialsauce + \def\specialsauceOUTER{outer definition} \tikzaddtikzonlycommandshortcutlet{\specialsauce}{\myspecialsauce} \let\specialsauce\specialsauceOUTER - \test{\specialsauceOUTER} + + \test \ENDTEST -\BEGINTEST{\tikzaddtikzonlycommandshortcutdef, undefined} - \def\myspecialsauce{\node{specialsauce}} +\BEGINTEST{shortcutdef, shortcut undefined outside} + \def\specialsauceINNER{\myspecialsauce} \tikzaddtikzonlycommandshortcutdef{\specialsauce}{\myspecialsauce} - \test{\UNDEFINED} + + \test \ENDTEST -\BEGINTEST{\tikzaddtikzonlycommandshortcutdef, defined before} - \def\myspecialsauce{\node{specialsauce}} +\BEGINTEST{shortcutdef, shortcut defined outside before doing shortcutdef} + \def\specialsauceINNER{\myspecialsauce} + \def\specialsauceOUTER{outer definition} \let\specialsauce\specialsauceOUTER \tikzaddtikzonlycommandshortcutdef{\specialsauce}{\myspecialsauce} - \test{\specialsauceOUTER} + + \test \ENDTEST -\BEGINTEST{\tikzaddtikzonlycommandshortcutdef, defined after} - \def\myspecialsauce{\node{specialsauce}} +\BEGINTEST{shortcutdef, shortcut defined outside after doing shortcutdef} + \def\specialsauceINNER{\myspecialsauce} + \def\specialsauceOUTER{outer definition} \tikzaddtikzonlycommandshortcutdef{\specialsauce}{\myspecialsauce} \let\specialsauce\specialsauceOUTER - \test{\specialsauceOUTER} + + \test \ENDTEST \END diff --git a/testfiles/gh-pull-1160.tlg b/testfiles/gh-pull-1160.tlg index 1ddc1f493..c5b673cf9 100644 --- a/testfiles/gh-pull-1160.tlg +++ b/testfiles/gh-pull-1160.tlg @@ -1,32 +1,80 @@ This is a generated file for the l3build validation system. Don't change this file in any respect. ============================================================ -TEST 1: \tikzaddtikzonlycommandshortcutlet , undefined +TEST 1: shortcutlet, shortcut undefined ouside ============================================================ PASSED +PASSED +PASSED +PASSED +PASSED +PASSED +PASSED +PASSED +PASSED ============================================================ ============================================================ -TEST 2: \tikzaddtikzonlycommandshortcutlet , defined before +TEST 2: shortcutlet, shortcut defined outside before doing shortcutlet ============================================================ PASSED +PASSED +PASSED +PASSED +PASSED +PASSED +PASSED +PASSED +PASSED ============================================================ ============================================================ -TEST 3: \tikzaddtikzonlycommandshortcutlet , defined after +TEST 3: shortcutlet, shortcut defined outside after doing shortcutlet ============================================================ PASSED +PASSED +PASSED +PASSED +PASSED +PASSED +PASSED +PASSED +PASSED ============================================================ ============================================================ -TEST 4: \tikzaddtikzonlycommandshortcutdef , undefined +TEST 4: shortcutdef, shortcut undefined outside ============================================================ PASSED +PASSED +PASSED +PASSED +PASSED +PASSED +PASSED +PASSED +PASSED ============================================================ ============================================================ -TEST 5: \tikzaddtikzonlycommandshortcutdef , defined before +TEST 5: shortcutdef, shortcut defined outside before doing shortcutdef ============================================================ PASSED +PASSED +PASSED +PASSED +PASSED +PASSED +PASSED +PASSED +PASSED ============================================================ ============================================================ -TEST 6: \tikzaddtikzonlycommandshortcutdef , defined after +TEST 6: shortcutdef, shortcut defined outside after doing shortcutdef ============================================================ PASSED +PASSED +PASSED +PASSED +PASSED +PASSED +PASSED +PASSED +PASSED ============================================================ diff --git a/tex/generic/pgf/frontendlayer/tikz/tikz.code.tex b/tex/generic/pgf/frontendlayer/tikz/tikz.code.tex index 6cb246e61..dc0889ed3 100644 --- a/tex/generic/pgf/frontendlayer/tikz/tikz.code.tex +++ b/tex/generic/pgf/frontendlayer/tikz/tikz.code.tex @@ -1727,7 +1727,11 @@ \let\tikz@atend@picture=\pgfutil@empty% \let\tikz@transform=\relax% \def\tikz@time{.5}% - \tikz@installcommands% + \iftikz@inside@picture + \else + \tikz@installcommands% + \tikz@inside@picturetrue + \fi \scope[every picture,#1]% \iftikz@handle@active@code% \tikz@switchoff@shorthands%