Skip to main content
deleted 29 characters in body
Source Link
Kuba
  • 137.7k
  • 13
  • 289
  • 751

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[];
);
  1. First procedure removes all queued cells from the evaluation queue. And puts a selection after a current evaluating cell.

  2. Since no Token or Abort works, let's improvise to abort pending evaluation in current evaluation cell. Each line(not really a line) is a separate CompoundExpression which needs to be aborted separately so we can $Pre the Abort[] operation. But it would be nice to get rid of that later, that's where ScheduledTask comes in. 1 second is arbitrary but I think enough to abort everything and not to interrupt user actions in future.

enter image description here

Everything from main cell after Assert is aborted and the cell with 4 is skipped from evaluation even though it was selected too.

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[];
);
  1. First procedure removes all queued cells from the evaluation queue. And puts a selection after a current evaluating cell.

  2. Since no Token or Abort works, let's improvise to abort pending evaluation in current evaluation cell. Each line(not really a line) is a separate CompoundExpression which needs to be aborted separately so we can $Pre the Abort[] operation. But it would be nice to get rid of that later, that's where ScheduledTask comes in. 1 second is arbitrary but I think enough to abort everything and not to interrupt user actions in future.

enter image description here

Everything from main cell after Assert is aborted and the cell with 4 is skipped from evaluation even though it was selected too.

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[];
);
  1. First procedure removes all queued cells from the evaluation queue. And puts a selection after a current evaluating cell.

  2. Since no Token or Abort works, let's improvise to abort pending evaluation in current evaluation cell. Each line(not really a line) is a separate CompoundExpression which needs to be aborted separately so we can $Pre the Abort[] operation. But it would be nice to get rid of that later, that's where ScheduledTask comes in. 1 second is arbitrary but I think enough to abort everything and not to interrupt user actions in future.

enter image description here

Everything from main cell after Assert is aborted and the cell with 4 is skipped from evaluation even though it was selected too.

Source Link
Kuba
  • 137.7k
  • 13
  • 289
  • 751

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[];
);
  1. First procedure removes all queued cells from the evaluation queue. And puts a selection after a current evaluating cell.

  2. Since no Token or Abort works, let's improvise to abort pending evaluation in current evaluation cell. Each line(not really a line) is a separate CompoundExpression which needs to be aborted separately so we can $Pre the Abort[] operation. But it would be nice to get rid of that later, that's where ScheduledTask comes in. 1 second is arbitrary but I think enough to abort everything and not to interrupt user actions in future.

enter image description here

Everything from main cell after Assert is aborted and the cell with 4 is skipped from evaluation even though it was selected too.