From 6fde3f8617ebf837a452f38c9d715f70d93e71e2 Mon Sep 17 00:00:00 2001
From: Karl Berry <karl@freefriends.org>
Date: Mon, 11 Dec 2017 22:22:32 +0000
Subject: spectralsequences (11dec17)

git-svn-id: svn://tug.org/texlive/trunk@46038 c570f23f-e606-0410-a88d-b1316a301751
---
 .../tex/latex/spectralsequences/sseqmain.code.tex  | 262 ++++++++++++++++-----
 1 file changed, 200 insertions(+), 62 deletions(-)

(limited to 'Master/texmf-dist/tex/latex/spectralsequences/sseqmain.code.tex')

diff --git a/Master/texmf-dist/tex/latex/spectralsequences/sseqmain.code.tex b/Master/texmf-dist/tex/latex/spectralsequences/sseqmain.code.tex
index d33fcf15c67..d69b28d2041 100644
--- a/Master/texmf-dist/tex/latex/spectralsequences/sseqmain.code.tex
+++ b/Master/texmf-dist/tex/latex/spectralsequences/sseqmain.code.tex
@@ -1,8 +1,8 @@
 %%
-%% Package: spectralsequences v1.1.1 2017-09-16 2017-09-16
+%% Package: spectralsequences v1.2.0 2017-09-16 2017-09-16
 %% Author: Hood Chatham
 %% Email: hood@mit.edu
-%% Date: 2017-09-16
+%% Date: 2017-12-10
 %% License: Latex Project Public License
 %%
 %% File: sseqmain.code.tex
@@ -63,6 +63,12 @@
     \sseq@installmacros
     \sseq@installmsghooks
     \sseq@install@xparse@Uarggrabber
+    % The behavior of xmax and xmin is very particular, so it's best not to mess with them. 
+    % In particular, they shouldn't be expanded until printing no matter what, but we don't want
+    % \pgfmathparse to barf on them. \pgfmathparse really doesn't like engine protected macros,
+    % so in no case should this be engine protected. (Wish we could test an argument for the presence 
+    % of engine protected macros). If we try to do that, \sseq@ifpgfmathexpr will break in 
+    % \sseq@tikzprimitives@coords@notaclass@handle@.
     \def\xmin{\protect\sseq@xmin}\def\xmax{\protect\sseq@xmax}
     \def\ymin{\protect\sseq@ymin}\def\ymax{\protect\sseq@ymax}
 %
@@ -96,7 +102,7 @@
         \global\let\@xp\@nx\csname pgfk@/sseqpages/global/{\sseq@currentoptionpath} options/.@cmd\endcsname
             \@xp\@nx\csname pgfk@/sseqpages/global/{\sseq@currentoptionpath} options/.@cmd\endcsname
     }
-    \sseq@savedpaths@xadd{\sseq@stylelist}
+    \sseq@savedpaths@xadd{\@nx\sseq@style@object{\sseq@stylelist}}
     \sseq@savedpaths@add{\begingroup} % prevent some of the two-pass user macros horrors
     \let\sseq@error@setup\sseq@error@setup@withinfo
 }
@@ -218,6 +224,10 @@
 %
     \ifx\sseq@xmin\sseq@infinity\sseq@error{no-range}\def\sseq@xmin{0}\def\sseq@xmax{0}\@xp\sseq@break\fi % could be warning
     \ifx\sseq@ymin\sseq@infinity\sseq@error{no-range}\def\sseq@ymin{0}\def\sseq@ymax{0}\@xp\sseq@break\fi
+    \let\xmin\sseq@xmin
+    \let\xmax\sseq@xmax
+    \let\ymin\sseq@ymin
+    \let\ymax\sseq@ymax
 %
     \ifnum\numexpr\sseq@xmax-\sseq@xmin\relax>\numexpr\maxdimen/\dimexpr1pt\relax-1\relax
         \sseq@error@xx{range-super-overflow}{x}
@@ -266,7 +276,6 @@
     \sseq@setlayoutparameters
     \begin{tikzpicture}[/sseqpages/global/{default} options,\ifsseq@hasname/sseqpages/global/{\sseq@thename} options\fi,/sseqpages/global/{this page} options]%
     \sseq@sseqstyle@globalpart
-    %\pgftransformreset
     \sseq@globaldetonetransform
     \sseq@globalscaletransform
 %
@@ -315,7 +324,6 @@
     \ifsseq@mathnodes
         \tikzset{execute at begin node=$,execute at end node=$}%
     \fi
-    %\let\sseq@error@setup\sseq@error@setup@withinfo
 %
     \begingroup
     \sseq@savedbackgroundpaths
@@ -324,10 +332,10 @@
     \sseq@useclip
 %
     \ifsseq@drawdifferentials\else
-        \let\sseq@differential@draw@ifpage\@gobble
+        \let\sseq@differential@object\@gobble
     \fi
     \ifsseq@drawstructlines\else
-        \let\sseq@structline@draw@ifpage\@gobble
+        \let\sseq@structline@object\@gobble
     \fi
 %
     \sseq@usesavedpaths
@@ -351,12 +359,48 @@
     \end{sseqpage}%
 }
 
+
+\def\SseqCopyPage#1#2#3{
+    \begingroup
+    \def#1{\begingroup}
+    \global\let\sseq@copymacro\empty
+    \def\sseq@thename{#2}
+    \global\let\sseq@savedpaths@save\sseq@savedpaths
+    \sseq@storelist@get\sseq@savedpaths
+    \def\sseq@thepage{#3}
+    \sseq@thepagecount=#3\relax
+    \def\sseq@beginscope@object{\sseq@g@addto@macro#1{\sseq@savedpaths@add{\sseq@beginscope@object}}}
+    \def\sseq@endscope@object{\sseq@g@addto@macro#1{\sseq@savedpaths@add{\sseq@endscope@object}}}
+    \def\sseq@scope@object##1{\sseq@g@addto@macro#1{\sseq@savedpaths@add{\sseq@scope@object{##1}}}}
+    \def\sseq@style@object##1{\sseq@g@addto@macro#1{\sseq@savedpaths@add{\sseq@style@object{##1}}}}
+    \let\sseq@class@drawnode\sseq@copypage@addclass
+    \let\sseq@differential@object\@gobble
+    \let\sseq@structline@draw\sseq@copypage@addstructline
+    \let\sseq@tikzpath@object\@gobble
+    \let\sseq@pgfkeysdocommand\@gobbletwo
+    \sseq@savedpaths
+    \sseq@g@addto@macro#1{\endgroup}
+    \endgroup
+    \@xp\let\csname\sseq@macroname#1 code\endcsname\sseq@copymacro
+    \DeclareSseqGroup #1 {} { \csname\sseq@macroname#1 code\endcsname }
+    \let\sseq@savedpaths\sseq@savedpaths@save
+}
+
+\def\sseq@copypage@addclass#1{
+    \sseq@x@addto@macro\sseq@copymacro{\@nx\sseq@class@copy{\sseq@thename}{#1}}
+}
+
+\def\sseq@copypage@addstructline#1{
+    \sseq@x@addto@macro\sseq@copymacro{\@nx\sseq@structline@copy{\sseq@thename}{#1}}
+}
+
+
 %%% Scope
 \newcount\sseq@scope@savestackid
 \def\sseq@scope@secondpasstoks{}
 \def\sseq@scope{\@ifnextchar[{\sseq@scope@}{\sseq@scope@[]}}%]
 \def\sseq@scope@[#1]{%
-    \sseq@scope@savedpaths@add{\begin{scope}}%
+    \sseq@scope@savedpaths@add{\sseq@beginscope@object}%
     % This is a funky hack to fix a problem with shifts. On tmfass, if we don't handle shifts specially, we actually put so much stuff into
     % this \sseq@scope@secondpasstoks macro that we exceed TeX's upper bound for the maximum total macro memory. Or something like that -- I don't understand the error,
     % but it definitely only depends on how much stuff there is overall and on there being lots of scopes, not on any particular part of the diagram.
@@ -364,12 +408,12 @@
     \let\sseq@options@scopeshiftsecondpass\sseq@scope@savedpaths@add
     \sseq@processoptions{scope}{#1}% outputs into \sseq@savedoptioncode
     \edef\sseq@scope@secondpasstoks{\unexpanded\@xp{\sseq@scope@secondpasstoks}\unexpanded\@xp{\sseq@savedoptioncode}}
-    \sseq@eval{\@nx\sseq@scope@savedpaths@add{\sseq@scope@toks{\unexpanded\@xp{\sseq@scope@secondpasstoks}}}}%
+    \sseq@eval{\@nx\sseq@scope@savedpaths@add{\@nx\sseq@scope@object{\sseq@scope@toks{\unexpanded\@xp{\sseq@scope@secondpasstoks}}}}}%
     %\advance\sseq@scope@savestackid\@ne
     %\sseq@savestack@name{scope@save\the\sseq@scope@savestackid}
 }
 \def\sseq@endscope{%
-    \sseq@scope@savedpaths@add{\end{scope}}
+    \sseq@scope@savedpaths@add{\sseq@endscope@object}
     %\sseq@restorestack@name{scope@save\the\sseq@scope@savestackid
 }
 
@@ -411,11 +455,11 @@
             \sseq@obj@xdef{partcoord.(\partialcoord).tag.\sseq@class@tagprefix\sseq@class@tag}{\nodenum}%
         \fi
         \ifx\sseq@class@name\pgfutil@empty\else
-            \sseq@cleanup@obj{class.\classname.name}
-            \sseq@cleanup@obj{class.namedclass.\sseq@class@name}
+            \sseq@cleanup@obj{\classname.name}
+            \sseq@cleanup@obj{class.namedclass.\detokenize\@xp{\sseq@class@name}}
             \sseq@namehandler
-            \sseq@obj@xdef{class.\classname.name}{\sseq@class@name}
-            \sseq@obj@xdef{class.namedclass.\sseq@class@name}{\coordnopar}
+            \sseq@obj@xdef{\classname.name}{\sseq@class@name}
+            \sseq@obj@xdef{class.namedclass.\detokenize\@xp{\sseq@class@name}}{\coordnopar}
         \fi
         \sseq@breakpoint
         \endgroup
@@ -463,7 +507,14 @@
         \sseq@breakfi
     \fi
 %%%% No more breaks after this point
+
+    \sseq@processlabels % This sets up the label nodes, now that we know the position of the class (I think that's what we needed?)
+    \sseq@class@main % We segment off the main part of the class so that we can call it separately from the copy method
+    \sseq@breakpoint
+    \endgroup
+}
 %
+\def\sseq@class@main{
     \ifx\sseq@classinsert\empty
         % by default, just insert to the right of previous classes
         \edef\sseq@classinsert{\nodenum}
@@ -483,7 +534,6 @@
         \fi
     \fi
 %
-    \sseq@processlabels % This sets up the label nodes, now that we know the position of the class (I think that's what we needed?)
 %
     \sseq@xminmax{\xcoord}{\ycoord}%
     \sseq@yminmax{\xcoord}{\ycoord}%
@@ -500,14 +550,10 @@
         \sseq@obj@xdef{partcoord.(\partialcoord).tag.\sseq@class@tagprefix\sseq@class@tag}{\nodenum}%
     \fi
     \ifx\sseq@class@name\pgfutil@empty\else
-        \sseq@cleanup@obj{class.\classname.name}
-        \sseq@cleanup@obj{class.namedclass.\sseq@class@name}
-        \sseq@namehandler
-        \sseq@obj@xdef{class.\classname.name}{\sseq@class@name}
-        \sseq@obj@xdef{class.namedclass.\sseq@class@name}{\coordnopar}
-    \fi
-    \ifcsname sseq@class@showname\endcsname
-        \sseq@eval{\@nx\sseq@handleclassquotes{\sseq@obj{class.\classname.name}}{\sseq@class@showname}}
+        \sseq@cleanup@obj{\classname.name}
+        \sseq@cleanup@obj{class.namedclass.\detokenize\@xp{\sseq@class@name}}
+        \sseq@obj@xdef{\classname.name}{\sseq@class@name}
+        \sseq@obj@xdef{class.namedclass.\detokenize\@xp{\sseq@class@name}}{\coordnopar}
     \fi
     \sseq@pushstack@\coord
 %
@@ -530,6 +576,9 @@
     \ifx\sseq@classlabelnodes\pgfutil@empty\else
         \sseq@obj@xodef{\classname.labelnodes}{\sseq@classlabelnodes}%
     \fi
+    \ifcsname sseq@class@showname\endcsname
+        \sseq@obj@xodef{\classname.showname}{\sseq@class@showname}
+    \fi
     \ifsseq@needstikz
         \sseq@obj@xdef{\classname.needstikz}{\sseq@needstikztrue}%
     \fi
@@ -541,11 +590,36 @@
     \fi
 %
     \sseq@savedpaths@addclass{class.\coord}%
-    \sseq@breakpoint
-    \endgroup
 }
 \def\sseq@setoffset#1{\sseq@obj@gdef{\classname.offset}{\pgftransformshift{#1}}}
 
+\def\sseq@copy@nameprefix{}
+
+\def\sseq@class@copy#1#2{
+    \begingroup
+    \let\sseq@thename@saved\sseq@thename
+    \def\sseq@thename{#1}
+    \sseq@lettoobj\sseq@familylist{#2.familylist}
+    \sseq@lettoobj\sseq@savedoptioncode{#2.options}
+    \sseq@lettoobj\sseq@classnodetext{#2.nodetext}
+    \sseq@lettoobj\sseq@classnodetextoptions{#2.nodetext.options}
+    \sseq@lettoobj\sseq@classlabelnodes{#2.labelnodes}
+    \sseq@obj@ifdef{#2.showname}{\sseq@lettoobj\sseq@class@showname{#2.showname}}{}
+    \sseq@lettoobj\sseq@class@name{#2.name}
+    \edef\sseq@class@name{\unexpanded\@xp{\sseq@copy@nameprefix}\unexpanded\@xp{\sseq@class@name}}
+    \sseq@obj{#2.needstikz}
+    \sseq@lettoobj\sseq@tooltip{#2.tooltip}
+    \sseq@class@getparts#2.
+    \sseq@quieterror{class-tag-already-defined}
+    \edef\sseq@class@tag{copiedfrom\sseq@thisposnum}
+    \let\sseq@thename\sseq@thename@saved
+    \sseq@eval{\@nx\sseq@cparsecoord{\the\sseq@tempx,\the\sseq@tempy}}
+    \let\sseq@pushstack@\@gobble
+    \sseq@class@main
+    \endgroup
+}
+
+
 % This is for use with "insert" key. Add one to offset index of each class later than the one currently being inserted
 % Takes the partial coordinate "x,y" in #1, and the position that the new class is being inserted into in \sseq@classinsert.
 \def\sseq@class@adjustclasses#1{
@@ -643,14 +717,13 @@
         \sseq@obj@xdef{partcoord.(\partialcoord).tag.\sseq@class@tagprefix\sseq@class@tag}{\sseq@index}%
     \fi
     \ifx\sseq@class@name\pgfutil@empty\else
-        \sseq@obj@ifdef{class.\classname.name}{
-            \sseq@error@nn{classoptions-class-already-named}{\coord}{\sseq@obj{class.\classname.name}}%could be warning
+        \sseq@obj@ifdef{\classname.name}{
+            \sseq@error@nn{classoptions-class-already-named}{\coord}{\sseq@obj{\classname.name}}%could be warning
         }{}
-        \sseq@cleanup@obj{class.\classname.name}
-        \sseq@cleanup@obj{class.namedclass.\sseq@class@name}
-        \sseq@namehandler
-        \sseq@obj@xdef{class.\classname.name}{\sseq@class@name}
-        \sseq@obj@xdef{class.namedclass.\sseq@class@name}{\coordnopar}
+        \sseq@cleanup@obj{\classname.name}
+        \sseq@cleanup@obj{class.namedclass.\detokenize\@xp{\sseq@class@name}}
+        \sseq@obj@xdef{\classname.name}{\sseq@class@name}
+        \sseq@obj@xdef{class.namedclass.\detokenize\@xp{\sseq@class@name}}{\coordnopar}
     \fi
     \sseq@tempcount=\sseq@gen\relax
     \advance\sseq@tempcount\m@ne
@@ -679,6 +752,9 @@
             \sseq@cleanup@obj{\classname.labelnodes}
             \sseq@classoptions@obj@addto@withpagerange{\classname.labelnodes}{\sseq@classlabelnodes}
         \fi
+        \ifcsname sseq@class@showname\endcsname
+            \sseq@obj@xodef{\classname.showname}{\sseq@class@showname}
+        \fi
         \ifx\sseq@familylist\pgfutil@empty\else
             \sseq@cleanup@obj{\classname.familylist}
             \sseq@classoptions@obj@addto@withpagerange{\classname.familylist}{\sseq@familylist}
@@ -725,10 +801,38 @@
         \sseq@smuggle@macro\sseq@gen
     \egroup
 }
+
 \sseq@DeclareDocumentCommand\replaceclass{od()}{%
     \begingroup
     \sseq@loadinputline
     \sseq@xsetthiscall{\string\replaceclass\IfNoValueF{#1}{[\unexpanded{#1}]}\unexpanded{(#2)}}
+%
+    \IfNoValueTF{#2}{
+        \def\sseq@coord{\lastclass0}
+    }{
+        \def\sseq@coord{#2}
+    }
+    \sseq@parsecoord\coord{\sseq@coord}{coordinate passed to \string\replaceclass}%
+    \sseq@replaceclassmain{#1}
+}
+
+\sseq@DeclareDocumentCommand\replacesource{o}{
+    \begingroup
+    \sseq@loadinputline
+    \sseq@xsetthiscall{\string\replacesource\IfNoValueF{#1}{[\unexpanded{#1}]}}
+    \sseq@parsedcoord@restore{\coord}{lastsource}
+    \sseq@replaceclassmain{#1}
+}
+
+\sseq@DeclareDocumentCommand\replacetarget{o}{
+    \begingroup
+    \sseq@loadinputline
+    \sseq@xsetthiscall{\string\replacetarget\IfNoValueF{#1}{[\unexpanded{#1}]}}
+    \sseq@parsedcoord@restore{\coord}{lasttarget}
+    \sseq@replaceclassmain{#1}
+}
+
+\def\sseq@replaceclassmain#1{
     \sseq@options@firstpassmode
     \the\sseq@sseqstyle
     \the\sseq@classstyle
@@ -737,24 +841,23 @@
     \IfNoValueF{#1}{%
         \sseq@processoptions{class}{#1}% Outputs result into \sseq@savedoptioncode
     }%
-%
-    \IfNoValueTF{#2}{
-        \def\sseq@coord{\lastclass0}
-    }{
-        \def\sseq@coord{#2}
-    }
-    \sseq@parsecoord\coord{\sseq@coord}{\string\classoptions}%
     \sseq@processlabels
-%
     \sseq@obj@ifundef{class.\coord.num}{\sseq@error@x{replaceclass-no-class}{\coordname}\sseq@break}{}
     \sseq@ifdead\coord{}{\sseq@error@x{replaceclass-not-dead-yet}{\coordname}\sseq@break}
+%
+    \edef\oldclassname{class.\coord[\sseq@obj{class.\coord.num}]}
+    \sseq@cleanup@obj{class.\coord.num}
+    \sseq@obj@inc{class.\coord.num}
+    \edef\classname{class.\coord[\sseq@obj{class.\coord.num}]}
+%
     \ifsseq@keepchanges\else
-        \ifnum\the\numexpr\sseq@obj{class.\coord[\sseq@obj{class.\coord.num}].page}<\sseq@thepagecount\else
-            \edef\sseq@temp{\sseq@obj{class.\coord[\sseq@obj{class.\coord.num}].page}}
+        \ifnum\the\numexpr\sseq@obj{\oldclassname.page}<\sseq@thepagecount\else
+            \edef\sseq@temp{\sseq@obj{\oldclassname.page}}
             \sseq@error@xxx{replaceclass-no-effect-on-this-page}{\coord}{\sseq@temp}{\the\numexpr\sseq@temp+\@ne}% warning
             \sseq@breakfifi
         \fi
     \fi
+%
     \let\partialcoord\coord@partial
     \ifx\sseq@class@tag\pgfutil@empty\else
         \sseq@obj@ifdef{partcoord.(\partialcoord).tag.\sseq@class@tagprefix\sseq@class@tag}{%
@@ -763,18 +866,20 @@
         \sseq@cleanup@obj{partcoord.(\partialcoord).tag.\sseq@class@tagprefix\sseq@class@tag}%
         \sseq@obj@xdef{partcoord.(\partialcoord).tag.\sseq@class@tagprefix\sseq@class@tag}{\nodenum}%
     \fi
-    \ifx\sseq@class@name\pgfutil@empty\else
-        \sseq@cleanup@obj{class.\classname.name}
-        \sseq@cleanup@obj{class.namedclass.\sseq@class@name}
-        \sseq@namehandler
-        \sseq@obj@xdef{class.\classname.name}{\sseq@class@name}
-        \sseq@obj@xdef{class.namedclass.\sseq@class@name}{\coordnopar}
-    \fi
-    \ifcsname sseq@class@showname\endcsname
-        \sseq@eval{\@nx\sseq@handleclassquotes{\sseq@obj{class.\classname.name}}{\sseq@class@showname}}
+    \ifx\sseq@class@name\pgfutil@empty
+        \sseq@obj@ifdef{\oldclassname.name}{
+            \sseq@lettoobj\sseq@class@name{\oldclassname.name}
+            \sseq@cleanup@obj{\classname.name}
+            \sseq@cleanup@obj{class.namedclass.\detokenize\@xp{\sseq@class@name}}
+            \sseq@obj@xdef{\classname.name}{\sseq@class@name}
+            \sseq@obj@xdef{class.namedclass.\detokenize\@xp{\sseq@class@name}}{\coordnopar}
+        }{}
+    \else
+        \sseq@cleanup@obj{\classname.name}
+        \sseq@cleanup@obj{class.namedclass.\detokenize\@xp{\sseq@class@name}}
+        \sseq@obj@xdef{\classname.name}{\sseq@class@name}
+        \sseq@obj@xdef{class.namedclass.\detokenize\@xp{\sseq@class@name}}{\coordnopar}
     \fi
-    \sseq@cleanup@obj{class.\coord.num}
-    \sseq@obj@inc{class.\coord.num}
     \let\partialcoord\coord@partial
     \ifx\sseq@class@tag\pgfutil@empty\else
         \sseq@obj@ifdef{partialcoord.(\partialcoord).tag.\sseq@class@tagprefix\sseq@class@tag}{%
@@ -782,8 +887,10 @@
         }{}%
         \sseq@obj@xdef{partialcoord.(\partialcoord).tag.\sseq@class@tagprefix\sseq@class@tag}{\nodenum}%
     \fi
-    \edef\classname{class.\coord[\sseq@obj{class.\coord.num}]}
 %
+    \ifcsname sseq@class@showname\endcsname
+        \sseq@obj@xodef{\classname.showname}{\sseq@class@showname}
+    \fi
     \sseq@obj@xodef{\classname.familylist}{\sseq@familylist}
     \sseq@obj@xdef{\classname.page}{\sseq@infinity}
     \sseq@obj@xodef{\classname.options}{\sseq@savedoptioncode}
@@ -794,6 +901,9 @@
         \sseq@obj@xodef{\classname.nodetext.options}{\sseq@classnodetextoptions}
     \fi
     \sseq@obj@xodef{\classname.labelnodes}{\sseq@classlabelnodes}
+    \ifcsname sseq@class@showname\endcsname
+        \sseq@obj@xodef{\classname.showname}{\sseq@class@showname}
+    \fi
     \sseq@obj@gdef{\classname.dependencies}{}
     \ifsseq@needstikz
         \sseq@obj@xdef{\classname.needstikz}{\sseq@needstikztrue}
@@ -819,6 +929,7 @@
     \fi
     \egroup
 }
+
 % #1 -- class
 % #2 -- page
 % If there is a class #1 drawn on page #2, set \sseq@gen to be the generation of that class, otherwise set \sseq@gen to be -1.
@@ -856,6 +967,8 @@
 \sseq@DeclareDocumentCommandAs\sseq@kill@\kill {d()} {
     \sseq@xsetthiscall{\string\kill\unexpanded\@xp{\sseq@dpage}\IfNoValueF{#1}{(#1)}}%
     \sseq@parsecoord\coordinate{\IfNoValueTF{#1}{\lastclass}{#1}}{}%
+    \sseq@parsedcoord@save{lastsource}{\coordinate}
+    \sseq@parsedcoord@save{lasttarget}{\coordinate}
     \sseq@ifintexpr{\sseq@dpage}{%
         \sseq@tempcount=\numexpr\sseq@dpage\relax % this is a convenient way to get rid of spaces because #3 has to be a number
     }{%
@@ -934,6 +1047,8 @@
 \def\sseq@d@d#1#2{%%
     \sseq@d@setpageminrec{class.\source}{#2}{source}%  automatically handles \sseq@cleanup@obj
     \sseq@d@setpageminrec{class.\target}{#2}{target}
+    %%% This is the last point we might break, so now the differential is good.
+    %%% Note that we can break inside \sseq@d@setpageclass inside \sseq@d@setpageminrec
 %
     \ifsseq@drawdifferential % TODO: probably should get rid of invisible now that we have \kill...
         \sseq@obj@xodef{d.#2\source\target.familylist}{\sseq@familylist}
@@ -1017,7 +1132,7 @@
         \fi
     \fi
     \sseq@obj@xdef{\sseq@classgenname.page}{#2}
-    \sseq@obj@xdef{\sseq@classgenname.deathinfo}{#3 of differential \sseq@thiscall\space on page #2}
+    \sseq@obj@xdef{\sseq@classgenname.deathinfo}{#3 of differential \sseq@thiscall\ on page #2}
     \bgroup
     \def\foreach{\@nx\@nx\@nx\foreach}
     \protected\def\\{}
@@ -1033,7 +1148,7 @@
     \ifx\sseq@restofstacktrace\pgfutil@empty\else\sseq@tempiftrue\fi
     \sseq@obj@xdef{\sseq@classgenname.deathstacktrace}{%
         \ifsseq@tempif
-            \unexpanded{\\\\}Stack trace for differential \sseq@thiscall\ that killed #3:\unexpanded{\\}%
+            \unexpanded{\\\\}Stack trace for differential \@nx\unexpanded{\sseq@thiscall} that killed #3:\unexpanded{\\}%
             \ifx\sseq@temp\sseq@empty\else\unexpanded{\ \ \ }\@nx\sseq@stack@unexpanded{\unexpanded\@xp{\the\sseq@foreachcall}}\fi
             \unexpanded\@xp{\sseq@restofstacktrace}%
         \fi
@@ -1056,8 +1171,10 @@
 
 \def\sseq@d@setpagemin#1#2{
     \ifnum\sseq@obj{#1.page}>#2\relax
-        \sseq@cleanup@obj{#1.page}
-        \sseq@obj@xdef{#1.page}{#2}
+	\ifnum\sseq@obj{#1.pagemin}>#2\relax\else % prevent a d1 from getting rid of a structline that was supposed to start on page 5
+	        \sseq@cleanup@obj{#1.page}
+	        \sseq@obj@xdef{#1.page}{#2}
+	\fi
     \fi
 }
 \def\sseq@differential@draw@ifpage#1{
@@ -1262,6 +1379,27 @@
         \sseq@obj@xoaddto{\sseq@structlinename.familylist}{\sseq@familylist}
     \ifnum\sseq@tempcount<\sseq@genmax\repeat
 }
+
+\def\sseq@structline@copy#1#2{
+    \begingroup
+    \sseq@structline@copy@decomposename#2
+    \let\sseq@thename@saved\sseq@thename
+    \def\sseq@pagemin{0}
+    \sseq@parsecoord\source{\sourcename}{source of structure line}%
+    \sseq@parsecoord\target{\targetname}{target of structure line}
+    \def\sseq@thename{#1}
+    \sseq@lettoobj\sseq@familylist{#2.familylist}
+    \sseq@lettoobj\sseq@savedoptioncode{#2.options}
+    \let\sseq@thename\sseq@thename@saved
+    \sseq@structline@structline
+    \endgroup
+}
+
+\def\sseq@structline@copy@decomposename#1.(#2,#3,#4)(#5,#6,#7){
+    \def\sourcename{#2,#3,copiedfrom#4}
+    \def\targetname{#5,#6,copiedfrom#7}
+}
+
 \def\sseq@structline@getgen#1{
     \bgroup
         \sseq@tempcount=\sseq@obj{structline.\source\target.num}\relax
@@ -1366,7 +1504,7 @@
     \sseq@obj@xodef{\circleclassobjname.tikzprimoptions}{\sseq@keysfortikzprim}
     \sseq@obj@xdef{\circleclassobjname.fitnodes}{\@nx\tikz@lib@fit{(sseq{\coordanopar})(sseq{\coordbnopar})\sseq@fitalso}}
     %\edef\temp{\@nx\sseq@circleclass@draw{\coorda@internalname}{\coordb@internalname}{\unexpanded\@xp{\sseq@savedoptioncode}}}
-    \sseq@savedpaths@xadd{\@nx\sseq@circleclass@draw@ifpage{\circleclassobjname}{\coordanopar}{\coordbnopar}}
+    \sseq@savedpaths@xadd{\@nx\sseq@circleclass@object{\circleclassobjname}{\coordanopar}{\coordbnopar}}
     \sseq@obj@xdef{\circleclassobjname.page}{\sseq@pagemax}
     \sseq@obj@xdef{\circleclassobjname.pagemin}{\sseq@pagemin}
     \@ifundefined{sseq@fit@pagemax}{
@@ -1425,13 +1563,13 @@
     \the\sseq@scope@toks
     \sseq@options@normalmode
     \sseq@processoptions{class/label}{#2}%
-    \sseq@classlabeltextfn{#1}% labeltextfn is a private handler, classlabeltextfn is exposed via "class label handler"
+    \sseq@classlabel@handler{#1}% labeltextfn is a private handler for transformations, sseq@classlabel@handler is exposed via "class label handler"
     \ifsseq@classlabel
         \sseq@options@firstpassmode
         \the\sseq@outerclasslabelstyle
         \sseq@x@addto@macro\sseq@classlabelnodes{%
             \@nx\sseq@drawlabel{%
-                \sseq@maybemathswitch\unexpanded\@xp{\processedlabel}\sseq@maybemathswitch}%
+                \sseq@maybemathswitch\unexpanded\@xp{\result}\sseq@maybemathswitch}%
                 {% This is setup to prevent a bug where \classoptions and class label style don't work correctly together
                     \the\sseq@sseqstyle\@nx\the\sseq@sseqstyle@page
                     \the\sseq@labelstyle\@nx\the\sseq@labelstyle@page
@@ -1449,7 +1587,7 @@
         \the\sseq@innerclasslabelstyle
         \sseq@options@normalmode
         \sseq@protectedeval{\@nx\pgfqkeys{/sseqpages/class/label}{#2}}%
-        \sseq@protected@xdef\sseq@classnodetext{\sseq@maybemathswitch\processedlabel\sseq@maybemathswitch}%
+        \sseq@protected@xdef\sseq@classnodetext{\sseq@maybemathswitch\result\sseq@maybemathswitch}%
         \xdef\sseq@classnodetextoptions{%
             %\unexpanded{\def\pgfkeysdefaultpath{/sseqpages/class/node texts/}}%
             \sseq@thelabelstyle\sseq@theclasslabelstyle\sseq@theinnerclasslabelstyle
-- 
cgit v1.2.3

