On 12/12/2021 2:12 PM, Jim Porter wrote: > It may be possible for context menu functions to be more careful about > the insertion of separators so that duplicates never crop up in the > first place. However, that would take a bit of experimentation, and I'm > not sure of all the pros and cons of a solution like that. Maybe Juri > has some thoughts on this though. Here's a *very* experimental patch that handles separators in a totally different way. Instead of removing duplicates, this *inserts* separators between different sections of the context menu. This works by giving menu items a `:section' property, and if that changes (and both the old and new section names are non-nil), the code inserts a separator between the two items. This patch only really works for elisp-mode using the default context menu functions, since I didn't want to spend too much time updating everything for a small experiment. It shouldn't be terribly hard to update all the other context menu functions if we decide to go with something like this though. This strategy seems less brittle from my experiments so far, since we no longer have to be so careful about getting the order of the keys exactly right in order to be able to detect the duplicated separators. It also makes it easier to insert duplicated separators if that's really what you want.