When developing packages I need to Get
my packages repeatedly, and it will be convenient to set a shortcut to reload the packages.
Suppose the structure of the notebook is like:
First cell
PacletDataRebuild[]
Get["Notation`"]
MemoryInUse[]
Lots of cells in several pages
Print/@Range@20
The cell I'm working with
foo[1]
Other cells
foo1[1]
What I want
I want to evaluate the first cell using a shortcut, without changing the current selection of the notebook. Is there convenient way to achieve this?
What I tried
I tried two methods by modifying KeyEventTranslations.tr
but failed
Method 1
Item[KeyEvent["t", Modifiers -> {Command}],
FrontEndExecute[
FrontEnd`SelectionMove[EvaluationNotebook[],Before,Notebook]
];
FrontEndExecute[
FrontEnd`SelectionMove[EvaluationNotebook[],Next,Cell]
];
FrontEndExecute[
FrontEnd`SelectionEvaluate[EvaluationNotebook[]]
]
]
Firstly these codes just don't work, and secondly they change the position of current selection.
Method 2
Item[KeyEvent["t", Modifiers -> {Command}],
KernelExecute[
Get["Notation`"]
]
]
I found the undocumented function KernelExecute
in other questions, but don't know how to use it.
code
as the default input cell style, and thecode
cells are initialization cells. $\endgroup$