4
$\begingroup$

I placed the following code in a init.m notebook that executes upon Mathematica startup. This creates a shortcut menu command that allows me to insert a page break by pressing Control+p. You can see the shortcut in the insert menu dropdown.

FrontEndExecute[FrontEnd`AddMenuCommands["DuplicatePreviousOutput",{MenuItem["Page Break",FrontEnd`KernelExecute[NotebookWrite[InputNotebook[],Cell["", "PageBreak", PageBreakBelow -> True],After]],FrontEnd`MenuKey["p",FrontEnd`Modifiers->{"Control"}],System`MenuEvaluator->Automatic]}]];

Let's say I want to change the shortcut from Control+p to Control+l. If I run the init.m file again with the modified code while Mathematica is already running it keeps the old shortcut which I don't want. You can see both by clicking the insert drop down menu.

Is there a way to erase the first shortcut by executing the init.m file without rebooting Mathematica? That is is there a command I can put at the top the init.m file that will erase the previous version?

I want to reinitialize so that erases the previously executed shortcut and installs the new one without rebooting? Any help would be greatly appreciated.

$\endgroup$
2
$\begingroup$

Please try this from John Fultz via MathGroup Archive.

FrontEndExecute[FrontEnd`ResetMenusPacket[{Automatic}]]
$\endgroup$
  • 1
    $\begingroup$ Thank you. I placed your code in the init.m file at the top and tried executing without rebooting Mathematica. It did not erase the old command in the insert menu. I then tried executing the code in a regular notebook but had the same result. It doesn't seem to reset the commands i created using the AddMenuCommands functions. $\endgroup$ – Michael McCain Mar 11 '19 at 3:47
  • $\begingroup$ @MichaelMcCain That's unfortunate; I seem to remember this working in the past but I didn't test it at this time. I shall try later, but I am (still) using version 10.1. What version are you using? $\endgroup$ – Mr.Wizard Mar 11 '19 at 3:51
  • 1
    $\begingroup$ No problem. Yes, by the link you sent it did seem to work in earlier versions. I am running 11.3 on a mac running 10.14.3 $\endgroup$ – Michael McCain Mar 11 '19 at 3:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.