(calcFunc-esimplify, calcFunc-simplify, calcFunc-subst): Use
[bpt/emacs.git] / lisp / recentf.el
index a107454..dc79e6c 100644 (file)
@@ -1,6 +1,6 @@
-;; recentf.el --- setup a menu of recently opened files
+;;; recentf.el --- setup a menu of recently opened files
 
-;; Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+;; Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
 
 ;; Author: David Ponce <david@dponce.com>
 ;; Created: July 19 1999
@@ -137,26 +137,41 @@ list of recently opened files."
   "*Function used to filter files displayed in the recentf menu.
 Nil means no filter.  The following functions are predefined:
 
-- `recentf-sort-ascending' to sort menu items in ascending order.
-- `recentf-sort-descending' to sort menu items in descending order.
-- `recentf-sort-basenames-ascending' to sort file names in descending order.
-- `recentf-sort-basenames-descending' to sort file names in descending order.
-- `recentf-sort-directories-ascending' to sort directories in ascending order.
-- `recentf-sort-directories-descending' to sort directories in descending order.
-- `recentf-show-basenames' to show file names (no directories) in menu items.
-- `recentf-show-basenames-ascending' to show file names in ascending order.
-- `recentf-show-basenames-descending' to show file names in descending order.
-- `recentf-relative-filter' to show file names relative to `default-directory'.
-- `recentf-arrange-by-rule' to show sub-menus following user defined rules.
-- `recentf-arrange-by-mode' to show a sub-menu for each major mode.
-- `recentf-arrange-by-dir' to show a sub-menu for each directory.
-- `recentf-filter-changer' to manage a ring of filters.
+- `recentf-sort-ascending' to sort menu items in ascending order.
+- `recentf-sort-descending' to sort menu items in descending order.
+- `recentf-sort-basenames-ascending' to sort file names in descending order.
+- `recentf-sort-basenames-descending' to sort file names in descending order.
+- `recentf-sort-directories-ascending' to sort directories in ascending order.
+- `recentf-sort-directories-descending' to sort directories in descending order.
+- `recentf-show-basenames' to show file names (no directories) in menu items.
+- `recentf-show-basenames-ascending' to show file names in ascending order.
+- `recentf-show-basenames-descending' to show file names in descending order.
+- `recentf-relative-filter' to show file names relative to `default-directory'.
+- `recentf-arrange-by-rule' to show sub-menus following user defined rules.
+- `recentf-arrange-by-mode' to show a sub-menu for each major mode.
+- `recentf-arrange-by-dir' to show a sub-menu for each directory.
+- `recentf-filter-changer' to manage a ring of filters.
 
 The filter function is called with one argument, the list of menu elements
 used to build the menu and must return a new list of menu elements (see
 `recentf-make-menu-element' for menu element form)."
   :group 'recentf
-  :type 'function
+  :type '(radio (const nil) 
+               (function-item recentf-sort-ascending)
+               (function-item recentf-sort-descending)
+               (function-item recentf-sort-basenames-ascending)
+               (function-item recentf-sort-basenames-descending)
+               (function-item recentf-sort-directories-ascending)
+               (function-item recentf-sort-directories-descending)
+               (function-item recentf-show-basenames)
+               (function-item recentf-show-basenames-ascending)
+               (function-item recentf-show-basenames-descending)
+               (function-item recentf-relative-filter)
+               (function-item recentf-arrange-by-rule)
+               (function-item recentf-arrange-by-mode)
+               (function-item recentf-arrange-by-dir)
+               (function-item recentf-filter-changer)
+               function)
   :set 'recentf-menu-customization-changed)
 
 (defcustom recentf-menu-append-commands-p t
@@ -321,10 +336,23 @@ menu-elements (no sub-menu)."
     l))
 
 (defvar recentf-menu-items-for-commands
-  (list ["Cleanup list" recentf-cleanup t]
-        ["Edit list..." recentf-edit-list t]
-        ["Save list now" recentf-save-list t]
-        (vector "Recentf Options..." '(customize-group "recentf") t))
+  (list ["Cleanup list"
+         recentf-cleanup
+         :help "Remove all non-readable and excluded files from the recent list"
+         :active t]
+        ["Edit list..."
+         recentf-edit-list
+         :help "Edit the files that are kept in the recent list"
+         :active t]
+        ["Save list now"
+         recentf-save-list
+         :help "Save the list of recently opened files now"
+         :active t]
+        ["Options..."
+         (customize-group "recentf")
+         :help "Customize recently opened files menu and options"
+         :active t]
+        )
   "List of menu items for recentf commands.")
 
 (defvar recentf-menu-filter-commands nil
@@ -342,9 +370,13 @@ filter function this variable is reset to nil.")
                  (recentf-apply-menu-filter
                   recentf-menu-filter
                   (recentf-menu-elements recentf-max-menu-items)))))
-    (append (or file-items (list ["No files" t nil]))
+    (append (or file-items (list ["No files" t
+                                  :help "No recent file to open"
+                                  :active nil]))
             (and (< recentf-max-menu-items (length recentf-list))
-                 (list ["More..." recentf-open-more-files t]))
+                 (list ["More..." recentf-open-more-files
+                        :help "Open files that are not in the menu"
+                        :active t]))
             (and recentf-menu-filter-commands
                  (cons "---"
                        recentf-menu-filter-commands))
@@ -360,7 +392,8 @@ filter function this variable is reset to nil.")
         (cons menu-item (mapcar 'recentf-make-menu-item menu-value))
       (vector menu-item
               (list recentf-menu-action menu-value)
-              t))))
+              :help (concat "Open " menu-value)
+              :active t))))
 
 ;;;;
 ;;;; Predefined menu filter functions
@@ -532,7 +565,7 @@ defined."
 Nil means no filter.  See also `recentf-menu-filter'.  You can't use
 `recentf-arrange-by-rule' itself here!"
   :group 'recentf-filters
-  :type 'function
+  :type '(choice (const nil) function)
   :set (lambda (sym val)
          (if (eq val 'recentf-arrange-by-rule)
              (error "Can't use `recentf-arrange-by-rule' itself here!")
@@ -653,13 +686,13 @@ Arrange them in sub-menus following rules in `recentf-arrange-rules'."
 (defun recentf-build-dir-rules (l)
   "Convert directories in menu-elements L to rules in `recentf-arrange-rules' format."
   (let (dirs)
-    (mapcar (function
-             (lambda (e)
-               (let ((dir (file-name-directory
-                           (recentf-menu-element-value e))))
-                 (or (member dir dirs)
-                     (setq dirs (cons dir dirs))))))
-            l)
+    (mapc (function
+           (lambda (e)
+             (let ((dir (file-name-directory
+                         (recentf-menu-element-value e))))
+               (or (member dir dirs)
+                   (setq dirs (cons dir dirs))))))
+          l)
     (mapcar (function
              (lambda (d)
                (cons (concat d " (%d)")
@@ -748,7 +781,7 @@ unchanged."
           (setq recentf-menu-filter-commands
                 (list (vector (cdr next-filter-item)
                               '(recentf-filter-changer-goto-next)
-                              t)))))
+                              :active t)))))
     l))
 
 ;;;;
@@ -813,18 +846,14 @@ These are the special commands of `recentf-dialog-mode' mode:
 Optional argument LIMIT specifies a maximum length when VARIABLE value
 is a list (default to the full list)."
   (let ((value (symbol-value variable)))
-    (insert (format "(setq %S\n      '(\n" variable))
-    (cond ((consp value)
-           (if (and (integerp limit) (> limit 0))
-               (setq value (recentf-trunc-list value limit)))
-           (mapcar (function
-                    (lambda (e)
-                      (insert (format "        %S\n" e))))
-                   value))
-          (t
-           (insert (format "        %S\n" value))))
-    (insert "        ))\n")
-    ))
+    (if (listp value)
+       (progn
+         (when (and (integerp limit) (> limit 0))
+           (setq value (recentf-trunc-list value limit)))
+         (insert (format "(setq %S '(" variable))
+         (mapc (lambda (e) (insert (format "\n%S" e))) value)
+         (insert "))\n"))
+      (insert (format "(setq %S %S)\n" variable value)))))
 
 ;;;###autoload
 (defun recentf-save-list ()
@@ -871,33 +900,33 @@ Holds list of files to be deleted from `recentf-list'.")
       (erase-buffer))
     (let ((all (overlay-lists)))
       ;; Delete all the overlays.
-      (mapcar 'delete-overlay (car all))
-      (mapcar 'delete-overlay (cdr all)))
+      (mapc 'delete-overlay (car all))
+      (mapc 'delete-overlay (cdr all)))
     (setq recentf-edit-selected-items nil)
     ;; Insert the dialog header
     (widget-insert "Select the files to be deleted from the 'recentf-list'.\n\n")
     (widget-insert "Click on Ok to update the list. ")
     (widget-insert "Click on Cancel or type \"q\" to quit.\n")
     ;; Insert the list of files as checkboxes
-    (mapcar (function
-             (lambda (item)
-               (widget-create 'checkbox
-                              :value nil ; unselected checkbox
-                              :format "\n %[%v%]  %t"
-                              :tag item
-                              :notify 'recentf-edit-list-action)))
-            recentf-list)
+    (mapc (function
+           (lambda (item)
+             (widget-create 'checkbox
+                            :value nil  ; unselected checkbox
+                            :format "\n %[%v%]  %t"
+                            :tag item
+                            :notify 'recentf-edit-list-action)))
+          recentf-list)
     (widget-insert "\n\n")
     ;; Insert the Ok button
     (widget-create 'push-button
                    :notify (lambda (&rest ignore)
                              (if recentf-edit-selected-items
                                  (progn (kill-buffer (current-buffer))
-                                        (mapcar (function
-                                                 (lambda (item)
-                                                   (setq recentf-list
-                                                         (delq item recentf-list))))
-                                                recentf-edit-selected-items)
+                                        (mapc (function
+                                               (lambda (item)
+                                                 (setq recentf-list
+                                                       (delq item recentf-list))))
+                                              recentf-edit-selected-items)
                                         (message "%S file(s) removed from the list"
                                                  (length recentf-edit-selected-items))
                                         (setq recentf-update-menu-p t))
@@ -951,8 +980,8 @@ Holds list of files to be deleted from `recentf-list'.")
                          :tag menu-item
                          :sample-face 'bold
                          :format (concat shift "%{%t%}:\n"))
-          (mapcar 'recentf-open-files-item
-                  file-path)
+          (mapc 'recentf-open-files-item
+                file-path)
           (widget-insert "\n"))
       (widget-create 'push-button
                      :button-face 'default
@@ -981,17 +1010,17 @@ which buffer to use for the interaction."
       (erase-buffer))
     (let ((all (overlay-lists)))
       ;; Delete all the overlays.
-      (mapcar 'delete-overlay (car all))
-      (mapcar 'delete-overlay (cdr all)))
+      (mapc 'delete-overlay (car all))
+      (mapc 'delete-overlay (cdr all)))
     ;; Insert the dialog header
     (widget-insert "Click on a file to open it. ")
     (widget-insert "Click on Cancel or type \"q\" to quit.\n\n" )
     ;; Insert the list of files as buttons
     (let ((recentf-open-files-item-shift ""))
-      (mapcar 'recentf-open-files-item
-              (recentf-apply-menu-filter
-               recentf-menu-filter
-               (mapcar 'recentf-make-default-menu-element files))))
+      (mapc 'recentf-open-files-item
+            (recentf-apply-menu-filter
+             recentf-menu-filter
+             (mapcar 'recentf-make-default-menu-element files))))
     (widget-insert "\n")
     ;; Insert the Cancel button
     (widget-create 'push-button
@@ -1021,7 +1050,6 @@ 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."
-  nil nil nil
   :global t
   :group 'recentf
   (if recentf-mode