]> code.delx.au - gnu-emacs/blobdiff - lisp/recentf.el
* cl-generic.el (cl-defmethod): Make docstring dynamic
[gnu-emacs] / lisp / recentf.el
index 6babb8c0d85e1a47d943e24e682b94ca5edf081c..dc9489752fb56f6cf96e3db081548a1f7f95064f 100644 (file)
@@ -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, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2016 Free Software Foundation, Inc.
 
 ;; Author: David Ponce <david@dponce.com>
 ;; Created: July 19 1999
@@ -70,9 +69,10 @@ See the command `recentf-save-list'."
   :group 'recentf
   :type 'integer)
 
-(defcustom recentf-save-file (convert-standard-filename "~/.recentf")
+(defcustom recentf-save-file (locate-user-emacs-file "recentf" ".recentf")
   "File to save the recent list into."
   :group 'recentf
+  :version "24.4"
   :type 'file
   :initialize 'custom-initialize-default
   :set (lambda (symbol value)
@@ -294,7 +294,7 @@ They are successively passed a file name to transform it."
             (function :tag "Other function")))))
 
 (defcustom recentf-show-file-shortcuts-flag t
-  "Whether to show ``[N]'' for the Nth item up to 10.
+  "Whether to show \"[N]\" for the Nth item up to 10.
 If non-nil, `recentf-open-files' will show labels for keys that can be
 used as shortcuts to open the Nth file."
   :group 'recentf
@@ -412,13 +412,14 @@ That is, if it doesn't match any of the `recentf-exclude' checks."
         (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))
+      ;; If there was an error in a predicate, err on the side of
+      ;; keeping the file.  (Bug#5843)
+      (setq keepit (not (ignore-errors
+                          (if (stringp (car checks))
+                              ;; A regexp
+                              (string-match (car checks) filename)
+                            ;; A predicate
+                            (funcall (car checks) filename))))
             checks (cdr checks)))
     keepit))
 
@@ -567,7 +568,7 @@ menu-elements (no sub-menu)."
   (if (and l (functionp filter))
       (let ((case-fold-search recentf-case-fold-search)
             elts others)
-        ;; split L into two sub-listes, one of sub-menus elements and
+        ;; split L into two sub-lists, one of sub-menus elements and
         ;; another of single menu elements.
         (dolist (elt l)
           (if (recentf-sub-menu-element-p elt)
@@ -590,7 +591,7 @@ menu-elements (no sub-menu)."
 ;; Count the number of assigned menu shortcuts.
 (defvar recentf-menu-shortcuts)
 
-(defun recentf-make-menu-items (&optional menu)
+(defun recentf-make-menu-items (&optional _menu)
   "Make menu items from the recent list.
 This is a menu filter function which ignores the MENU argument."
   (setq recentf-menu-filter-commands nil)
@@ -780,7 +781,7 @@ Filenames are relative to the `default-directory'."
     )
   "List of rules used by `recentf-arrange-by-rule' to build sub-menus.
 A rule is a pair (SUB-MENU-TITLE . MATCHER).  SUB-MENU-TITLE is the
-displayed title of the sub-menu where a '%d' `format' pattern is
+displayed title of the sub-menu where a `%d' `format' pattern is
 replaced by the number of items in the sub-menu.  MATCHER is a regexp
 or a list of regexps.  Items matching one of the regular expressions in
 MATCHER are added to the corresponding sub-menu.
@@ -797,7 +798,7 @@ may have been modified to match another rule."
   "Title of the `recentf-arrange-by-rule' sub-menu.
 This is for the menu where items that don't match any
 `recentf-arrange-rules' are displayed.  If nil these items are
-displayed in the main recent files menu.  A '%d' `format' pattern in
+displayed in the main recent files menu.  A `%d' `format' pattern in
 the title is replaced by the number of items in the sub-menu."
   :group 'recentf-filters
   :type '(choice (const  :tag "Main menu" nil)
@@ -1036,7 +1037,7 @@ That is, remove a non kept file from the recent list."
 
 ;;; Common dialog stuff
 ;;
-(defun recentf-cancel-dialog (&rest ignore)
+(defun recentf-cancel-dialog (&rest _ignore)
   "Cancel the current dialog.
 IGNORE arguments."
   (interactive)
@@ -1061,7 +1062,8 @@ Go to the beginning of buffer if not found."
   (let ((km (copy-keymap recentf--shortcuts-keymap)))
     (set-keymap-parent km widget-keymap)
     (define-key km "q" 'recentf-cancel-dialog)
-    (define-key km [follow-link] "\C-m")
+    (define-key km "n" 'next-line)
+    (define-key km "p" 'previous-line)
     km)
   "Keymap used in recentf dialogs.")
 
@@ -1092,7 +1094,7 @@ Go to the beginning of buffer if not found."
 ;;
 (defvar recentf-edit-list nil)
 
-(defun recentf-edit-list-select (widget &rest ignore)
+(defun recentf-edit-list-select (widget &rest _ignore)
   "Toggle a file selection based on the checkbox WIDGET state.
 IGNORE other arguments."
   (let ((value (widget-get widget :tag))
@@ -1102,7 +1104,7 @@ IGNORE other arguments."
       (setq recentf-edit-list (delq value recentf-edit-list)))
     (message "%s %sselected" value (if check "" "un"))))
 
-(defun recentf-edit-list-validate (&rest ignore)
+(defun recentf-edit-list-validate (&rest _ignore)
   "Process the recent list when the edit list dialog is committed.
 IGNORE arguments."
   (if recentf-edit-list
@@ -1146,7 +1148,7 @@ Click on Cancel or type `q' to cancel.\n")
 \f
 ;;; Open file dialog
 ;;
-(defun recentf-open-files-action (widget &rest ignore)
+(defun recentf-open-files-action (widget &rest _ignore)
   "Open the file stored in WIDGET's value when notified.
 IGNORE other arguments."
   (kill-buffer (current-buffer))
@@ -1184,6 +1186,9 @@ IGNORE other arguments."
            :format "%[%t\n%]"
            :help-echo ,(concat "Open " (cdr menu-element))
            :action recentf-open-files-action
+           ;; Override the (problematic) follow-link property of the
+           ;; `link' widget (bug#22434).
+           :follow-link nil
            ,(cdr menu-element))))
 
 (defun recentf-open-files-items (files)
@@ -1221,7 +1226,7 @@ use for the dialog.  It defaults to \"*`recentf-menu-title'*\"."
                        ", or type the corresponding digit key,"
                      "")
                    " to open it.\n"
-                   "Click on Cancel or type `q' to cancel.\n")
+                   (format-message "Click on Cancel or type `q' to cancel.\n"))
     ;; Use a L&F that looks like the recentf menu.
     (tree-widget-set-theme "folder")
     (apply 'widget-create
@@ -1278,7 +1283,8 @@ Write data into the file specified by `recentf-save-file'."
       (with-temp-buffer
         (erase-buffer)
         (set-buffer-file-coding-system recentf-save-file-coding-system)
-        (insert (format recentf-save-file-header (current-time-string)))
+        (insert (format-message recentf-save-file-header
+                               (current-time-string)))
         (recentf-dump-variable 'recentf-list recentf-max-saved-items)
         (recentf-dump-variable 'recentf-filter-changer-current)
         (insert "\n\f\n;; Local Variables:\n"
@@ -1336,12 +1342,14 @@ That is, remove duplicates, non-kept, and excluded files."
 
 ;;;###autoload
 (define-minor-mode recentf-mode
-  "Toggle recentf mode.
-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."
+  "Toggle \"Open Recent\" menu (Recentf mode).
+With a prefix argument ARG, enable Recentf mode if ARG is
+positive, and disable it otherwise.  If called from Lisp, enable
+Recentf mode if ARG is omitted or nil.
+
+When Recentf mode is enabled, a \"Open Recent\" submenu is
+displayed in the \"File\" menu, containing a list of files that
+were operated on recently."
   :global t
   :group 'recentf
   :keymap recentf-mode-map
@@ -1355,11 +1363,7 @@ 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 (called-interactively-p 'interactive)
-      (message "Recentf mode %sabled" (if recentf-mode "en" "dis"))))
-  recentf-mode)
+        (apply hook-setup hook)))))
 
 (defun recentf-unload-function ()
   "Unload the recentf library."
@@ -1371,5 +1375,4 @@ that were operated on recently."
 
 (run-hooks 'recentf-load-hook)
 \f
-;; arch-tag: 78f1eec9-0d16-4d19-a4eb-2e4529edb62a
 ;;; recentf.el ends here