changeset 52468:de4ce9c67474

Ensure that recentf correctly update the menu bar: (recentf-menu-path,recentf-menu-before): Doc fix. (recentf-menu-bar): New function. (recentf-clear-data): Use it (recentf-update-menu): Likewise. Use easy-menu-add-item instead of easy-menu-change.
author Eli Zaretskii <eliz@gnu.org>
date Mon, 08 Sep 2003 19:00:17 +0000
parents 0d2c9a1cea58
children 88758cad1012
files lisp/recentf.el
diffstat 1 files changed, 14 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/recentf.el	Mon Sep 08 18:26:17 2003 +0000
+++ b/lisp/recentf.el	Mon Sep 08 19:00:17 2003 +0000
@@ -8,7 +8,7 @@
 ;; Maintainer: FSF
 ;; Keywords: files
 
-(defconst recentf-version "$Revision: 1.24 $")
+(defconst recentf-version "$Revision: 1.25 $")
 
 ;; This file is part of GNU Emacs.
 
@@ -98,7 +98,7 @@
 
 (defcustom recentf-menu-path '("files")
   "*Path where to add the recentf menu.
-If nil add it at top level (see also `easy-menu-change')."
+If nil add it at top level (see also `easy-menu-add-item')."
   :group 'recentf
   :type '(choice (const :tag "Top Level" nil)
                  (sexp :tag "Menu Path"))
@@ -106,7 +106,7 @@
 
 (defcustom recentf-menu-before "Open File..."
   "*Name of the menu before which the recentf menu will be added.
-If nil add it at end of menu (see also `easy-menu-change')."
+If nil add it at end of menu (see also `easy-menu-add-item')."
   :group 'recentf
   :type '(choice (string :tag "Name")
                  (const :tag "Last" nil))
@@ -520,10 +520,15 @@
               :help (concat "Open " value)
               :active t))))
 
+(defsubst recentf-menu-bar ()
+  "Return the keymap of the global menu bar."
+  (lookup-key global-map [menu-bar]))
+
 (defun recentf-clear-data ()
   "Clear data used to build the recentf menu.
 This force a rebuild of the menu."
-  (easy-menu-remove-item nil recentf-menu-path recentf-menu-title)
+  (easy-menu-remove-item (recentf-menu-bar)
+                         recentf-menu-path recentf-menu-title)
   (setq recentf-data-cache nil))
 
 ;;; Predefined menu filters
@@ -916,10 +921,11 @@
     (unless (equal recentf-data-cache cache)
       (setq recentf-data-cache cache)
       (condition-case err
-          (easy-menu-change recentf-menu-path
-                            recentf-menu-title
-                            (recentf-make-menu-items)
-                            recentf-menu-before)
+          (easy-menu-add-item
+           (recentf-menu-bar) recentf-menu-path
+           (easy-menu-create-menu recentf-menu-title
+                                  (recentf-make-menu-items))
+           recentf-menu-before)
         (error
          (message "recentf update menu failed: %s"
                   (error-message-string err)))))))