I think this needs some sort of solution. If it’s not already on the roadmap I’ll try to implement it, but I’m looking for feedback first. I only want to spend time implementing if it’s probable that my changes will get merged into Atom. Thoughts, feedback?
Hopefully that will be accepted, then the next step will be defining ids for Atom’s existing menu items. And then a few changes in menu-helpers to make sure id and position attributes are merged into the template. And then I think you’ll be able to include position attributes for your menu items like this:
Making progress… https://github.com/atom/atom/issues/6270 is now incorporated into Atom Shell/Electron. Now to be able to use those optional menu position features the Atom menu templates need to include ids for each menu item. Any thoughts on what conventions I should use to generate these IDs?
That bring up a new questions: How unique and stable are command names? We could remove a lot of duplication by using “command” as a backup menu “id”. So for menu items whose command names are unique in the menu and expected to not change we wouldn’t need to define an id:
Oh that’s a good point! As far as I know, command names must be unique, so they already serve as an “id” of sorts. I think they’re mostly stable, but as long as we’re in pre-Atom 1.0 they could always change.
I think it would probably be helpful too to throw an error if a menu entry tries to refer to an id / command that doesn’t exist (rather than failing silently).
I wonder: If I have two different menu items that invoke the same command, then they always have the same behavior, right? If that’s true, then the only use case for id is that we want two different menu items that do the same thing.
Well, the other only use case is separators. Why does a separator need an id, though? Oh, right, it needs an id so that I can address it when I want to say I want to add a menu item after it. But it feels so wrong to provide an id to a separator!
How about allowing users to insert a menu item before or after an existing menu item? That should allow folks to insert menu items on the right side of the separator, without having to mention separators at all. It also allows folks to add a menu item to the beginning or the end of the menu, which would not be possible otherwise.