On 12/15/2021 12:57 AM, Juri Linkov wrote: > I'm not sure if de-duplication is needed for other menus. Currently > de-duplication is used only to simplify creation of context menus. > But there is no indication that someone needed this for other menus. > Otherwise, they would report duplicate separators in other menus as a bug. Ok, we can worry about that another time. I've attached an updated patch that lets context-menu-functions add items to the beginning of the keymap as they currently do, while still removing consecutive separators correctly. Since this logic is a bit tricky, it could probably use an automated test or two, but before I write some, I wanted to check that the strategy I'm using seems reasonable. It's probably easiest to explain the logic by just pointing to the patch; I added several comments describing the behavior so that reviewers (and future readers) should be able to make sense of it.