From 5db380abad0482ae74aa71761f0da2b2351ce97a Mon Sep 17 00:00:00 2001 From: Jim Porter Date: Wed, 1 Dec 2021 21:55:31 -0800 Subject: [PATCH] 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). --- lisp/mouse.el | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lisp/mouse.el b/lisp/mouse.el index 3ab9fbcdfe2..ec43aecdd02 100644 --- a/lisp/mouse.el +++ b/lisp/mouse.el @@ -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))) -- 2.39.2