SHARE
TWEET

Untitled

a guest Jun 17th, 2019 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. With[
  2.   { nb := EvaluationNotebook[]
  3.   , c := EvaluationCell[]
  4.   }
  5. , With[
  6.     { cv := CurrentValue[nb, {"TaggingRules", "LastCursorPosition"}]
  7.     , pos := FrontEndExecute@FrontEnd`UndocumentedGetSelectionPacket[nb]
  8.     }
  9.   , With[
  10.       { savePosition := (
  11.           cv = If[MemberQ[pos, "CharacterRange" -> _], Last["CharacterRange" /. pos], False]
  12.         )
  13.       }
  14.     , SetOptions[nb
  15.       , CellEventActions :> {
  16.           {"MenuCommand", "HandleShiftReturn"} :> savePosition
  17.         , {"MenuCommand", "EvaluateCells"} :> savePosition
  18.         , PassEventsDown -> True
  19.         }
  20.       , CellEpilog :>  If[
  21.           IntegerQ[cv]
  22.         , SelectionMove[c, Before, CellContents]
  23.         ; SelectionMove[nb, Next, Character, cv]
  24.         ; cv = False
  25.         ]
  26.       ]
  27.     ]
  28.   ]
  29. ]
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top