-
Notifications
You must be signed in to change notification settings - Fork 111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix foreach not remembering nodes between iterations #1304
Changes from all commits
ad03942
937b354
5d98602
de96d67
4240ad6
4f0b709
f39dd0d
1f85761
1c843a9
bd9613b
f49f0c9
a85413f
27ad7c4
9e0d878
f6c7d00
aee5b41
a78e964
b184f93
e09607f
f2399b3
2580e30
467766f
b6734d9
d2b1d22
0963b67
12a38a9
e988e66
8b6ee86
1d3535f
7371bd4
742ce71
987e851
6ce8705
ece59e9
d436492
ae9d592
a1a947c
73ea508
67d9326
810f682
41c0cea
07a5d00
37d73a2
134da12
503dc63
3100454
5c26f95
292fa1d
bb712ea
eff182f
bf8d893
3d03d02
61ba843
f35286d
c46ed90
7eb346a
5fb6ca9
f2fa2e4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2580,28 +2580,77 @@ | |
|
||
\def\tikz@fchar oreach{\tikz@foreach}% | ||
|
||
|
||
% | ||
% These are to allow \foreach to remember macros and dimensions between iterations | ||
% | ||
|
||
\def\tikzforeach@smugglers@cove{} | ||
\let\tikztostart=\relax | ||
|
||
\def\tikzforeach@smuggle@macro#1{% | ||
\pgfutil@ifx#1\relax{}{% | ||
\expandafter | ||
\pgfutil@g@addto@macro | ||
\expandafter | ||
\tikzforeach@smugglers@cove | ||
\expandafter | ||
{% | ||
\expandafter\def\expandafter#1\expandafter{#1}% | ||
}% | ||
}% | ||
} | ||
|
||
\def\tikzforeach@smuggle@dimen#1{% | ||
\pgfutil@ifx#1\relax{}{% | ||
\expandafter | ||
\pgfutil@g@addto@macro | ||
\expandafter | ||
\tikzforeach@smugglers@cove | ||
\expandafter | ||
{% | ||
\expandafter#1\expandafter=\the#1\relax% | ||
}% | ||
}% | ||
} | ||
|
||
\def\tikzforeach@smugglers@loot{% | ||
% | ||
\tikzforeach@smuggle@macro\tikz@moveto@waiting% | ||
\tikzforeach@smuggle@macro\tikztostart% | ||
\tikzforeach@smuggle@macro\tikz@tangent% | ||
% | ||
\tikzforeach@smuggle@dimen\tikz@lastx% | ||
\tikzforeach@smuggle@dimen\tikz@lasty% | ||
\tikzforeach@smuggle@dimen\tikz@lastxsaved% | ||
\tikzforeach@smuggle@dimen\tikz@lastysaved% | ||
% | ||
} | ||
Comment on lines
+2591
to
+2628
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like this approach (and the naming scheme 😁), but I think it would be even better if we could make this more general using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are you happy with just |
||
|
||
\tikzset{ | ||
remember macro/.code={ | ||
\tikzforeach@smuggle@macro#1 | ||
}, | ||
remember dimension/.code={ | ||
\tikzforeach@smuggle@dimen#1 | ||
} | ||
} | ||
|
||
\def\tikz@foreach{% | ||
\def\pgffor@beginhook{% | ||
\tikz@lastx=\tikz@foreach@save@lastx% | ||
\tikz@lasty=\tikz@foreach@save@lasty% | ||
\tikz@lastxsaved=\tikz@foreach@save@lastxsaved% | ||
\tikz@lastysaved=\tikz@foreach@save@lastysaved% | ||
\tikzforeach@smugglers@cove% | ||
\gdef\tikzforeach@smugglers@cove{}% | ||
\setbox\tikz@figbox=\box\tikz@tempbox% | ||
\setbox\tikz@figbox@bg=\box\tikz@tempbox@bg% | ||
\expandafter\tikz@scan@next@command\pgfutil@firstofone}% | ||
\def\pgffor@endhook{\pgfextra{% | ||
\xdef\tikz@foreach@save@lastx{\the\tikz@lastx}% | ||
\xdef\tikz@foreach@save@lasty{\the\tikz@lasty}% | ||
\xdef\tikz@foreach@save@lastxsaved{\the\tikz@lastxsaved}% | ||
\xdef\tikz@foreach@save@lastysaved{\the\tikz@lastysaved}% | ||
\tikzforeach@smugglers@loot% | ||
\global\setbox\tikz@tempbox=\box\tikz@figbox% | ||
\global\setbox\tikz@tempbox@bg=\box\tikz@figbox@bg% | ||
\pgfutil@gobble}}% | ||
\def\pgffor@afterhook{% | ||
\tikz@lastx=\tikz@foreach@save@lastx% | ||
\tikz@lasty=\tikz@foreach@save@lasty% | ||
\tikz@lastxsaved=\tikz@foreach@save@lastxsaved% | ||
\tikz@lastysaved=\tikz@foreach@save@lastysaved% | ||
\tikzforeach@smugglers@cove | ||
\gdef\tikzforeach@smugglers@cove{}% | ||
\let\pgffor@beginhook\relax% | ||
\let\pgffor@endhook\relax% | ||
\let\pgffor@afterhook\relax% | ||
|
@@ -2610,13 +2659,9 @@ | |
\tikz@scan@next@command}% | ||
\global\setbox\tikz@tempbox=\box\tikz@figbox% | ||
\global\setbox\tikz@tempbox@bg=\box\tikz@figbox@bg% | ||
\xdef\tikz@foreach@save@lastx{\the\tikz@lastx}% | ||
\xdef\tikz@foreach@save@lasty{\the\tikz@lasty}% | ||
\xdef\tikz@foreach@save@lastxsaved{\the\tikz@lastxsaved}% | ||
\xdef\tikz@foreach@save@lastysaved{\the\tikz@lastysaved}% | ||
\tikzforeach@smugglers@loot% | ||
\foreach}% | ||
|
||
|
||
% Syntax for againpath: | ||
% \againpath \somepathname | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe move this to
tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarytopaths.code.tex
where\tikztostart
(and\tikztotarget
) originally come from.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had a look at
tikzlibrarytopaths.code.tex
and while that is where\tikztostart
is used, it is never defined there. The definitions are contained in the core TikZ parser in that whenever TikZ encounters a coordinate then it sets\tikztostart
to something sensible so that if the next command is ato
path then the start is set up correctly. Similarly with\tikz@tangent
(which is mainly used in thecalc
library).So I'm happy to move it, but just want to double-check first.