Subject: [PATCH] Make XEmacs compat aliases easy-menu-{add,remove} obsolete

From: Stefan Kangas <[email-masked]>
Date: Wed, 18 Nov 2020 16:40:27 -0800

Severity: wishlist

The `easy-menu-remove' and `easy-menu-add' are XEmacs compatibility
aliases.  I think they do not make sense these days, and it is better
for code that wants to use them to wrap the call in something like
`(when (featurep 'xemacs) ...)'.

The attached patch makes them obsolete and fixes all callers.  It takes
care to not remove XEmacs compatibility from any modules where it was
not already removed, so I hope this will be uncontroversial.
From a79ebd5c0aa86b9c8adc011310b7eb666e19e700 Mon Sep 17 00:00:00 2001
From: Stefan Kangas <[email-masked]>
Date: Wed, 18 Nov 2020 23:15:21 +0100
Subject: [PATCH] Make XEmacs compat aliases easy-menu-{add,remove} obsolete

* lisp/emacs-lisp/easymenu.el (easy-menu-remove, easy-menu-add):
Make XEmacs compat aliases obsolete.
* lisp/allout.el (allout-setup-menubar):
* lisp/cus-edit.el (Custom-mode):
* lisp/gnus/gnus-art.el (gnus-article-edit-mode):
* lisp/gnus/message.el (message-mode):
* lisp/net/sieve.el (sieve-manage-mode):
* lisp/org/org-agenda.el (org-agenda-mode):
* lisp/org/org-table.el (org-table-edit-formulas, orgtbl-mode):
* lisp/org/org.el:
* lisp/progmodes/cperl-mode.el (cperl-mode):
* lisp/progmodes/hideshow.el (hs-minor-mode):
* lisp/progmodes/idlw-help.el (idlwave-help-mode):
* lisp/progmodes/idlw-shell.el (idlwave-shell-mode):
* lisp/progmodes/idlwave.el (idlwave-mode):
* lisp/progmodes/meta-mode.el (meta-common-mode):
* lisp/progmodes/octave.el (octave-mode):
* lisp/progmodes/prolog.el (prolog-menu):
* lisp/progmodes/tcl.el (tcl-mode):
* lisp/speedbar.el (speedbar-reconfigure-keymaps):
* lisp/term.el (term-mode, term-char-mode, term-process-pager):
* lisp/textmodes/dns-mode.el (dns-mode):
* lisp/wid-browse.el (widget-browse-mode): Don't call above
obsolete aliases.
* lisp/cedet/semantic/grammar.el (semantic-grammar-setup-menu-xemacs):
* lisp/mh-e/mh-folder.el (mh-folder-mode):
* lisp/mh-e/mh-identity.el (mh-identity-add-menu):
* lisp/mh-e/mh-letter.el (mh-letter-mode):
* lisp/mh-e/mh-search.el (mh-search-mode):
* lisp/mh-e/mh-show.el (mh-show-mode):
* lisp/obsolete/otodo-mode.el (todo-mode):
* lisp/progmodes/antlr-mode.el (antlr-mode):
* lisp/progmodes/cc-mode.el (c-mode, c++-mode, objc-mode)
(java-mode, idl-mode, pike-mode):
* lisp/progmodes/sql.el (sql-mode, sql-interactive-mode):
* lisp/progmodes/vhdl-mode.el (vhdl-update-mode-menu)
(vhdl-add-source-files-menu, vhdl-mode):
* lisp/textmodes/reftex-index.el (reftex-index-mode)
(reftex-index-phrases-mode):
* lisp/textmodes/reftex-toc.el (reftex-toc-mode):
* lisp/textmodes/reftex.el (reftex-mode): Only call above obsolete
aliases in XEmacs.

* lisp/progmodes/prolog.el (prolog-inferior-menu):
* lisp/erc/erc-menu.el (erc-menu-add, erc-menu-remove): Don't call
above obsolete aliases.  Make obsolete.
* lisp/erc/erc-menu.el (menu, erc-menu-add, erc-menu-remove):
* lisp/progmodes/prolog.el (prolog-inferior-mode): Adjust callers.
* lisp/speedbar.el (speedbar-previous-menu): Make obsolete.
---
 lisp/allout.el                 |  3 +--
 lisp/cedet/semantic/grammar.el |  3 ++-
 lisp/cus-edit.el               |  1 -
 lisp/emacs-lisp/easymenu.el    |  7 ++-----
 lisp/erc/erc-menu.el           | 15 ++++++---------
 lisp/gnus/gnus-art.el          |  1 -
 lisp/gnus/message.el           |  2 --
 lisp/mh-e/mh-folder.el         |  7 ++++---
 lisp/mh-e/mh-identity.el       |  2 +-
 lisp/mh-e/mh-letter.el         |  2 +-
 lisp/mh-e/mh-search.el         |  2 +-
 lisp/mh-e/mh-show.el           |  7 ++++---
 lisp/net/sieve.el              |  3 +--
 lisp/obsolete/otodo-mode.el    |  3 ++-
 lisp/org/org-agenda.el         |  1 -
 lisp/org/org-table.el          |  5 +----
 lisp/org/org.el                |  1 -
 lisp/progmodes/antlr-mode.el   |  3 ++-
 lisp/progmodes/cc-mode.el      | 18 ++++++++++++------
 lisp/progmodes/cperl-mode.el   |  2 --
 lisp/progmodes/hideshow.el     |  1 -
 lisp/progmodes/idlw-help.el    |  1 -
 lisp/progmodes/idlw-shell.el   |  7 +------
 lisp/progmodes/idlwave.el      |  4 ----
 lisp/progmodes/meta-mode.el    |  5 +----
 lisp/progmodes/octave.el       |  4 +---
 lisp/progmodes/prolog.el       | 14 ++++----------
 lisp/progmodes/sql.el          | 10 ++++++----
 lisp/progmodes/tcl.el          |  4 +---
 lisp/progmodes/vhdl-mode.el    | 12 ++++++++----
 lisp/speedbar.el               |  6 ++----
 lisp/term.el                   |  7 -------
 lisp/textmodes/dns-mode.el     |  3 +--
 lisp/textmodes/reftex-index.el |  6 ++++--
 lisp/textmodes/reftex-toc.el   |  3 ++-
 lisp/textmodes/reftex.el       |  6 ++++--
 lisp/wid-browse.el             |  2 --
 37 files changed, 75 insertions(+), 108 deletions(-)

diff --git a/lisp/allout.el b/lisp/allout.el
index a4802a1c2a..880098c515 100644
--- a/lisp/allout.el
+++ b/lisp/allout.el
@@ -1621,8 +1621,7 @@ allout-setup-menubar
 	cur)
     (while menus
       (setq cur (car menus)
-	    menus (cdr menus))
-      (easy-menu-add cur))))
+            menus (cdr menus)))))
 ;;;_  > allout-overlay-preparations
 (defun allout-overlay-preparations ()
   "Set the properties of the allout invisible-text overlay and others."
diff --git a/lisp/cedet/semantic/grammar.el b/lisp/cedet/semantic/grammar.el
index f71ac6c413..b7670ef44b 100644
--- a/lisp/cedet/semantic/grammar.el
+++ b/lisp/cedet/semantic/grammar.el
@@ -1258,7 +1258,8 @@ semantic-grammar-setup-menu-xemacs
        (unless (boundp ',symbol)
          (easy-menu-define ,symbol nil
            "Grammar Menu" (copy-sequence semantic-grammar-menu)))
-       (easy-menu-add ,symbol)
+       (when (featurep 'xemacs)
+         (easy-menu-add ,symbol))
        (let ((,items (cdr ,mode-menu))
              (,path (list (car ,symbol))))
          (when ,items
diff --git a/lisp/cus-edit.el b/lisp/cus-edit.el
index d1077d367d..593ff3f7bb 100644
--- a/lisp/cus-edit.el
+++ b/lisp/cus-edit.el
@@ -5116,7 +5116,6 @@ Custom-mode
 Entry to this mode calls the value of `Custom-mode-hook'
 if that value is non-nil."
   (use-local-map custom-mode-map)
-  (easy-menu-add Custom-mode-menu)
   (setq-local tool-bar-map
 	      (or custom-tool-bar-map
 		  ;; Set up `custom-tool-bar-map'.
diff --git a/lisp/emacs-lisp/easymenu.el b/lisp/emacs-lisp/easymenu.el
index 73dabef3fa..7068980919 100644
--- a/lisp/emacs-lisp/easymenu.el
+++ b/lisp/emacs-lisp/easymenu.el
@@ -488,17 +488,14 @@ easy-menu-change
 `menu-bar-update-hook' or use a menu filter."
   (easy-menu-add-item map path (easy-menu-create-menu name items) before))
 
-;; XEmacs needs the following two functions to add and remove menus.
-;; In Emacs this is done automatically when switching keymaps, so
-;; here easy-menu-remove and easy-menu-add are a noops.
-(defalias 'easy-menu-remove 'ignore
+(define-obsolete-function-alias 'easy-menu-remove #'ignore "28.1"
   "Remove MENU from the current menu bar.
 Contrary to XEmacs, this is a nop on Emacs since menus are automatically
 \(de)activated when the corresponding keymap is (de)activated.
 
 \(fn MENU)")
 
-(defalias 'easy-menu-add #'ignore
+(define-obsolete-function-alias 'easy-menu-add #'ignore "28.1"
   "Add the menu to the menubar.
 On Emacs this is a nop, because menus are already automatically
 activated when the corresponding keymap is activated.  On XEmacs
diff --git a/lisp/erc/erc-menu.el b/lisp/erc/erc-menu.el
index 9c02899057..b36a1cb8fa 100644
--- a/lisp/erc/erc-menu.el
+++ b/lisp/erc/erc-menu.el
@@ -114,22 +114,19 @@ menu
      ;; make sure the menu only gets defined once, since Emacs 22
      ;; activates it immediately
      (easy-menu-define erc-menu erc-mode-map "ERC menu" erc-menu-definition)
-     (setq erc-menu-defined t))
-   (erc-menu-add))
-  ((erc-menu-remove)
-   ;; `easy-menu-remove' is a no-op in Emacs 22
+     (setq erc-menu-defined t)))
+  (;; `easy-menu-remove' is a no-op in Emacs 22
    (message "You might have to restart Emacs to remove the ERC menu")))
 
-;; silence byte-compiler warning
-(defvar erc-menu)
-
 (defun erc-menu-add ()
   "Add the ERC menu to the current buffer."
-  (easy-menu-add erc-menu erc-mode-map))
+  (declare (obsolete nil "28.1"))
+  nil)
 
 (defun erc-menu-remove ()
   "Remove the ERC menu from the current buffer."
-  (easy-menu-remove erc-menu))
+  (declare (obsolete nil "28.1"))
+  nil)
 
 (provide 'erc-menu)
 
diff --git a/lisp/gnus/gnus-art.el b/lisp/gnus/gnus-art.el
index 8f4ca7eb3b..7f594c9c36 100644
--- a/lisp/gnus/gnus-art.el
+++ b/lisp/gnus/gnus-art.el
@@ -7251,7 +7251,6 @@ gnus-article-edit-mode
        '(message-font-lock-keywords t))
   (set (make-local-variable 'mail-header-separator) "")
   (set (make-local-variable 'gnus-article-edit-mode) t)
-  (easy-menu-add message-mode-field-menu message-mode-map)
   (mml-mode)
   (setq buffer-read-only nil)
   (buffer-enable-undo)
diff --git a/lisp/gnus/message.el b/lisp/gnus/message.el
index 0782778fd4..f9811baa69 100644
--- a/lisp/gnus/message.el
+++ b/lisp/gnus/message.el
@@ -3109,8 +3109,6 @@ message-mode
        '(message-font-lock-keywords t))
   (if (boundp 'tool-bar-map)
       (set (make-local-variable 'tool-bar-map) (message-make-tool-bar)))
-  (easy-menu-add message-mode-menu message-mode-map)
-  (easy-menu-add message-mode-field-menu message-mode-map)
   ;; Mmmm... Forbidden properties...
   (add-hook 'after-change-functions #'message-strip-forbidden-properties
 	    nil 'local)
diff --git a/lisp/mh-e/mh-folder.el b/lisp/mh-e/mh-folder.el
index 0a73ff45c2..0fb5ebf1f7 100644
--- a/lisp/mh-e/mh-folder.el
+++ b/lisp/mh-e/mh-folder.el
@@ -656,9 +656,10 @@ mh-folder-mode
   (mh-funcall-if-exists hl-line-mode 1)
   (setq revert-buffer-function 'mh-undo-folder)
   (add-to-list 'minor-mode-alist '(mh-showing-mode " Show"))
-  (easy-menu-add mh-folder-sequence-menu)
-  (easy-menu-add mh-folder-message-menu)
-  (easy-menu-add mh-folder-folder-menu)
+  (mh-do-in-xemacs
+    (easy-menu-add mh-folder-sequence-menu)
+    (easy-menu-add mh-folder-message-menu)
+    (easy-menu-add mh-folder-folder-menu))
   (mh-inc-spool-make)
   (mh-set-help mh-folder-mode-help-messages)
   (if (and (featurep 'xemacs)
diff --git a/lisp/mh-e/mh-identity.el b/lisp/mh-e/mh-identity.el
index ed23996339..23fa87de82 100644
--- a/lisp/mh-e/mh-identity.el
+++ b/lisp/mh-e/mh-identity.el
@@ -91,7 +91,7 @@ mh-identity-add-menu
   "Add the current Identity menu.
 See `mh-identity-make-menu'."
   (if mh-identity-menu
-      (easy-menu-add mh-identity-menu)))
+      (mh-do-in-xemacs (easy-menu-add mh-identity-menu))))
 
 (defvar mh-identity-local nil
   "Buffer-local variable that holds the identity currently in use.")
diff --git a/lisp/mh-e/mh-letter.el b/lisp/mh-e/mh-letter.el
index 5e1ce40318..b8aca77ddc 100644
--- a/lisp/mh-e/mh-letter.el
+++ b/lisp/mh-e/mh-letter.el
@@ -330,7 +330,7 @@ mh-letter-mode
    (t
     ;; ...or the header only
     (setq font-lock-defaults '((mh-show-font-lock-keywords) t))))
-  (easy-menu-add mh-letter-menu)
+  (mh-do-in-xemacs (easy-menu-add mh-letter-menu))
   ;; Maybe we want to use the existing Mail menu from mail-mode in
   ;; 9.0; in the mean time, let's remove it since the redundancy will
   ;; only produce confusion.
diff --git a/lisp/mh-e/mh-search.el b/lisp/mh-e/mh-search.el
index 6fb76beff2..5cfe67865e 100644
--- a/lisp/mh-e/mh-search.el
+++ b/lisp/mh-e/mh-search.el
@@ -618,7 +618,7 @@ mh-search-mode
 
 \\{mh-search-mode-map}"
 
-  (easy-menu-add mh-pick-menu)
+  (mh-do-in-xemacs (easy-menu-add mh-pick-menu))
   (mh-set-help mh-search-mode-help-messages))
 
 
diff --git a/lisp/mh-e/mh-show.el b/lisp/mh-e/mh-show.el
index 7536f949e7..48ff74131d 100644
--- a/lisp/mh-e/mh-show.el
+++ b/lisp/mh-e/mh-show.el
@@ -863,9 +863,10 @@ mh-show-mode
   (when mh-decode-mime-flag
     (mh-make-local-hook 'kill-buffer-hook)
     (add-hook 'kill-buffer-hook 'mh-mime-cleanup nil t))
-  (easy-menu-add mh-show-sequence-menu)
-  (easy-menu-add mh-show-message-menu)
-  (easy-menu-add mh-show-folder-menu)
+  (mh-do-in-xemacs
+    (easy-menu-add mh-show-sequence-menu)
+    (easy-menu-add mh-show-message-menu)
+    (easy-menu-add mh-show-folder-menu))
   (make-local-variable 'mh-show-folder-buffer)
   (buffer-disable-undo)
   (use-local-map mh-show-mode-map))
diff --git a/lisp/net/sieve.el b/lisp/net/sieve.el
index 08367c698f..75bb4e242e 100644
--- a/lisp/net/sieve.el
+++ b/lisp/net/sieve.el
@@ -143,8 +143,7 @@ sieve-manage-mode-menu
 (define-derived-mode sieve-manage-mode special-mode "Sieve-manage"
   "Mode used for sieve script management."
   (buffer-disable-undo (current-buffer))
-  (setq truncate-lines t)
-  (easy-menu-add sieve-manage-mode-menu sieve-manage-mode-map))
+  (setq truncate-lines t))
 
 ;; Commands used in sieve-manage mode:
 
diff --git a/lisp/obsolete/otodo-mode.el b/lisp/obsolete/otodo-mode.el
index 2a4af290b6..6aada0755e 100644
--- a/lisp/obsolete/otodo-mode.el
+++ b/lisp/obsolete/otodo-mode.el
@@ -923,7 +923,8 @@ todo-menu
 ;;;###autoload
 (define-derived-mode todo-mode nil "TODO"
   "Major mode for editing TODO lists."
-  (easy-menu-add todo-menu))
+  (when (featurep 'xemacs)
+    (easy-menu-add todo-menu)))
 
 (with-suppressed-warnings ((lexical date entry))
   (defvar date)
diff --git a/lisp/org/org-agenda.el b/lisp/org/org-agenda.el
index 689d134627..82bf1b23f9 100644
--- a/lisp/org/org-agenda.el
+++ b/lisp/org/org-agenda.el
@@ -2236,7 +2236,6 @@ org-agenda-mode
   (setq mode-name "Org-Agenda")
   (setq indent-tabs-mode nil)
   (use-local-map org-agenda-mode-map)
-  (easy-menu-add org-agenda-menu)
   (when org-startup-truncated (setq truncate-lines t))
   (setq-local line-move-visual nil)
   (add-hook 'post-command-hook 'org-agenda-update-agenda-type nil 'local)
diff --git a/lisp/org/org-table.el b/lisp/org/org-table.el
index 5c37cb1af5..4636baae73 100644
--- a/lisp/org/org-table.el
+++ b/lisp/org/org-table.el
@@ -3287,7 +3287,6 @@ org-table-edit-formulas
       (setq-local org-selected-window sel-win)
       (use-local-map org-table-fedit-map)
       (add-hook 'post-command-hook #'org-table-fedit-post-command t t)
-      (easy-menu-add org-table-fedit-menu)
       (setq startline (org-current-line))
       (dolist (entry eql)
 	(let* ((type (cond
@@ -5129,15 +5128,13 @@ orgtbl-mode
 		  orgtbl-line-start-regexp))
     (when (fboundp 'font-lock-add-keywords)
       (font-lock-add-keywords nil orgtbl-extra-font-lock-keywords)
-      (org-restart-font-lock))
-    (easy-menu-add orgtbl-mode-menu))
+      (org-restart-font-lock)))
    (t
     (setq auto-fill-inhibit-regexp org-old-auto-fill-inhibit-regexp)
     (remove-hook 'before-change-functions 'org-before-change-function t)
     (when (fboundp 'font-lock-remove-keywords)
       (font-lock-remove-keywords nil orgtbl-extra-font-lock-keywords)
       (org-restart-font-lock))
-    (easy-menu-remove orgtbl-mode-menu)
     (force-mode-line-update 'all))))
 
 (defun orgtbl-make-binding (fun n &rest keys)
diff --git a/lisp/org/org.el b/lisp/org/org.el
index 1ab8ab6888..9a72b74d23 100644
--- a/lisp/org/org.el
+++ b/lisp/org/org.el
@@ -4791,7 +4791,6 @@ buffer-face-mode-face
 (require 'time-date)
 (unless (fboundp 'time-subtract) (defalias 'time-subtract 'subtract-time))
 (require 'easymenu)
-(autoload 'easy-menu-add "easymenu")
 (require 'overlay)
 
 ;; (require 'org-macs) moved higher up in the file before it is first used
diff --git a/lisp/progmodes/antlr-mode.el b/lisp/progmodes/antlr-mode.el
index 9dacd5856c..dc727aa375 100644
--- a/lisp/progmodes/antlr-mode.el
+++ b/lisp/progmodes/antlr-mode.el
@@ -2592,7 +2592,8 @@ antlr-mode
 	comment-start-skip "/\\*+ *\\|// *")
   ;; various -----------------------------------------------------------------
   (set (make-local-variable 'font-lock-defaults) antlr-font-lock-defaults)
-  (easy-menu-add antlr-mode-menu)
+  (when (featurep 'xemacs)
+    (easy-menu-add antlr-mode-menu))
   (set (make-local-variable 'imenu-create-index-function)
        'antlr-imenu-create-index-function)
   (set (make-local-variable 'imenu-generic-expression) t) ; fool stupid test
diff --git a/lisp/progmodes/cc-mode.el b/lisp/progmodes/cc-mode.el
index c5201d1af5..5e8cf6161e 100644
--- a/lisp/progmodes/cc-mode.el
+++ b/lisp/progmodes/cc-mode.el
@@ -2597,7 +2597,8 @@ c-mode
   (setq abbrev-mode t)
   (c-init-language-vars-for 'c-mode)
   (c-common-init 'c-mode)
-  (easy-menu-add c-c-menu)
+  (when (featurep 'xemacs)
+    (easy-menu-add c-c-menu))
   (cc-imenu-init cc-imenu-c-generic-expression)
   (add-hook 'flymake-diagnostic-functions 'flymake-cc nil t)
   (c-run-mode-hooks 'c-mode-common-hook))
@@ -2688,7 +2689,8 @@ c++-mode
   (setq abbrev-mode t)
   (c-init-language-vars-for 'c++-mode)
   (c-common-init 'c++-mode)
-  (easy-menu-add c-c++-menu)
+  (when (featurep 'xemacs)
+    (easy-menu-add c-c++-menu))
   (cc-imenu-init cc-imenu-c++-generic-expression)
   (add-hook 'flymake-diagnostic-functions 'flymake-cc nil t)
   (c-run-mode-hooks 'c-mode-common-hook))
@@ -2735,7 +2737,8 @@ objc-mode
   (setq abbrev-mode t)
   (c-init-language-vars-for 'objc-mode)
   (c-common-init 'objc-mode)
-  (easy-menu-add c-objc-menu)
+  (when (featurep 'xemacs)
+    (easy-menu-add c-objc-menu))
   (cc-imenu-init nil 'cc-imenu-objc-function)
   (c-run-mode-hooks 'c-mode-common-hook))
 
@@ -2785,7 +2788,8 @@ java-mode
   (setq abbrev-mode t)
   (c-init-language-vars-for 'java-mode)
   (c-common-init 'java-mode)
-  (easy-menu-add c-java-menu)
+  (when (featurep 'xemacs)
+    (easy-menu-add c-java-menu))
   (cc-imenu-init cc-imenu-java-generic-expression)
   (c-run-mode-hooks 'c-mode-common-hook))
 
@@ -2827,7 +2831,8 @@ idl-mode
   (c-initialize-cc-mode t)
   (c-init-language-vars-for 'idl-mode)
   (c-common-init 'idl-mode)
-  (easy-menu-add c-idl-menu)
+  (when (featurep 'xemacs)
+    (easy-menu-add c-idl-menu))
   ;;(cc-imenu-init cc-imenu-idl-generic-expression) ;TODO
   (c-run-mode-hooks 'c-mode-common-hook))
 
@@ -2872,7 +2877,8 @@ pike-mode
   (setq	abbrev-mode t)
   (c-init-language-vars-for 'pike-mode)
   (c-common-init 'pike-mode)
-  (easy-menu-add c-pike-menu)
+  (when (featurep 'xemacs)
+    (easy-menu-add c-pike-menu))
   ;;(cc-imenu-init cc-imenu-pike-generic-expression) ;TODO
   (c-run-mode-hooks 'c-mode-common-hook))
 
diff --git a/lisp/progmodes/cperl-mode.el b/lisp/progmodes/cperl-mode.el
index 3606f9a395..659bc93c8e 100644
--- a/lisp/progmodes/cperl-mode.el
+++ b/lisp/progmodes/cperl-mode.el
@@ -1720,8 +1720,6 @@ cperl-mode
   (and (boundp 'msb-menu-cond)
        (not cperl-msb-fixed)
        (cperl-msb-fix))
-  (if (fboundp 'easy-menu-add)
-      (easy-menu-add cperl-menu))	; A NOP in Emacs.
   (if cperl-hook-after-change
       (add-hook 'after-change-functions #'cperl-after-change-function nil t))
   ;; After hooks since fontification will break this
diff --git a/lisp/progmodes/hideshow.el b/lisp/progmodes/hideshow.el
index 2ad66ccc5e..4dee72c737 100644
--- a/lisp/progmodes/hideshow.el
+++ b/lisp/progmodes/hideshow.el
@@ -948,7 +948,6 @@ hs-minor-mode
         (add-hook 'change-major-mode-hook
                   #'turn-off-hideshow
                   nil t)
-        (easy-menu-add hs-minor-mode-menu)
         (set (make-local-variable 'line-move-ignore-invisible) t)
         (add-to-invisibility-spec '(hs . t)))
     (remove-from-invisibility-spec '(hs . t))
diff --git a/lisp/progmodes/idlw-help.el b/lisp/progmodes/idlw-help.el
index 2d4ea465c4..52c50c5317 100644
--- a/lisp/progmodes/idlw-help.el
+++ b/lisp/progmodes/idlw-help.el
@@ -306,7 +306,6 @@ idlwave-help-mode
 Here are all keybindings.
 \\{idlwave-help-mode-map}"
   (buffer-disable-undo)
-  (easy-menu-add idlwave-help-menu idlwave-help-mode-map)
   (setq truncate-lines t)
   (setq case-fold-search t)
   (setq mode-line-format
diff --git a/lisp/progmodes/idlw-shell.el b/lisp/progmodes/idlw-shell.el
index 38127fccbc..6f71482a9e 100644
--- a/lisp/progmodes/idlw-shell.el
+++ b/lisp/progmodes/idlw-shell.el
@@ -973,7 +973,6 @@ idlwave-shell-mode
 	    nil 'local)
   (add-hook 'kill-buffer-hook 'idlwave-shell-delete-temp-files nil 'local)
   (add-hook 'kill-emacs-hook 'idlwave-shell-delete-temp-files)
-  (easy-menu-add idlwave-shell-mode-menu idlwave-shell-mode-map)
 
   ;; Set the optional comint variables
   (when idlwave-shell-comint-settings
@@ -4362,11 +4361,7 @@ idlwave-shell-menu-def
        idlwave-shell-menu-def)
       (save-current-buffer
 	(dolist (buf (buffer-list))
-          (set-buffer buf)
-          (if (derived-mode-p 'idlwave-mode)
-              (progn
-                (easy-menu-remove idlwave-mode-debug-menu)
-                (easy-menu-add idlwave-mode-debug-menu)))))))
+          (set-buffer buf)))))
 
 ;; The Breakpoint Glyph -------------------------------------------------------
 
diff --git a/lisp/progmodes/idlwave.el b/lisp/progmodes/idlwave.el
index 86f9f33672..8b73bc5b53 100644
--- a/lisp/progmodes/idlwave.el
+++ b/lisp/progmodes/idlwave.el
@@ -1873,10 +1873,6 @@ idlwave-mode
   (set (make-local-variable 'indent-tabs-mode) nil)
   (set (make-local-variable 'completion-ignore-case) t)
 
-  (when (featurep 'easymenu)
-    (easy-menu-add idlwave-mode-menu idlwave-mode-map)
-    (easy-menu-add idlwave-mode-debug-menu idlwave-mode-map))
-
   (setq abbrev-mode t)
 
   (set (make-local-variable idlwave-fill-function) 'idlwave-auto-fill)
diff --git a/lisp/progmodes/meta-mode.el b/lisp/progmodes/meta-mode.el
index 4a5d872b79..87c20a2ee0 100644
--- a/lisp/progmodes/meta-mode.el
+++ b/lisp/progmodes/meta-mode.el
@@ -946,10 +946,7 @@ meta-common-mode
   (set (make-local-variable 'font-lock-defaults)
        '(meta-font-lock-keywords
          nil nil ((?_ . "w")) nil
-         (font-lock-comment-start-regexp . "%")))
-
-  ;; Activate syntax table, keymap and menu.
-  (easy-menu-add meta-mode-menu))
+         (font-lock-comment-start-regexp . "%"))))

 ;;;###autoload
diff --git a/lisp/progmodes/octave.el b/lisp/progmodes/octave.el
index 55a78c6cc8..c313ad1179 100644
--- a/lisp/progmodes/octave.el
+++ b/lisp/progmodes/octave.el
@@ -619,9 +619,7 @@ octave-mode
   (add-hook 'before-save-hook 'octave-sync-function-file-names nil t)
   (setq-local beginning-of-defun-function 'octave-beginning-of-defun)
   (and octave-font-lock-texinfo-comment (octave-font-lock-texinfo-comment))
-  (add-hook 'eldoc-documentation-functions 'octave-eldoc-function nil t)
-
-  (easy-menu-add octave-mode-menu))
+  (add-hook 'eldoc-documentation-functions 'octave-eldoc-function nil t))
 
 
 (defcustom inferior-octave-program "octave"
diff --git a/lisp/progmodes/prolog.el b/lisp/progmodes/prolog.el
index 124f652ed6..1812fe07fd 100644
--- a/lisp/progmodes/prolog.el
+++ b/lisp/progmodes/prolog.el
@@ -1293,8 +1293,7 @@ prolog-inferior-mode
   (setq-local shell-dirstack-query "pwd.")
   (setq-local compilation-error-regexp-alist
               prolog-inferior-error-regexp-alist)
-  (compilation-shell-minor-mode)
-  (prolog-inferior-menu))
+  (compilation-shell-minor-mode))
 
 (defun prolog-input-filter (str)
   (cond ((string-match "\\`\\s *\\'" str) nil) ;whitespace
@@ -3381,9 +3380,6 @@ prolog-variables-to-anonymous
 (defun prolog-menu ()
   "Add the menus for the Prolog editing buffers."
 
-  (easy-menu-add prolog-edit-menu-insert-move)
-  (easy-menu-add prolog-edit-menu-runtime)
-
   ;; Add predicate index menu
   (setq-local imenu-create-index-function
               'imenu-default-create-index-function)
@@ -3394,9 +3390,7 @@ prolog-menu
 
   (if (and prolog-imenu-flag
            (< (count-lines (point-min) (point-max)) prolog-imenu-max-lines))
-      (imenu-add-to-menubar "Predicates"))
-
-  (easy-menu-add prolog-menu-help))
+      (imenu-add-to-menubar "Predicates")))
 
 (easy-menu-define
   prolog-inferior-menu-all prolog-inferior-mode-map
@@ -3439,8 +3433,8 @@ prolog-inferior-menu
   "Create the menus for the Prolog inferior buffer.
 This menu is dynamically created because one may change systems during
 the life of an Emacs session."
-  (easy-menu-add prolog-inferior-menu-all)
-  (easy-menu-add prolog-menu-help))
+  (declare (obsolete nil "28.1"))
+  nil)
 
 (defun prolog-mode-version ()
   "Echo the current version of Prolog mode in the minibuffer."
diff --git a/lisp/progmodes/sql.el b/lisp/progmodes/sql.el
index 6b0df2d700..22099394ff 100644
--- a/lisp/progmodes/sql.el
+++ b/lisp/progmodes/sql.el
@@ -4186,8 +4186,9 @@ sql-mode
 	    (modify-syntax-entry ?\\\\ \"\\\\\" sql-mode-syntax-table)))"
   :abbrev-table sql-mode-abbrev-table
 
-  (if sql-mode-menu
-      (easy-menu-add sql-mode-menu)); XEmacs
+  (when (and (featurep 'xemacs)
+             sql-mode-menu)
+      (easy-menu-add sql-mode-menu))
 
   ;; (smie-setup sql-smie-grammar #'sql-smie-rules)
   (set (make-local-variable 'comment-start) "--")
@@ -4312,8 +4313,9 @@ sql-interactive-mode
   (setq mode-name
         (concat "SQLi[" (or (sql-get-product-feature sql-product :name)
                             (symbol-name sql-product)) "]"))
-  (if sql-interactive-mode-menu
-      (easy-menu-add sql-interactive-mode-menu)) ; XEmacs
+  (when (and (featurep 'xemacs)
+             sql-interactive-mode-menu)
+    (easy-menu-add sql-interactive-mode-menu))
 
   ;; Note that making KEYWORDS-ONLY nil will cause havoc if you try
   ;; SELECT 'x' FROM DUAL with SQL*Plus, because the title of the column
diff --git a/lisp/progmodes/tcl.el b/lisp/progmodes/tcl.el
index f0dd9afa4c..ff3fb9657d 100644
--- a/lisp/progmodes/tcl.el
+++ b/lisp/progmodes/tcl.el
@@ -654,9 +654,7 @@ tcl-mode
        #'tcl-add-log-defun)
 
   (setq-local beginning-of-defun-function #'tcl-beginning-of-defun-function)
-  (setq-local end-of-defun-function #'tcl-end-of-defun-function)
-
-  (easy-menu-add tcl-mode-menu))
+  (setq-local end-of-defun-function #'tcl-end-of-defun-function))
 
 
 
diff --git a/lisp/progmodes/vhdl-mode.el b/lisp/progmodes/vhdl-mode.el
index f288facba5..489092f58e 100644
--- a/lisp/progmodes/vhdl-mode.el
+++ b/lisp/progmodes/vhdl-mode.el
@@ -4205,9 +4205,11 @@ vhdl-mode-menu-list
 (defun vhdl-update-mode-menu ()
   "Update VHDL Mode menu."
   (interactive)
-  (easy-menu-remove vhdl-mode-menu-list) ; for XEmacs
+  (when (featurep 'xemacs)
+    (easy-menu-remove vhdl-mode-menu-list))
   (setq vhdl-mode-menu-list (vhdl-create-mode-menu))
-  (easy-menu-add vhdl-mode-menu-list)	; for XEmacs
+  (when (featurep 'xemacs)
+    (easy-menu-add vhdl-mode-menu-list))
   (easy-menu-define vhdl-mode-menu vhdl-mode-map
 		    "Menu keymap for VHDL Mode." vhdl-mode-menu-list))
 
@@ -4313,7 +4315,8 @@ vhdl-add-source-files-menu
     (push ["*Rescan*" vhdl-add-source-files-menu t] menu-list)
     (push "Sources" menu-list)
     ;; Create menu
-    (easy-menu-add menu-list)
+    (when (featurep 'xemacs)
+      (easy-menu-add menu-list))
     (easy-menu-define vhdl-sources-menu newmap
 		      "VHDL source files menu" menu-list))
   (message ""))
@@ -4926,7 +4929,8 @@ vhdl-mode
   ;; add source file menu
   (if vhdl-source-file-menu (vhdl-add-source-files-menu))
   ;; add VHDL menu
-  (easy-menu-add vhdl-mode-menu-list)	; for XEmacs
+  (when (featurep 'xemacs)
+    (easy-menu-add vhdl-mode-menu-list))
   (easy-menu-define vhdl-mode-menu vhdl-mode-map
 		    "Menu keymap for VHDL Mode." vhdl-mode-menu-list)
   ;; initialize hideshow and add menu
diff --git a/lisp/speedbar.el b/lisp/speedbar.el
index 3619b23d9e..34687805b5 100644
--- a/lisp/speedbar.el
+++ b/lisp/speedbar.el
@@ -1144,6 +1144,7 @@ speedbar-set-mode-line-format
 
 (defvar speedbar-previous-menu nil
   "The menu before the last `speedbar-reconfigure-keymaps' was called.")
+(make-obsolete-variable 'speedbar-previous-menu "no longer used." "28.1")
 
 (defun speedbar-reconfigure-keymaps ()
   "Reconfigure the menu-bar in a speedbar frame.
@@ -1195,10 +1196,7 @@ speedbar-reconfigure-keymaps
 			 (speedbar-initial-keymap)
 			 ;; This creates a small keymap we can glom the
 			 ;; menu adjustments into.
-			 (speedbar-make-specialized-keymap)))
-      ;; Delete the old menu if applicable.
-      (if speedbar-previous-menu (easy-menu-remove speedbar-previous-menu))
-      (setq speedbar-previous-menu md)
+                         (speedbar-make-specialized-keymap)))
       ;; Now add the new menu
       (easy-menu-define speedbar-menu-map (current-local-map)
         "Speedbar menu" md))
diff --git a/lisp/term.el b/lisp/term.el
index 585232be6c..ca64d28d9b 100644
--- a/lisp/term.el
+++ b/lisp/term.el
@@ -1107,8 +1107,6 @@ term-mode
 
   (term--reset-scroll-region)
 
-  (easy-menu-add term-terminal-menu)
-  (easy-menu-add term-signals-menu)
   (or term-input-ring
       (setq term-input-ring (make-ring term-input-ring-size)))
   (term-update-mode-line))
@@ -1293,8 +1291,6 @@ term-char-mode
   (when (term-in-line-mode)
     (setq term-old-mode-map (current-local-map))
     (use-local-map term-raw-map)
-    (easy-menu-add term-terminal-menu)
-    (easy-menu-add term-signals-menu)
 
     ;; Don't allow changes to the buffer or to point which are not
     ;; caused by the process filter.
@@ -3550,9 +3546,6 @@ term-process-pager
   ;;   (stop-process process))
   (setq term-pager-old-local-map (current-local-map))
   (use-local-map term-pager-break-map)
-  (easy-menu-add term-terminal-menu)
-  (easy-menu-add term-signals-menu)
-  (easy-menu-add term-pager-menu)
   (make-local-variable 'term-old-mode-line-format)
   (setq term-old-mode-line-format mode-line-format)
   (setq mode-line-format
diff --git a/lisp/textmodes/dns-mode.el b/lisp/textmodes/dns-mode.el
index 6dfea8f188..712955e84d 100644
--- a/lisp/textmodes/dns-mode.el
+++ b/lisp/textmodes/dns-mode.el
@@ -184,8 +184,7 @@ dns-mode
   (set (make-local-variable 'font-lock-defaults)
        '(dns-mode-font-lock-keywords nil nil ((?_ . "w"))))
   (add-hook 'before-save-hook 'dns-mode-soa-maybe-increment-serial
-	    nil t)
-  (easy-menu-add dns-mode-menu dns-mode-map))
+            nil t))
 
 ;;;###autoload (defalias 'zone-mode 'dns-mode)
 
diff --git a/lisp/textmodes/reftex-index.el b/lisp/textmodes/reftex-index.el
index a1e30269d2..bebda48367 100644
--- a/lisp/textmodes/reftex-index.el
+++ b/lisp/textmodes/reftex-index.el
@@ -408,7 +408,8 @@ reftex-index-mode
     (make-local-hook 'post-command-hook)
     (make-local-hook 'pre-command-hook))
   (make-local-variable 'reftex-last-follow-point)
-  (easy-menu-add reftex-index-menu reftex-index-mode-map)
+  (when (featurep 'xemacs)
+    (easy-menu-add reftex-index-menu reftex-index-mode-map))
   (add-hook 'post-command-hook 'reftex-index-post-command-hook nil t)
   (add-hook 'pre-command-hook  'reftex-index-pre-command-hook nil t))
 
@@ -1386,7 +1387,8 @@ reftex-index-phrases-mode
   :syntax-table reftex-index-phrases-syntax-table
   (set (make-local-variable 'font-lock-defaults)
        reftex-index-phrases-font-lock-defaults)
-  (easy-menu-add reftex-index-phrases-menu reftex-index-phrases-mode-map)
+  (when (featurep 'xemacs)
+    (easy-menu-add reftex-index-phrases-menu reftex-index-phrases-mode-map))
   (set (make-local-variable 'reftex-index-phrases-marker) (make-marker)))
 ;; (add-hook 'reftex-index-phrases-mode-hook 'turn-on-font-lock)
 
diff --git a/lisp/textmodes/reftex-toc.el b/lisp/textmodes/reftex-toc.el
index 02e7e3a8f1..eb6ed2ff44 100644
--- a/lisp/textmodes/reftex-toc.el
+++ b/lisp/textmodes/reftex-toc.el
@@ -153,7 +153,8 @@ reftex-toc-mode
   (make-local-variable 'reftex-last-follow-point)
   (add-hook 'post-command-hook 'reftex-toc-post-command-hook nil t)
   (add-hook 'pre-command-hook  'reftex-toc-pre-command-hook nil t)
-  (easy-menu-add reftex-toc-menu reftex-toc-mode-map))
+  (when (featurep 'xemacs)
+    (easy-menu-add reftex-toc-menu reftex-toc-mode-map)))
 
 (defvar reftex-last-toc-file nil
   "Stores the file name from which `reftex-toc' was called.  For redo command.")
diff --git a/lisp/textmodes/reftex.el b/lisp/textmodes/reftex.el
index 4071c0dd07..29ebab5f9b 100644
--- a/lisp/textmodes/reftex.el
+++ b/lisp/textmodes/reftex.el
@@ -207,7 +207,8 @@ reftex-mode
   (if reftex-mode
       (progn
         ;; Mode was turned on
-        (easy-menu-add reftex-mode-menu)
+        (when (featurep 'xemacs)
+          (easy-menu-add reftex-mode-menu))
         (and reftex-plug-into-AUCTeX
              (reftex-plug-into-AUCTeX))
         (unless (get 'reftex-auto-view-crossref 'initialized)
@@ -224,7 +225,8 @@ reftex-mode
 
         (run-hooks 'reftex-mode-hook))
     ;; Mode was turned off
-    (easy-menu-remove reftex-mode-menu)))
+    (when (featurep 'xemacs)
+      (easy-menu-remove reftex-mode-menu))))
 
 (defvar reftex-docstruct-symbol)
 (defun reftex-kill-buffer-hook ()
diff --git a/lisp/wid-browse.el b/lisp/wid-browse.el
index 53f918cff9..f5c3d486f4 100644
--- a/lisp/wid-browse.el
+++ b/lisp/wid-browse.el
@@ -77,8 +77,6 @@ widget-browse-mode
   (setq major-mode 'widget-browse-mode
 	mode-name "Widget")
   (use-local-map widget-browse-mode-map)
-  (easy-menu-add widget-browse-mode-customize-menu)
-  (easy-menu-add widget-browse-mode-menu)
   (run-mode-hooks 'widget-browse-mode-hook))
 
 (put 'widget-browse-mode 'mode-class 'special)
-- 
2.29.2