MenuEvaluator->Automatic
uses the default kernel to evaluate the expression in the menu. MenuEvaluator->None
is the default, which means that the front end "evaluates" the expression (which generally means the expression is composed only of FE tokens and packets). One could also use MenuEvaluator->"kernelname"
to point to an explicit kernel.
For doing the kind of menu editing you wish to do, you have to rewrite the menus wholesale. You can begin by reading the menu from the layout, tweaking it how you want, and then sending it to the FE in ResetMenusPacket
. Here's an example:
Begin["System`"];
menu = Get[
FileNameJoin[{$InstallationDirectory, "SystemFiles", "FrontEnd",
"TextResources", "Windows", "MenuSetup.tr"}]];
End[];
menu = menu /. {MenuItem["Plain &Text", ___] ->
MenuItem["Plain &Text", FrontEnd`CopySpecial["PlainText"]],
MenuItem["&LaTeX", ___] ->
MenuItem["&LaTeX",
KernelExecute[ToExpression["FrontEnd`CopyAsTeX[]"]],
MenuKey["C", Modifiers -> {"Control", "Shift"}],
MenuEvaluator -> Automatic]};
FrontEndExecute[FrontEnd`ResetMenusPacket[menu]]
Some notes about this code:
- A number of symbols in the menu expression aren't in the
System`
context, but need to be for this to work. That's the reason for the Begin
/End
calls.
- To make this code work on Linux, replace
"Windows"
with "X"
- To make this code work on Mac, replace
"Windows"
with "Macintosh"
, "Control"
with "Command"
, and remove the ampersands.
- This code only work on v7 and later (when
MenuItem
was introduced)
Finally, and this is really important, you need to be playing with this stuff in a fresh session of Mathematica, and frequently either saving your work or copying to the clipboard. If you make any mistakes, you can lose all of your menus, including the ability to evaluate, save, or copy. You might be able to recover by using the contextual menu, but probably safer to just quit and restart.
Assuming you haven't really hosed your menus, you can reset to the default by evaluating:
FrontEndExecute[FrontEnd`ResetMenusPacket[{Automatic}]]
Another option is to simply make your own MenuSetup.tr
which is in $UserBaseDirectory
or $BaseDirectory
, in the same location it is now in $InstallationDirectory
. But I don't generally advise this because, if you do, all copies of Mathematica will find it, including past and future versions, which could cause you hopeless confusion.