]> code.delx.au - gnu-emacs/blobdiff - lisp/recentf.el
Update copyright years, update license to GPLv3 or later.
[gnu-emacs] / lisp / recentf.el
index 2afb0955c46443d03238f827fbb62f1bfcebdeb4..85f00b2bc5f3734a56f1d8b879c29da97501ef6a 100644 (file)
@@ -1,7 +1,7 @@
 ;;; recentf.el --- setup a menu of recently opened files
 
 ;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004,
-;;   2005, 2006 Free Software Foundation, Inc.
+;;   2005, 2006, 2007 Free Software Foundation, Inc.
 
 ;; Author: David Ponce <david@dponce.com>
 ;; Created: July 19 1999
@@ -11,7 +11,7 @@
 
 ;; GNU Emacs is free software; you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published
-;; by the Free Software Foundation; either version 2, or (at your
+;; by the Free Software Foundation; either version 3, or (at your
 ;; option) any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
@@ -72,7 +72,14 @@ See the command `recentf-save-list'."
 (defcustom recentf-save-file "~/.recentf"
   "*File to save the recent list into."
   :group 'recentf
-  :type 'file)
+  :type 'file
+  :initialize 'custom-initialize-default
+  :set (lambda (symbol value)
+         (let ((oldvalue (eval symbol)))
+           (custom-set-default symbol value)
+           (and (not (equal value oldvalue))
+                recentf-mode
+                (recentf-load-list)))))
 
 (defcustom recentf-save-file-modes 384 ;; 0600
   "Mode bits of recentf save file, as an integer, or nil.
@@ -82,7 +89,7 @@ file.  See also the function `set-file-modes'."
   :group 'recentf
   :type '(choice (const :tag "Don't change" nil)
           integer))
-  
+
 (defcustom recentf-exclude nil
   "*List of regexps and predicates for filenames excluded from the recent list.
 When a filename matches any of the regexps or satisfies any of the
@@ -92,19 +99,27 @@ must return non-nil to exclude it."
   :group 'recentf
   :type '(repeat (choice regexp function)))
 
+(defun recentf-keep-default-predicate (file)
+  "Return non-nil if FILE should be kept in the recent list.
+It handles the case of remote files as well."
+  (cond
+   ((file-remote-p file nil t) (file-readable-p file))
+   ((file-remote-p file))
+   ((file-readable-p file))))
+
 (defcustom recentf-keep
-  '(file-readable-p)
+  '(recentf-keep-default-predicate)
   "*List of regexps and predicates for filenames kept in the recent list.
 Regexps and predicates are tried in the specified order.
 When nil all filenames are kept in the recent list.
 When a filename matches any of the regexps or satisfies any of the
 predicates it is kept in the recent list.
-The default is to keep readable files.
+The default is to keep readable files.  Remote files are checked
+for readability only in case a connection is established to that
+remote system, otherwise they are kept in the recent list without
+checking their readability.
 A predicate is a function that is passed a filename to check and that
-must return non-nil to keep it.  For example, you can add the
-`file-remote-p' predicate in front of this list to keep remote file
-names in the recent list without checking their readability through a
-remote access."
+must return non-nil to keep it."
   :group 'recentf
   :type '(repeat (choice regexp function)))
 
@@ -1165,7 +1180,7 @@ IGNORE other arguments."
            :button-prefix ""
            :button-suffix ""
            :button-face default
-           :format "%[%t%]\n"
+           :format "%[%t\n%]"
            :help-echo ,(concat "Open " (cdr menu-element))
            :action recentf-open-files-action
            ,(cdr menu-element))))
@@ -1318,9 +1333,7 @@ With prefix argument ARG, turn on if positive, otherwise off.
 Returns non-nil if the new state is enabled.
 
 When recentf mode is enabled, it maintains a menu for visiting files
-that were operated on recently.
-
-\\{recentf-mode-map}"
+that were operated on recently."
   :global t
   :group 'recentf
   :keymap recentf-mode-map