9

In this question, answers were given that worked to add items to some menu commands, e.g., additional colors on the Format > Background Color menu, or Help menu items. I have code for such in an init.m:

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}];

AddMenuCommands["BackgroundDialog",{Delimiter,
Item["L&inen",Background->RGBColor[0.980,0.941,0.902]],
Item["A&liceBlue",Background->RGBColor[0.941,0.973,1.0]],
Delimiter,
Item["HelpBrowser Sand",Background->RGBColor[0.964706,0.929412,0.839216]],
Item["SlideShow Slate",Background->RGBColor[0.408011,0.440726,0.8]]
}];

The solution proposed there was to place that init.m into:

$UserBaseDirectory/Autoload/PacletManager/Configuration/FrontEnd/

However, this no longer seems to work with Mathematica 10.0.1. Yes, I did restart with a clean cache and clean preferences.

I note that in $UserBaseDirectory/Autoload/PacletManager/Configuration/FrontEnd/ there's already a file init_10.0.1.0. I even tried appending the code displayed above to that (and appending a semi-colon to the long SetOptions[$FrontEndSession... expression already in init_10.0.1.0, but still no change to the menus. Moreover, after I restart Mathematica, the added text has disappeared from init_10.0.1.0.

I'm using version-specific front end preferences, just as I had been doing with Mathematica versions 8 and 9.0.1, and, I think, version 10.0.0.

What am I doing wrong? How get this to work?

murray
  • 11,888
  • 2
  • 26
  • 50

2 Answers2

3

I have a partial answer to my question. In order to add menu items, e.g., to submenus of the Format menu for Mathematica version 10.0.1.

What to put in the init.m

FrontEndExecute[
AddMenuCommands["BackgroundDialog",
{Delimiter,
MenuItem["Linen",Background->RGBColor[0.980,0.941,0.902]],
MenuItem["AliceBlue",Background->RGBColor[0.941,0.973,1.0]],
MenuItem["MintCream",Background->RGBColor[0.961,1.0,0.980]],
MenuItem["LightYellow",Background->RGBColor[1.0,1.0,0.878]],
MenuItem["Smoke",Background->RGBColor[0.961,0.961,0.961]],
Item["MistyRose",Background->RGBColor[1.0,0.894,0.882]],
Delimiter,
MenuItem["HelpBrowser Straw",Background->RGBColor[0.960784,0.878431,0.666667]],
MenuItem["SlideShow Slate",Background->RGBColor[0.408011,0.440726,0.8]]}]];

FrontEndExecute[
AddMenuCommands["FontColorDialog", 
{Delimiter, 
Item["HelpBrowser Brick", FontColor -> RGBColor[0.592157, 0.313726, 0.313726]],
Item["Mocha", FontColor -> RGBColor[0.501961, 0.25098, 0]],
Item["Ocean", FontColor -> RGBColor[0, 0.25098, 0.501961]],
Item["Eggplant", FontColor -> RGBColor[0.25098, 0, 0.501961]]}]];

This works despite the information from Wolfram tech support that this can no longer be done!

Note that it does not work if the wrapping function FrontEndExecute is removed (although in previous Mathematica versions FrontEndExecute was not needed).

Where to put the init.m

That init.m will work if it's placed in $UserBaseDirectory/Autoload/FrontEnd.

However, it does not work if the same init.m is placed, instead, in $UserBaseDirectory/Autoload/PacletManager/Configuration/FrontEnd(which did work with previous Mathematica versions).

The remaining problem

What remains to be done is how to get the Help menu additions to work that were indicated in the original question.

A possible clue: in the system file MenuSetup.tr that, the Format and most other main menu items use the function Menu, but the item for the help menu uses instead the function HelpMenu.

murray
  • 11,888
  • 2
  • 26
  • 50
  • I tried this on my machine, but unsuccessfully. It is strange. Instead I succeeded to install it into $InstallationDirectory/SystemFiles/Autoload/PacletManager/Kernel. This is already the second case when on my machine I cannot work with the init.m file where other people seem to easily work with it, but secceed at the mentioned position. I have a question, however. In my case all the items are repeated twice in the Menu/Format/FontColor and Menu/Format/BackgroundColor. Do you know any reason? – Alexei Boulbitch Nov 25 '14 at 09:32
  • @Alexei Boulbitch: The only reason I can think of for having items appear twice is that you have, in fact, two init.m's being read. I recommend against putting any files of your own, or editing any, in the $InstallationDirectory tree, if for no other reason than that they'll disappear whenever you upgrade with a new Mathematica version. – murray Nov 25 '14 at 18:03
0

I never did what you are trying to do. However, I added an add-on to the init.m file in order to always load it up together with Mma. I used then the init.m file situated here: ~\Wolfram Research\Mathematica\10.0\SystemFiles\Autoload\PacletManager\Kernel. May be you could try this. Please let me know, if you succeed.

Alexei Boulbitch
  • 39,397
  • 2
  • 47
  • 96
  • @Alexi Boulbitch: Unfortunately, doing that does not allow the kernel to start at all for me. (I was surprised you gave directory starting at path ~\Wolfram Research\Mathematica\10.0\SystemFiles\, since my Mathematica.app is in \Applications. By any chance, did you mean to put the edited init.m in Library\Mathematica\SystemFiles\Autoload\PacletManager\Kernel?) – murray Nov 15 '14 at 21:59
  • @murray No, not into Library. The complete path on my machine looks as follows: D:\Program Files\Wolfram Research\Mathematica\10.0\SystemFiles\Autoload\PacletManager\Kernel\init.m. This is dictated by the fact that I installed Mma on the disk D. I did not use it, however, for the task you have in mind. My aim was to provide loading of one of the packages together with Mma, since I use this package on the everyday basis. It works for me. – Alexei Boulbitch Nov 17 '14 at 08:29
  • I'm using OS X, not Windows. If I correctly translate what you're saying, you put the edited init.m into $InstallationDirectory/SystemFiles/Autoload/PacletManager/Kernel. If I do that, Mathematica hangs as soon as the Welcome splash screen appears. – murray Nov 17 '14 at 15:47
  • @murray Yes, I checked $InstallationDirectoryand it, indeed, gives the directory I used. – Alexei Boulbitch Nov 18 '14 at 08:21
  • And editing the init.m so as add my AddMenuCommands there expressions (in separate initialization cells) locks up Mathematica. I need to force quit it, then remove the apparently offending code from /Applications/Mathematica.app/SystemFiles/Autoload/PacletManager/Kernel/init.m. – murray Nov 18 '14 at 18:18
  • Just to check, does the init.m file you're editing contain merely the following: Get["PacletManager\PacletManager`"] `? – murray Nov 18 '14 at 18:19
  • @murray Before I changed it, it contained only this: Get["PacletManagerPacletManager"] Now it also contains <<Presentations `in another cell. – Alexei Boulbitch Nov 19 '14 at 08:40
  • Right, as distributed, they init.m contains only Get["PacletManager\PacletManager/"]. I do note that loading an add-on such as Presentations would be a kernel activity, whereas adding items to the Mathematica system's menus would seem to be a front end operation. – murray Nov 19 '14 at 21:48
  • I just received an answer from Wolfram Support about the question: "[According to the front-end developers,] it appears that package and functionality has been removed from the program. It was never a support functionality so doubt it will reappear. Based on what I see in your examples it appears you would accomplish much of the same by adding a new environment to your style sheet that would include a toolbar with links and paste buttons." Alas! But not sure which package "that package" refers to. – murray Nov 20 '14 at 01:52
  • @murray Thank you for having informed me. – Alexei Boulbitch Nov 20 '14 at 09:19
  • More bad news: it seems that now editing MenuSetup.tr in $InstallationDirectory/SystemFiles/FrontEnd/TextResources/Macintoshno longer works to add menu items, either. (After restarting Mathematica 10.0.1 with a clean cache via Shift + Cmd.) – murray Nov 20 '14 at 22:14