That's hilarious but works :)
On[Assert]
$AssertFunction := (
(*1*)
SelectionMove[EvaluationNotebook[], All, Notebook, AutoScroll -> False];
FrontEndExecute @ FrontEndToken @ "RemoveFromEvaluationQueue";
SelectionMove[EvaluationCell[], After, Cell, AutoScroll -> False];
(*2*)
RunScheduledTask[$Pre =., {1}];
$Pre = Abort[] &; Abort[];
);
First procedure removes all queued cells from the evaluation queue. And puts a selection after a current evaluating cell.
Since no
Token
orAbort
works, let's improvise to abort pending evaluation in current evaluation cell. Each line(not really a line) is a separateCompoundExpression
which needs to be aborted separately so we can$Pre
theAbort[]
operation. But it would be nice to get rid of that later, that's whereScheduledTask
comes in. 1 second is arbitrary but I think enough to abort everything and not to interrupt user actions in future.
Everything from main cell after Assert
is aborted and the cell with 4
is skipped from evaluation even though it was selected too.