9
$\begingroup$

I want to add some items to the Mathematica 8.0.4 Help menu (under Mac OS X). In

 [$UserBaseDirectory]/Autoload/FrontEnd/init.m

I have the following cell:

  FrontEnd`AddMenuCommands["OpenHelpLink",{Delimiter,
  Item["Installed Add-Ons",FrontEndExecute[FrontEnd`FrontEndToken["OpenHelpLink",    
       {"guide/InstalledAddOns",Automatic}]]],
  Item["Standard Extra Packages",FrontEndExecute[FrontEnd`FrontEndToken["OpenHelpLink", 
        {"guide/StandardExtraPackages",Automatic}]]],
  Delimiter}]

but the items are not added to the Help menu when I start Mathematica.

Do I have the syntax wrong, or should this go in some other init.m?

$\endgroup$
7
  • $\begingroup$ Possible duplicate of mathematica.stackexchange.com/q/907/46? $\endgroup$
    – Heike
    Feb 10, 2012 at 20:05
  • $\begingroup$ so, does this work when you run it interactively? $\endgroup$
    – acl
    Feb 10, 2012 at 20:24
  • $\begingroup$ You are missing a closing ] in the code above. It works for me when put under $UserBaseDirectory/Autoload/PacletManager/Configuration/FrontEnd. It seem that the path you are using is not scanned for init.m files when MMa is starting up. $\endgroup$
    – Matariki
    Feb 10, 2012 at 20:29
  • $\begingroup$ Sorry about the missing terminal ] in the code; a copy-paste error. I fixed that. $\endgroup$
    – murray
    Feb 10, 2012 at 22:41
  • $\begingroup$ About@Matariki comment that the init.m can be placed in $UserBaseDirectory/Autoload/PacletManager/Configuration/FrontEnd: I'm using versioned preferences, and that directory already has an init_8.0.4.m with the following code: SetOptions[$FrontEndSession, PrivatePaths -> {"SystemResources" -> {ParentList}, "TextResources" -> {FrontEnd`FileName[{"/Applications/Math/Mathematica.app/\ AddOns/Applications/WolframAlphaClient/./FrontEnd", "TextResources"}, "PacletManager" -> True, "Prepend" -> True], ParentList}}] What to do? $\endgroup$
    – murray
    Feb 10, 2012 at 22:45

1 Answer 1

8
$\begingroup$

I can only speak for Windows but I would expect the solution should be similar for Mac.

I created a file $BaseDirectory\FrontEnd\init.m

In that file I added the following lines. Note they are slightly different than what you provide but should do what you want.

FrontEndExecute[AddMenuCommands["AboutBoxDialog",{Delimiter,
  Item["Installed Add Ons",FrontEndExecute[FrontEnd`FrontEndToken["OpenHelpLink",
    {"guide/InstalledAddOns",Automatic}]]],Item["Standard Extra Packages",
       FrontEndExecute[FrontEnd`FrontEndToken["OpenHelpLink",
          {"guide/StandardExtraPackages",Automatic}]]]}]]

I attempted to do this using $UserBaseDirectory\FrontEnd but Mathematica insists on wiping out any changes I make to the init.m file that already exists there.

EDIT:

Following the comment by @Matariki one can place the init.m file in $UserBaseDirectory\Autoload\PacletManager\Configuration\FrontEnd\ instead. I'm not sure which is preferable. The $BaseDirectory installation should add the customization for any user on the machine whereas the $UserBaseDirectory option will only work for the selected user.

Extension:

Also worth noting is that "AboutBoxDialog" is a front end token that can be found in MenuSetup.tr located in $InstallationDirectory/SystemFiles/FrontEnd/TextResources/.

These tokens, to my knowledge, are the only way to control the placement of new commands in menus. I could for example have added a background color to the Format>Background Colors menu by noting that "BackgroundDialog" is the token closest to the relevant menu in MenuSetup.tr. Adding the following code to the previously mentioned init.m will add a Linen color to the Background Colors sub-menu.

FrontEndExecute[ 
  AddMenuCommands["BackgroundDialog", {Delimiter, 
   Item["L&inen",Background->RGBColor[0.980,0.941,0.902]]}]];
$\endgroup$
1
  • $\begingroup$ Drat: I was hoping I could isolate any such change to $UserBaseDirectory and away from $BaseDirectory -- so that the change would definitely be preserved across upgrades or (in case needed) re-installation. I think the only difference between your version and mine is that I included Delimiter before and after the other items. My version of the init.m does work for Mac in $$BaseDirectory/FrontEnd/init.m. $\endgroup$
    – murray
    Feb 10, 2012 at 21:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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