Aidan,
This is the patch you had proposed. Please look this over.
Everyone - please review. It looks good to me, and based on that (and
Uwe's prior feedback) I will commit today in order to get some testing
in before I release 21.4.19, now pushed back to next weekend - the
weekend of 2006-01-14.
Regards,
Vin
21.4 source patch:
Diff command: cvs -q diff -u
Files affected: lisp/easymenu.el
Index: lisp/ChangeLog
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/lisp/ChangeLog,v
retrieving revision 1.266.2.90
diff -a -u -u -r1.266.2.90 ChangeLog
--- lisp/ChangeLog 2006/01/07 13:22:41 1.266.2.90
+++ lisp/ChangeLog 2006/01/07 13:25:32
@@ -1,3 +1,16 @@
+2006-01-03 Aidan Kehoe <kehoea(a)parhasard.net>
+
+ * easymenu.el: Update copyright.
+ * easymenu.el (easy-menu-all-popups):
+ Add a docstring.
+ * easymenu.el (easy-menu-add):
+ Document a bug, rework the function to preserve any existing
+ non-default mode-popup-menu instead of overwriting it, and not to
+ bother normalising the menu title (nothing else does).
+ * easymenu.el (easy-menu-remove):
+ Restore the default mode-popup-menu instead of leaving an empty
+ one when we remove the last easy-menu popup.
+
2006-01-06 Adrian Aichner <adrian(a)xemacs.org>
* package-get.el (package-get-download-sites): Add
pt.xemacs.org,
Index: lisp/easymenu.el
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/lisp/easymenu.el,v
retrieving revision 1.5.2.1
diff -a -u -u -r1.5.2.1 easymenu.el
--- lisp/easymenu.el 2005/11/28 02:10:08 1.5.2.1
+++ lisp/easymenu.el 2006/01/07 13:25:32
@@ -1,6 +1,6 @@
;;; easymenu.el - Easy menu support for Emacs 19 and XEmacs.
-;; Copyright (C) 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
+;; Copyright (C) 1992, 1993, 1994, 1995, 2005 Free Software Foundation, Inc.
;; Author: Per Abrahamsen <abraham(a)dina.kvl.dk>
;; Maintainer: XEmacs Development Team
@@ -159,32 +159,52 @@
,doc
(interactive "@e")
(run-hooks 'activate-menubar-hook)
- (setq zmacs-region-stays 't)
+ (setq zmacs-region-stays t)
(popup-menu ,symbol)))))
(defun easy-menu-change (&rest args)
(when (featurep 'menubar)
(apply 'add-menu args)))
-;; This variable hold the easy-menu mode menus of all major and
-;; minor modes currently in effect in the current buffer.
-(defvar easy-menu-all-popups nil)
+(defvar easy-menu-all-popups nil
+ "Don't use this.
+This variable holds the menus of all major and minor modes in effect in the
+current buffer. ")
(make-variable-buffer-local 'easy-menu-all-popups)
(defun easy-menu-add (menu &optional map)
"Add MENU to the current menu bar."
+ ;; If you uncomment the following, do an xemacs -vanilla, type M-x
+ ;; folding-mode RET, you'll see that this code, which theoretically has
+ ;; *scratch* as its buffer context, can't see *scratch*'s value for
+ ;; mode-popup-menu--the default overrides it.
+ ;;
+ ;; This is not specific to *scratch*--try it on ~/.xemacs/init.el--but it
+ ;; does appear to be specific to the first time mode-popup-menu is
+ ;; accessed as a buffer-local variable in non-interactive code (that is,
+ ;; M-: mode-popup-menu RET gives the correct value).
+ ;;
+ ;; My fixing this right now isn't going to happen. Aidan Kehoe, 2006-01-03
+; (message (concat "inside easy-menu-add, menu is %s, "
+; "mode-popup-menu is %s, current buffer is %s, "
+; "default-value mode-popup-menu is %s, "
+; "easy-menu-all-popups is %s")
+; menu mode-popup-menu (current-buffer)
+; (default-value 'mode-popup-menu) easy-menu-all-popups)
(when (featurep 'menubar)
- (unless (member menu easy-menu-all-popups)
- (push menu easy-menu-all-popups))
- (setq mode-popup-menu (if (> (length easy-menu-all-popups) 1)
- (cons (easy-menu-title)
- (reverse easy-menu-all-popups))
- (let ((same-as-menu
- (car easy-menu-all-popups)))
- (cons (normalize-menu-item-name
- (car same-as-menu))
- (cdr same-as-menu)))))
-
+ ;; Save the existing mode-popup-menu, if it's been changed.
+ (when (and (zerop (length easy-menu-all-popups))
+ (not (equal (default-value 'mode-popup-menu) mode-popup-menu)))
+ (push mode-popup-menu easy-menu-all-popups))
+ ;; Add the menu to our list of all the popups for the buffer.
+ (pushnew menu easy-menu-all-popups :test 'equal)
+ ;; If there are multiple popup menus available, make the popup menu
+ ;; normally shown with button-3 a menu of them. If there is just one,
+ ;; make that button show it, and no super-menu.
+ (setq mode-popup-menu (if (= 1 (length easy-menu-all-popups))
+ (car easy-menu-all-popups)
+ (cons (easy-menu-title)
+ (reverse easy-menu-all-popups))))
(cond ((null current-menubar)
;; Don't add it to a non-existing menubar.
nil)
@@ -202,16 +222,20 @@
(defun easy-menu-remove (menu)
"Remove MENU from the current menu bar."
(when (featurep 'menubar)
- (setq easy-menu-all-popups (delq menu easy-menu-all-popups)
- mode-popup-menu (if (> (length easy-menu-all-popups) 1)
- (cons (easy-menu-title)
- (reverse easy-menu-all-popups))
- (let ((same-as-menu
- (car easy-menu-all-popups)))
- (cons (normalize-menu-item-name
- (car same-as-menu))
- (cdr same-as-menu)))))
-
+ (setq
+ ;; Remove this menu from the list of popups we know about.
+ easy-menu-all-popups (delq menu easy-menu-all-popups)
+ ;; If there are multiple popup menus available, make the popup menu
+ ;; normally shown with button-3 a menu of them. If there is just one,
+ ;; make that button show it, and no super-menu.
+ mode-popup-menu (if (= 1 (length easy-menu-all-popups))
+ (car easy-menu-all-popups)
+ (cons (easy-menu-title)
+ (reverse easy-menu-all-popups))))
+ ;; If we've just set mode-popup-menu to an empty menu, change that menu
+ ;; to its default value (without intervention from easy-menu).
+ (if (zerop (length easy-menu-all-popups))
+ (setq mode-popup-menu (default-value 'mode-popup-menu)))
(and current-menubar
(assoc (car menu) current-menubar)
(delete-menu-item (list (car menu))))))
@@ -260,9 +284,6 @@
(when (featurep 'menubar)
(delete-menu-item (append path (list name))
(easy-menu-normalize menu))))
-
-
-
;; Think up a good title for the menu. Take the major-mode of the
;; buffer, strip the -mode part, convert hyphens to spaces, and