Mercurial > emacs
comparison lisp/recentf.el @ 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 | 695cf19ef79e |
children | 5308684cd360 |
comparison
equal
deleted
inserted
replaced
52467:0d2c9a1cea58 | 52468:de4ce9c67474 |
---|---|
6 ;; Author: David Ponce <david@dponce.com> | 6 ;; Author: David Ponce <david@dponce.com> |
7 ;; Created: July 19 1999 | 7 ;; Created: July 19 1999 |
8 ;; Maintainer: FSF | 8 ;; Maintainer: FSF |
9 ;; Keywords: files | 9 ;; Keywords: files |
10 | 10 |
11 (defconst recentf-version "$Revision: 1.24 $") | 11 (defconst recentf-version "$Revision: 1.25 $") |
12 | 12 |
13 ;; This file is part of GNU Emacs. | 13 ;; This file is part of GNU Emacs. |
14 | 14 |
15 ;; GNU Emacs is free software; you can redistribute it and/or modify | 15 ;; GNU Emacs is free software; you can redistribute it and/or modify |
16 ;; it under the terms of the GNU General Public License as published | 16 ;; it under the terms of the GNU General Public License as published |
96 :type 'string | 96 :type 'string |
97 :set 'recentf-menu-customization-changed) | 97 :set 'recentf-menu-customization-changed) |
98 | 98 |
99 (defcustom recentf-menu-path '("files") | 99 (defcustom recentf-menu-path '("files") |
100 "*Path where to add the recentf menu. | 100 "*Path where to add the recentf menu. |
101 If nil add it at top level (see also `easy-menu-change')." | 101 If nil add it at top level (see also `easy-menu-add-item')." |
102 :group 'recentf | 102 :group 'recentf |
103 :type '(choice (const :tag "Top Level" nil) | 103 :type '(choice (const :tag "Top Level" nil) |
104 (sexp :tag "Menu Path")) | 104 (sexp :tag "Menu Path")) |
105 :set 'recentf-menu-customization-changed) | 105 :set 'recentf-menu-customization-changed) |
106 | 106 |
107 (defcustom recentf-menu-before "Open File..." | 107 (defcustom recentf-menu-before "Open File..." |
108 "*Name of the menu before which the recentf menu will be added. | 108 "*Name of the menu before which the recentf menu will be added. |
109 If nil add it at end of menu (see also `easy-menu-change')." | 109 If nil add it at end of menu (see also `easy-menu-add-item')." |
110 :group 'recentf | 110 :group 'recentf |
111 :type '(choice (string :tag "Name") | 111 :type '(choice (string :tag "Name") |
112 (const :tag "Last" nil)) | 112 (const :tag "Last" nil)) |
113 :set 'recentf-menu-customization-changed) | 113 :set 'recentf-menu-customization-changed) |
114 | 114 |
518 (cons item (mapcar 'recentf-make-menu-item value)) | 518 (cons item (mapcar 'recentf-make-menu-item value)) |
519 (vector item (list recentf-menu-action value) | 519 (vector item (list recentf-menu-action value) |
520 :help (concat "Open " value) | 520 :help (concat "Open " value) |
521 :active t)))) | 521 :active t)))) |
522 | 522 |
523 (defsubst recentf-menu-bar () | |
524 "Return the keymap of the global menu bar." | |
525 (lookup-key global-map [menu-bar])) | |
526 | |
523 (defun recentf-clear-data () | 527 (defun recentf-clear-data () |
524 "Clear data used to build the recentf menu. | 528 "Clear data used to build the recentf menu. |
525 This force a rebuild of the menu." | 529 This force a rebuild of the menu." |
526 (easy-menu-remove-item nil recentf-menu-path recentf-menu-title) | 530 (easy-menu-remove-item (recentf-menu-bar) |
531 recentf-menu-path recentf-menu-title) | |
527 (setq recentf-data-cache nil)) | 532 (setq recentf-data-cache nil)) |
528 | 533 |
529 ;;; Predefined menu filters | 534 ;;; Predefined menu filters |
530 ;; | 535 ;; |
531 (defsubst recentf-sort-ascending (l) | 536 (defsubst recentf-sort-ascending (l) |
914 (let ((cache (cons default-directory recentf-list))) | 919 (let ((cache (cons default-directory recentf-list))) |
915 ;; Does nothing, if nothing has changed. | 920 ;; Does nothing, if nothing has changed. |
916 (unless (equal recentf-data-cache cache) | 921 (unless (equal recentf-data-cache cache) |
917 (setq recentf-data-cache cache) | 922 (setq recentf-data-cache cache) |
918 (condition-case err | 923 (condition-case err |
919 (easy-menu-change recentf-menu-path | 924 (easy-menu-add-item |
920 recentf-menu-title | 925 (recentf-menu-bar) recentf-menu-path |
921 (recentf-make-menu-items) | 926 (easy-menu-create-menu recentf-menu-title |
922 recentf-menu-before) | 927 (recentf-make-menu-items)) |
928 recentf-menu-before) | |
923 (error | 929 (error |
924 (message "recentf update menu failed: %s" | 930 (message "recentf update menu failed: %s" |
925 (error-message-string err))))))) | 931 (error-message-string err))))))) |
926 | 932 |
927 (defconst recentf-used-hooks | 933 (defconst recentf-used-hooks |