As Mark Wibrow wrote in a comment, \pgfextra, pic and graph don't all take the same approach to "path suspension". There are two approaches to path suspension: the one taken by \pgfextra, and the one taken by node. The other path components: edge, graph and pic are, in a way, treated by the TikZ "engine" like special kinds of nodes, and, in particular, their approach to "path suspension" is like the one taken by nodes.
The explanations below are very rough approximations to what is actually going on in the source code. The code snippets are for illustration purposes only; they are not copied verbatim from the source code, but are the result of extreme, almost grotesque, simplification of the actual implementation. Those who want to understand how TikZ is really implemented, should read the source code.
The \pgfextra approach
When \pgfextra{<body>} is "executed", the path parser yields control temporarily to the top-level TikZ picture parser. However, this happens without closing any existing TeX scope or starting any new one, and the engine's internal state remains unchanged, so all the internal data structures created so far along the path remain intact as control changes hands.
Once the top-level parser has finished processing <body>, control returns to the path parser, which picks up right after the \pgfextra{<body>} command. As before, this control switch does not involve the creation or destruction of TeX scopes, and does not affect the engine's state.
These explanations can be restated more formally as follows. Suppose the top-level TikZ picture parser is called \tikz@parser and takes one argument (\def\tikz@parser#1{...}), and that the TikZ path parser is called \path@parser. Then the execution of the path
\path <before> \pgfextra{<extra>} <after>;
proceeds as follows.
The path statement expands to
\path@parser <before> \pgfextra{<extra>} <after>;
The path parser scans the input consecutively, so the above line eventually reduces to
\path@parser \pgfextra{<extra>} <after>;
This expands to
\tikz@parser{<extra>} \path@parser <after>;
The node approach
A node is typeset into a TeX box that is saved to a TeX box register. A node can be saved to one of two boxes: the foreground box or the background box. All the nodes for which the option behind path was specified are appended to the background box, whereas the rest of the nodes are appended to the foreground box.
At the end of the path, the two boxes' contents, consisting of low-level typesetting directives (aka \specials), are written to the dvi file: first the background box, then the normal path, and finally the foreground box.
Paths are processed in textual order. Since nodes and normal path-construction operations can be textually intermixed, it is essential to take precautions that a node's path will not be treated as a natural continuation of the normal path. Therefore, when a node is first processed, a TeX scope is opened, a copy of the current path is saved to a local "private variable", and the current path is reset, i.e. set to the empty path. Similarly, the path options are saved and reset.
When the node has finished typesetting to the appropriate TeX box, the TeX scope is closed, and the saved path and options are restored.
To put it more formally, the execution of the path
\path <before> node <node specification> <after>;
proceeds as follows.
The path statement expands to
\path@parser <before> node <node specification> <after>;
The path parser scans the input consecutively, so the above line eventually reduces to
\path@parser node <node specification> <after>;
This expands to
\begin{pgfinterruptpath}%
\def\options{}%
\ifx<current node is `behind path`>%
\setbox\bg@box\hbox{\unbox\bg@box<typeset current node per specs>}%
\else%
\setbox\fg@box\hbox{\unbox\fg@box<typeset current node per specs>}%
\fi%
\end{pgfinterruptpath}%
\path@parser<after>;
Note that the pgfinterruptpath environment automatically surrounds its body with a \begingroup ... \endgroup pair.
\let\pgftemp\tokenlistand do stuff and then restore \pgftemp. There is no mystery. It's just not exposed to the user. – percusse Jul 31 '17 at 09:20\letoperation and instead of using\pgfusepathit stores it in a macro does whatever needs to be done and continues where it left off. – percusse Jul 31 '17 at 09:27\pgfinterruptpathin the manual – percusse Jul 31 '17 at 09:33<beginning of path><interruption><end of path>becomes<interruption><beginning of path><end of path>? – Evan Aad Jul 31 '17 at 09:46\draw[red] (0,0) -- (1,1) edge[blue, shorten <=1mm] (3,2) -- (2,1);. The smooth line join at the elbow only happens when it is a single path. I've shortened the edge path to make the line join visible. – percusse Jul 31 '17 at 09:53pgfinterruptpathenvironment, or by encapsulating the path built so far in a macro to be expanded after the interrupting part has been executed, the path would be drawn on top of whatever the interrupting part has drawn. However, in practice the path is drawn below the interrupting part. Take for instance the following graph defined in the middle of a path:\draw (-1,0) graph { O[red] } -- (1,0);– Evan Aad Aug 01 '17 at 07:19\pgftempis expanded, i.e. before the path is executed. I'm not bringing this up for the sake of correcting an error; my only concern is to understand what the manual means by 'path suspension', and for a while I thought I understood it, but now I'm back to square 1. – Evan Aad Aug 01 '17 at 08:30\pgfextra,picand\path graphtake different approaches to "path suspension" (which can be seen in the source code) so the use of this phrase in the manual should not be taken to imply the same underlying basic level operations are occurring, but merely a high level description of what is going on. – Mark Wibrow Aug 01 '17 at 10:45\path graph? – Evan Aad Aug 01 '17 at 11:17\pgfinterruptpath, 3. Do the graph, 4.\endpgfinterruptpath, 5. End the box which now contains the graph, 6. Carry on with the the path. When the path is "finished" (i.e., stroked, filled etc) the box is either inserted beforehand (so behind the path) or afterwards (so in front of the path). The relevant code is the macros\tikz@lib@graph@parser@and\tikz@lib@graphs@normal@mainintikzlibrarygraphs.code.texand\tikz@finishintikz.code.tex. The "box" is the\tikz@whichbox(actually it is a macro which refers to either\tikz@figboxor\tikz@figbox@bg)behind pathandin front of path. See17.2.1 Syntax of the Node Command(pp214-218 in the Manual for Version 3.0.1a) – Mark Wibrow Aug 01 '17 at 15:17pdftexrenders to PDF, so if this is how path suspension works in TikZ, it can't be mapped directly to driver operations. – Evan Aad Aug 01 '17 at 15:19\pgfextra's approach? – Evan Aad Aug 02 '17 at 10:01