From xemacs-m  Mon Apr 14 13:23:40 1997
Received: from jagor.srce.hr (jagor.srce.hr [161.53.2.130])
	by xemacs.org (8.8.5/8.8.5) with ESMTP id NAA16248
	for <xemacs-beta@xemacs.org>; Mon, 14 Apr 1997 13:23:38 -0500 (CDT)
Received: (from hniksic@localhost)
          by jagor.srce.hr (8.8.5/8.8.4)
	  id UAA12848; Mon, 14 Apr 1997 20:23:01 +0200 (MET DST)
Sender: hniksic@public.srce.hr
To: XEmacs Developers <xemacs-beta@xemacs.org>
Subject: easymenu.el made useful?
X-URL: ftp://gnjilux.cc.fer.hr/pub/unix/util/wget/
X-Attribution: Hrv
X-Face: &}4JQk=L;e.~x+|eo]#DGk@x3~ed!.~lZ}YQcYb7f[WL9L'Z*+OyA\nA
        EL1M(".[qvI#a2E6WYI5>>e7'@_)3Ol9p|Nn2wNa/;~06jL*B%tTcn/X
        vhAu7qeES0\|MF%$;sI#yn1+y"
From: Hrvoje Niksic <hniksic@srce.hr>
Date: 14 Apr 1997 20:23:00 +0200
Message-ID: <kigk9m5jwfv.fsf@jagor.srce.hr>
Lines: 65
X-Mailer: Gnus v5.4.42/XEmacs 19.15

I think I've fixed easymenu.el to behave similar to the one in GNU
Emacs (i.e. give proper submenus on button3, etc.).  The patch is for
stock 20.x (remove my previous patch, if you applied it).

Please try it out.  I think I begin to like easymenu-created menus
now!

--- easymenu.el.orig	Mon Apr 14 12:11:17 1997
+++ easymenu.el	Mon Apr 14 20:19:05 1997
@@ -160,7 +160,7 @@
 (fset 'easy-menu-change (symbol-function 'add-menu))
 
 ;; This variable hold the easy-menu mode menus of all major and
-;; minor modes currently in effect.
+;; minor modes currently in effect in the current buffer.
 (defvar easy-menu-all-popups nil)
 (make-variable-buffer-local 'easy-menu-all-popups)
 
@@ -168,11 +168,10 @@
   "Add MENU to the current menu bar."
   (if (featurep 'menubar)
       (progn
-	(if easy-menu-all-popups
-	    (setq easy-menu-all-popups (cons menu easy-menu-all-popups))
-	  (setq easy-menu-all-popups (list menu mode-popup-menu)))
-	(setq mode-popup-menu menu)
-  
+	(setq easy-menu-all-popups (cons menu easy-menu-all-popups))
+	(setq mode-popup-menu (cons (easy-menu-title)
+				    (reverse easy-menu-all-popups)))
+
 	(cond ((null current-menubar)
 	       ;; Don't add it to a non-existing menubar.
 	       nil)
@@ -192,10 +191,23 @@
   (if (featurep 'menubar)
       (progn
 	(setq easy-menu-all-popups (delq menu easy-menu-all-popups)
-	      mode-popup-menu (car easy-menu-all-popups))
+	      mode-popup-menu (cons (easy-menu-title)
+				    (reverse easy-menu-all-popups)))
 	(and current-menubar
 	     (assoc (car menu) current-menubar)
 	     (delete-menu-item (list (car 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
+;; capitalize it.
+;;
+;; If you can think of something smarter, feel free to replace it.
+;; Don't forget to mail the change to xemacs@xemacs.org where everyone
+;; can flame, er, praise your changes.
+(defun easy-menu-title ()
+  (capitalize (replace-in-string (replace-in-string
+				  (symbol-name major-mode) "-mode$" "")
+				 "-" " ")))
 
 (provide 'easymenu)
 

-- 
Hrvoje Niksic <hniksic@srce.hr> | Student at FER Zagreb, Croatia
--------------------------------+--------------------------------
You'll notice that perl is not itself written in Perl.
                                                 -- The Perl FAQ

