X-Git-Url: https://git.hcoop.net/bpt/emacs.git/blobdiff_plain/ecae6af979abcbb5b45c33ee05ceb297678ec9a0..10339fa90363cf20a9e379c083df83405718302d:/lisp/recentf.el diff --git a/lisp/recentf.el b/lisp/recentf.el index 589e5ebbd3..d0be69b51f 100644 --- a/lisp/recentf.el +++ b/lisp/recentf.el @@ -1,7 +1,6 @@ ;;; recentf.el --- setup a menu of recently opened files -;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, -;; 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +;; Copyright (C) 1999-2011 Free Software Foundation, Inc. ;; Author: David Ponce ;; Created: July 19 1999 @@ -26,11 +25,14 @@ ;; This package maintains a menu for visiting files that were operated ;; on recently. When enabled a new "Open Recent" sub menu is -;; displayed in the "Files" menu. The recent files list is +;; displayed in the "File" menu. The recent files list is ;; automatically saved across Emacs sessions. You can customize the ;; number of recent files displayed, the location of the menu and ;; others options (see the source code for details). +;; To enable this package, add the following to your .emacs: +;; (recentf-mode 1) + ;;; History: ;; @@ -67,7 +69,7 @@ See the command `recentf-save-list'." :group 'recentf :type 'integer) -(defcustom recentf-save-file "~/.recentf" +(defcustom recentf-save-file (convert-standard-filename "~/.recentf") "File to save the recent list into." :group 'recentf :type 'file @@ -300,7 +302,7 @@ used as shortcuts to open the Nth file." ;;; Utilities ;; (defconst recentf-case-fold-search - (memq system-type '(vax-vms windows-nt cygwin)) + (memq system-type '(windows-nt cygwin)) "Non-nil if recentf searches and matches should ignore case.") (defsubst recentf-string-equal (s1 s2) @@ -1307,13 +1309,20 @@ empty `file-name-history' with the recent list." That is, remove duplicates, non-kept, and excluded files." (interactive) (message "Cleaning up the recentf list...") - (let ((n 0) newlist) + (let ((n 0) + (ht (make-hash-table + :size recentf-max-saved-items + :test 'equal)) + newlist key) (dolist (f recentf-list) - (setq f (recentf-expand-file-name f)) + (setq f (recentf-expand-file-name f) + key (if recentf-case-fold-search (downcase f) f)) (if (and (recentf-include-p f) (recentf-keep-p f) - (not (recentf-string-member f newlist))) - (push f newlist) + (not (gethash key ht))) + (progn + (push f newlist) + (puthash key t ht)) (setq n (1+ n)) (message "File %s removed from the recentf list" f))) (message "Cleaning up the recentf list...done (%d removed)" n) @@ -1345,15 +1354,16 @@ that were operated on recently." (recentf-auto-cleanup) (let ((hook-setup (if recentf-mode 'add-hook 'remove-hook))) (dolist (hook recentf-used-hooks) - (apply hook-setup hook))) - (run-hooks 'recentf-mode-hook) - (when (interactive-p) - (message "Recentf mode %sabled" (if recentf-mode "en" "dis")))) - recentf-mode) + (apply hook-setup hook))))) + +(defun recentf-unload-function () + "Unload the recentf library." + (recentf-mode -1) + ;; continue standard unloading + nil) (provide 'recentf) (run-hooks 'recentf-load-hook) -;; arch-tag: 78f1eec9-0d16-4d19-a4eb-2e4529edb62a ;;; recentf.el ends here