emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/lisp/recentf.el


From: David Ponce
Subject: [Emacs-diffs] Changes to emacs/lisp/recentf.el
Date: Wed, 23 Mar 2005 02:20:48 -0500

Index: emacs/lisp/recentf.el
diff -c emacs/lisp/recentf.el:1.34 emacs/lisp/recentf.el:1.35
*** emacs/lisp/recentf.el:1.34  Sat Mar 19 14:09:29 2005
--- emacs/lisp/recentf.el       Wed Mar 23 07:20:48 2005
***************
*** 1,6 ****
  ;;; recentf.el --- setup a menu of recently opened files
  
! ;; Copyright (C) 1999, 2000, 2001, 2002, 2003
  ;;   Free Software Foundation, Inc.
  
  ;; Author: David Ponce <address@hidden>
--- 1,6 ----
  ;;; recentf.el --- setup a menu of recently opened files
  
! ;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2005
  ;;   Free Software Foundation, Inc.
  
  ;; Author: David Ponce <address@hidden>
***************
*** 84,89 ****
--- 84,105 ----
    :group 'recentf
    :type '(repeat (choice regexp function)))
  
+ (defcustom recentf-keep
+   '(file-readable-p)
+   "*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.
+ 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."
+   :group 'recentf
+   :type '(repeat (choice regexp function)))
+ 
  (defun recentf-menu-customization-changed (variable value)
    "Function called when the recentf menu customization has changed.
  Set VARIABLE with VALUE, and force a rebuild of the recentf menu."
***************
*** 114,122 ****
                   (const :tag "Last" nil))
    :set 'recentf-menu-customization-changed)
  
! (defcustom recentf-menu-action 'recentf-find-file
    "*Function to invoke with a filename item of the recentf menu.
! The default is to call `recentf-find-file' to edit the selected file."
    :group 'recentf
    :type 'function
    :set 'recentf-menu-customization-changed)
--- 130,138 ----
                   (const :tag "Last" nil))
    :set 'recentf-menu-customization-changed)
  
! (defcustom recentf-menu-action 'find-file
    "*Function to invoke with a filename item of the recentf menu.
! The default is to call `find-file' to edit the selected file."
    :group 'recentf
    :type 'function
    :set 'recentf-menu-customization-changed)
***************
*** 194,210 ****
                          'recentf-menu-append-commands-flag
                          "22.1")
  
- (defcustom recentf-keep-non-readable-files-flag nil
-   "*non-nil means to keep non readable files in the recent list."
-   :group 'recentf
-   :type 'boolean)
- 
- (defvaralias 'recentf-keep-non-readable-files-p
-   'recentf-keep-non-readable-files-flag)
- (make-obsolete-variable 'recentf-keep-non-readable-files-p
-                         'recentf-keep-non-readable-files-flag
-                         "22.1")
- 
  (defcustom recentf-auto-cleanup 'mode
    "*Define when to automatically cleanup the recent list.
  The following values can be set:
--- 210,215 ----
***************
*** 255,265 ****
  If it returns nil, the filename is left unchanged."
    :group 'recentf
    :type 'function)
- 
- (defcustom recentf-cleanup-remote t
-   "*non-nil means to auto cleanup remote files."
-   :group 'recentf
-   :type  'boolean)
  
  ;;; Utilities
  ;;
--- 260,265 ----
***************
*** 356,411 ****
               (funcall recentf-filename-handler filename))
          filename)))
  
- (defsubst recentf-file-readable-p (filename)
-   "Return t if file FILENAME exists and you can read it.
- Like the function `file-readable-p' but return nil on error."
-   (condition-case nil
-       (file-readable-p filename)
-     (error nil)))
- 
  (defun recentf-include-p (filename)
    "Return non-nil if FILENAME should be included in the recent list.
  That is, if it doesn't match any of the `recentf-exclude' checks."
    (let ((case-fold-search recentf-case-fold-search)
          (checks recentf-exclude)
!         (keepit t)
!         check)
      (while (and checks keepit)
!       (setq check  (car checks)
!             checks (cdr checks)
!             keepit (not (if (stringp check)
!                             ;; A regexp
!                             (string-match check filename)
!                           ;; A predicate
!                           (funcall check filename)))))
      keepit))
  
  (defsubst recentf-add-file (filename)
    "Add or move FILENAME at the beginning of the recent list.
! Does nothing if the name satisfies any of the `recentf-exclude' regexps or
! predicates."
    (setq filename (recentf-expand-file-name filename))
    (when (recentf-include-p filename)
      (recentf-push filename)))
  
! (defsubst recentf-remove-if-non-readable (filename)
!   "Remove FILENAME from the recent list, if file is not readable.
  Return non-nil if FILENAME has been removed."
!   (unless (recentf-file-readable-p filename)
      (let ((m (recentf-string-member
                (recentf-expand-file-name filename) recentf-list)))
        (and m (setq recentf-list (delq (car m) recentf-list))))))
  
- (defun recentf-find-file (filename)
-   "Edit file FILENAME using `find-file'.
- If the file does not exist or is non readable, and
- `recentf-keep-non-readable-files-flag' is nil, it is not edited and
- its name is removed from the recent list."
-   (if (and (not recentf-keep-non-readable-files-flag)
-            (recentf-remove-if-non-readable filename))
-       (message "File `%s' not found" filename)
-     (find-file filename)))
- 
  (defsubst recentf-directory-compare (f1 f2)
    "Compare absolute filenames F1 and F2.
  First compare directories, then filenames sans directory.
--- 356,411 ----
               (funcall recentf-filename-handler filename))
          filename)))
  
  (defun recentf-include-p (filename)
    "Return non-nil if FILENAME should be included in the recent list.
  That is, if it doesn't match any of the `recentf-exclude' checks."
    (let ((case-fold-search recentf-case-fold-search)
          (checks recentf-exclude)
!         (keepit t))
      (while (and checks keepit)
!       (setq keepit (condition-case nil
!                        (not (if (stringp (car checks))
!                                 ;; A regexp
!                                 (string-match (car checks) filename)
!                               ;; A predicate
!                               (funcall (car checks) filename)))
!                      (error nil))
!             checks (cdr checks)))
!     keepit))
! 
! (defun recentf-keep-p (filename)
!   "Return non-nil if FILENAME should be kept in the recent list.
! That is, if it matches any of the `recentf-keep' checks."
!   (let* ((case-fold-search recentf-case-fold-search)
!          (checks recentf-keep)
!          (keepit (null checks)))
!     (while (and checks (not keepit))
!       (setq keepit (condition-case nil
!                        (if (stringp (car checks))
!                            ;; A regexp
!                            (string-match (car checks) filename)
!                          ;; A predicate
!                          (funcall (car checks) filename))
!                      (error nil))
!             checks (cdr checks)))
      keepit))
  
  (defsubst recentf-add-file (filename)
    "Add or move FILENAME at the beginning of the recent list.
! Does nothing if the name satisfies any of the `recentf-exclude'
! regexps or predicates."
    (setq filename (recentf-expand-file-name filename))
    (when (recentf-include-p filename)
      (recentf-push filename)))
  
! (defsubst recentf-remove-if-non-kept (filename)
!   "Remove FILENAME from the recent list, if file is not kept.
  Return non-nil if FILENAME has been removed."
!   (unless (recentf-keep-p filename)
      (let ((m (recentf-string-member
                (recentf-expand-file-name filename) recentf-list)))
        (and m (setq recentf-list (delq (car m) recentf-list))))))
  
  (defsubst recentf-directory-compare (f1 f2)
    "Compare absolute filenames F1 and F2.
  First compare directories, then filenames sans directory.
***************
*** 422,428 ****
  (defvar recentf-menu-items-for-commands
    (list ["Cleanup list"
           recentf-cleanup
!          :help "Remove all non-readable and excluded files from the recent 
list"
           :active t]
          ["Edit list..."
           recentf-edit-list
--- 422,428 ----
  (defvar recentf-menu-items-for-commands
    (list ["Cleanup list"
           recentf-cleanup
!          :help "Remove all excluded and non-kept files from the recent list"
           :active t]
          ["Edit list..."
           recentf-edit-list
***************
*** 938,948 ****
  
  (defun recentf-track-closed-file ()
    "Update the recent list when a buffer is killed.
! That is, remove a non readable file from the recent list, if
! `recentf-keep-non-readable-files-flag' is nil."
    (and buffer-file-name
!        (not recentf-keep-non-readable-files-flag)
!        (recentf-remove-if-non-readable buffer-file-name)))
  
  (defun recentf-update-menu ()
    "Update the recentf menu from the current recent list."
--- 938,946 ----
  
  (defun recentf-track-closed-file ()
    "Update the recent list when a buffer is killed.
! That is, remove a non kept file from the recent list."
    (and buffer-file-name
!        (recentf-remove-if-non-kept buffer-file-name)))
  
  (defun recentf-update-menu ()
    "Update the recentf menu from the current recent list."
***************
*** 1169,1187 ****
                                             recentf-list))))))
  
  (defun recentf-cleanup ()
!   "Remove all excluded or non-readable files from the recent list."
    (interactive)
    (message "Cleaning up the recentf list...")
!   (let (newlist)
      (dolist (f recentf-list)
        (if (and (recentf-include-p f)
!              (or (and (file-remote-p f)
!                       (not recentf-cleanup-remote))
!                  (recentf-file-readable-p f)))
            (push f newlist)
          (message "File %s removed from the recentf list" f)))
!     (setq recentf-list (nreverse newlist))
!     (message "Cleaning up the recentf list...done")))
  
  ;;;###autoload
  (define-minor-mode recentf-mode
--- 1167,1184 ----
                                             recentf-list))))))
  
  (defun recentf-cleanup ()
!   "Remove all non-kept and excluded files from the recent list."
    (interactive)
    (message "Cleaning up the recentf list...")
!   (let ((n 0) newlist)
      (dolist (f recentf-list)
        (if (and (recentf-include-p f)
!                (recentf-keep-p f))
            (push f newlist)
+         (setq n (1+ n))
          (message "File %s removed from the recentf list" f)))
!     (message "Cleaning up the recentf list...done (%d removed)" n)
!     (setq recentf-list (nreverse newlist))))
  
  ;;;###autoload
  (define-minor-mode recentf-mode




reply via email to

[Prev in Thread] Current Thread [Next in Thread]