Ensure there are no duplicate separators when creating a context menu

Previously, if there were three or more consecutive menu separators,
not all of them would be removed.

* lisp/mouse.el (context-menu-map): Ensure no duplicate separators
(bug#52237).
This commit is contained in:
Jim Porter 2021-12-01 21:55:31 -08:00 committed by Lars Ingebrigtsen
parent d353c08d2b
commit 5db380abad

View file

@ -330,10 +330,10 @@ the function `context-menu-filter-function'."
;; Remove duplicate separators
(let ((l menu))
(while (consp l)
(when (and (equal (cdr-safe (car l)) menu-bar-separator)
(equal (cdr-safe (cadr l)) menu-bar-separator))
(setcdr l (cddr l)))
(setq l (cdr l))))
(if (and (equal (cdr-safe (car l)) menu-bar-separator)
(equal (cdr-safe (cadr l)) menu-bar-separator))
(setcdr l (cddr l))
(setq l (cdr l)))))
(when (functionp context-menu-filter-function)
(setq menu (funcall context-menu-filter-function menu click)))