From d886825394855f7dc66d5f89889a36491b039249 Mon Sep 17 00:00:00 2001 From: "Richard M. Stallman" Date: Tue, 28 Apr 1998 20:03:07 +0000 Subject: [PATCH] (easy-menu-define-key): Fixed bug with BEFORE argument. Now it works also if you repeat an identical call to easy-menu-define-key. --- lisp/emacs-lisp/easymenu.el | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/lisp/emacs-lisp/easymenu.el b/lisp/emacs-lisp/easymenu.el index ee666aa6b42..8a5043998db 100644 --- a/lisp/emacs-lisp/easymenu.el +++ b/lisp/emacs-lisp/easymenu.el @@ -274,7 +274,7 @@ shadow\\(Double\\)?Etched\\(In\\|Out\\)\\(Dash\\)?\\)\\)$" ;; put binding before BEFORE in MENU, otherwise if binding is already ;; present in MENU, just change it, otherwise put it last in MENU. (let ((inserted (null item)) ; Fake already inserted. - done) + tail done) (while (not done) (cond ((or (setq done (or (null (cdr menu)) (keymapp (cdr menu)))) @@ -286,20 +286,20 @@ shadow\\(Double\\)?Etched\\(In\\|Out\\)\\(Dash\\)?\\)\\)$" (unless inserted ; Don't insert more than once. (setcdr menu (cons (cons key item) (cdr menu))) (setq inserted t) - (setq menu (cdr menu)))) + (setq menu (cdr menu))) + (setq menu (cdr menu))) ((and key (equal (car-safe (cadr menu)) key)) - (if (and (or inserted ; Already inserted or - before) ; wanted elsewhere and - (or (not (setq done ; not the last in this keymap. - (or (null (cddr menu)) - (keymapp (cddr menu))))) - inserted)) - ;; The contorted logic above, guarantees `done' has been computed. + (if (or inserted ; Already inserted or + (and before ; wanted elsewhere and + (setq tail (cddr menu)) ; not last item and not + (not (keymapp tail)) + (not (equal (car-safe (car tail)) before)))) ; in position (setcdr menu (cddr menu)) ; Remove item. (setcdr (cadr menu) item) ; Change item. - (setq inserted t)))) - (setq menu (cdr menu))))) - + (setq inserted t) + (setq menu (cdr menu)))) + (t (setq menu (cdr menu))))))) + (defun easy-menu-always-true (x) ;; Return true if X never evaluates to nil. (if (consp x) (and (eq (car x) 'quote) (cadr x)) -- 2.39.2