Skip to main content
deleted 12 characters in body
Source Link
Chris Degnen
  • 31.4k
  • 2
  • 57
  • 112

This will assign a 'Save and Run` function to control-shift F:

FrontEndExecute[FrontEnd`AddMenuCommands["Save", {Delimiter, MenuItem["Save and Run &Demo"&Run", FrontEnd`KernelExecute[NotebookSave[SelectedNotebook[]]; Get[StringJoin[ StringDrop[NotebookFileName[SelectedNotebook[]], -3], ".m"]]], MenuKey["F", Modifiers -> {"Control", "Shift"}],  System`MenuEvaluator -> Automatic]}]] 

To test, include the following as an initialisation cell in the working notebook (with auto-create package):

test := Print["Change this text, then execute Save and Run and run test"] 

By using AddMenuCommands the menu addition only appears when the procedure is run, so doesn't affect the standard setup. It only needs to be run once, and the menu addition disappears upon restart. The 'Save and Run' command is placed under Save on the File menu.

This will assign a 'Save and Run` function to control-shift F:

FrontEndExecute[FrontEnd`AddMenuCommands["Save", {Delimiter, MenuItem["Save and Run &Demo", FrontEnd`KernelExecute[NotebookSave[SelectedNotebook[]]; Get[StringJoin[ StringDrop[NotebookFileName[SelectedNotebook[]], -3], ".m"]]], MenuKey["F", Modifiers -> {"Control", "Shift"}],  System`MenuEvaluator -> Automatic]}]] 

To test, include the following as an initialisation cell in the working notebook (with auto-create package):

test := Print["Change this text, then execute Save and Run and run test"] 

By using AddMenuCommands the menu addition only appears when the procedure is run, so doesn't affect the standard setup. It only needs to be run once, and the menu addition disappears upon restart. The 'Save and Run' command is placed under Save on the File menu.

This will assign a 'Save and Run` function to control-shift F:

FrontEndExecute[FrontEnd`AddMenuCommands["Save", {MenuItem["Save and &Run", FrontEnd`KernelExecute[NotebookSave[SelectedNotebook[]]; Get[StringJoin[ StringDrop[NotebookFileName[SelectedNotebook[]], -3], ".m"]]], MenuKey["F", Modifiers -> {"Control", "Shift"}], System`MenuEvaluator -> Automatic]}]] 

To test, include the following as an initialisation cell in the working notebook (with auto-create package):

test := Print["Change this text, then execute Save and Run and run test"] 

By using AddMenuCommands the menu addition only appears when the procedure is run, so doesn't affect the standard setup. It only needs to be run once, and the menu addition disappears upon restart. The 'Save and Run' command is placed under Save on the File menu.

added 180 characters in body
Source Link
Chris Degnen
  • 31.4k
  • 2
  • 57
  • 112

This will assign a 'Save and Run` function to control-shift F:

FrontEndExecute[FrontEnd`AddMenuCommands["DuplicatePreviousOutput"FrontEndExecute[FrontEnd`AddMenuCommands["Save", {Delimiter, MenuItem["Save and Run &Demo", FrontEnd`KernelExecute[NotebookSave[SelectedNotebook[]]; Get[StringJoin[ StringDrop[NotebookFileName[SelectedNotebook[]], -3], ".m"]]], MenuKey["F", Modifiers -> {"Control", "Shift"}], System`MenuEvaluator -> Automatic]}]] 

To test, include the following as an initialisation cell in the working notebook (with auto-create package):

test := Print["Change this text, then execute Save and Run and run test"] 

By using AddMenuCommands itthe menu addition only appears when the additionprocedure is run, so doesn't affect the standard setup.

Currently it placed It only needs to be run once, and the menu command on the Insert menuaddition disappears upon restart. I'll see if I can find the right front end token to put it The 'Save and Run' command is placed under Save on the File menu.

This will assign a 'Save and Run` function to control-shift F:

FrontEndExecute[FrontEnd`AddMenuCommands["DuplicatePreviousOutput", {Delimiter, MenuItem["Save and Run &Demo", FrontEnd`KernelExecute[NotebookSave[SelectedNotebook[]]; Get[StringJoin[ StringDrop[NotebookFileName[SelectedNotebook[]], -3], ".m"]]], MenuKey["F", Modifiers -> {"Control", "Shift"}], System`MenuEvaluator -> Automatic]}]] 

By using AddMenuCommands it only appears when the addition is run, so doesn't affect the standard setup.

Currently it placed the menu command on the Insert menu. I'll see if I can find the right front end token to put it on the File menu.

This will assign a 'Save and Run` function to control-shift F:

FrontEndExecute[FrontEnd`AddMenuCommands["Save", {Delimiter, MenuItem["Save and Run &Demo", FrontEnd`KernelExecute[NotebookSave[SelectedNotebook[]]; Get[StringJoin[ StringDrop[NotebookFileName[SelectedNotebook[]], -3], ".m"]]], MenuKey["F", Modifiers -> {"Control", "Shift"}], System`MenuEvaluator -> Automatic]}]] 

To test, include the following as an initialisation cell in the working notebook (with auto-create package):

test := Print["Change this text, then execute Save and Run and run test"] 

By using AddMenuCommands the menu addition only appears when the procedure is run, so doesn't affect the standard setup. It only needs to be run once, and the menu addition disappears upon restart. The 'Save and Run' command is placed under Save on the File menu.

Source Link
Chris Degnen
  • 31.4k
  • 2
  • 57
  • 112

This will assign a 'Save and Run` function to control-shift F:

FrontEndExecute[FrontEnd`AddMenuCommands["DuplicatePreviousOutput", {Delimiter, MenuItem["Save and Run &Demo", FrontEnd`KernelExecute[NotebookSave[SelectedNotebook[]]; Get[StringJoin[ StringDrop[NotebookFileName[SelectedNotebook[]], -3], ".m"]]], MenuKey["F", Modifiers -> {"Control", "Shift"}], System`MenuEvaluator -> Automatic]}]] 

By using AddMenuCommands it only appears when the addition is run, so doesn't affect the standard setup.

Currently it placed the menu command on the Insert menu. I'll see if I can find the right front end token to put it on the File menu.