annotate lisp/recentf.el @ 42577:5b7e0e31b555

Regenerated to reflect latest changes in Keywords: headers.
author Pavel Janík <Pavel@Janik.cz>
date Sun, 06 Jan 2002 17:53:26 +0000
parents 7308bbc423d5
children ea21866100eb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
38436
b174db545cfd Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 35971
diff changeset
1 ;;; recentf.el --- setup a menu of recently opened files
30416
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
2
38662
dd6bc9395c61 (recentf-dump-variable): Handle a value of nil
Gerd Moellmann <gerd@gnu.org>
parents: 38436
diff changeset
3 ;; Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
30416
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
4
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
5 ;; Author: David Ponce <david@dponce.com>
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
6 ;; Created: July 19 1999
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
7 ;; Keywords: customization
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
8
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
9 ;; This file is part of GNU Emacs.
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
10
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
12 ;; it under the terms of the GNU General Public License as published by
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
13 ;; the Free Software Foundation; either version 2, or (at your option)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
14 ;; any later version.
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
15
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
16 ;; GNU Emacs is distributed in the hope that it will be useful,
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
19 ;; GNU General Public License for more details.
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
20
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
21 ;; You should have received a copy of the GNU General Public License
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
24 ;; Boston, MA 02111-1307, USA.
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
25
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
26 ;;; Commentary:
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
27
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
28 ;; This package maintains a menu for visiting files that were operated
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
29 ;; on recently. When enabled a new "Open Recent" submenu is displayed
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
30 ;; in the "Files" menu. The recent files list is automatically saved
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
31 ;; across Emacs sessions. You can customize the number of recent
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
32 ;; files displayed, the location of the menu and others options (see
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
33 ;; the source code for details). To install and use, put the file on
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
34 ;; your Emacs-Lisp load path and add the following into your ~/.emacs
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
35 ;; startup file:
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
36 ;;
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
37 ;; (require 'recentf)
32292
11bee5bae414 Doc fixes.
Dave Love <fx@gnu.org>
parents: 30778
diff changeset
38 ;; (recentf-mode 1)
30416
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
39
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
40 ;;; Code:
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
41
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
42 (require 'easymenu)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
43 (require 'wid-edit)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
44
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
45 (defconst recentf-save-file-header
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
46 ";;; Automatically generated by `recentf' on %s.\n"
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
47 "Header to be written into the `recentf-save-file'.")
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
48
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
49 (defvar recentf-list nil
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
50 "List of recently opened files.")
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
51
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
52 (defvar recentf-update-menu-p t
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
53 "Non-nil if the recentf menu must be updated.")
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
54
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
55 (defvar recentf-initialized-p nil
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
56 "Non-nil if recentf already initialized.")
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
57
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
58 ;; IMPORTANT: This function must be defined before the following defcustoms
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
59 ;; because it is used in their :set clause. To avoid byte-compiler warnings
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
60 ;; the `symbol-value' function is used to access the `recentf-menu-path'
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
61 ;; and `recentf-menu-title' values.
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
62 (defun recentf-menu-customization-changed (sym val)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
63 "Function called when menu customization has changed.
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
64 It removes the recentf menu and forces its complete redrawing."
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
65 (when recentf-initialized-p
32292
11bee5bae414 Doc fixes.
Dave Love <fx@gnu.org>
parents: 30778
diff changeset
66 (easy-menu-remove-item nil
30416
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
67 (symbol-value 'recentf-menu-path)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
68 (symbol-value 'recentf-menu-title))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
69 (setq recentf-update-menu-p t))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
70 (custom-set-default sym val))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
71
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
72 (defgroup recentf nil
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
73 "Maintain a menu of recently opened files."
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
74 :version "21.1"
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
75 :group 'files)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
76
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
77 (defgroup recentf-filters nil
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
78 "Group to customize recentf menu filters.
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
79 You should define the options of your own filters in this group."
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
80 :group 'recentf)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
81
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
82 (defcustom recentf-max-saved-items 20
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
83 "*Maximum number of items saved to `recentf-save-file'."
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
84 :group 'recentf
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
85 :type 'integer)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
86
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
87 (defcustom recentf-save-file (expand-file-name "~/.recentf")
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
88 "*File to save `recentf-list' into."
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
89 :group 'recentf
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
90 :type 'file)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
91
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
92 (defcustom recentf-exclude nil
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
93 "*List of regexps for filenames excluded from `recentf-list'."
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
94 :group 'recentf
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
95 :type '(repeat regexp))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
96
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
97 (defcustom recentf-menu-title "Open Recent"
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
98 "*Name of the recentf menu."
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
99 :group 'recentf
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
100 :type 'string
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
101 :set 'recentf-menu-customization-changed)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
102
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
103 (defcustom recentf-menu-path '("files")
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
104 "*Path where to add the recentf menu.
32429
0e626f0c2b8a Maintainer's checkdoc fixes.
Dave Love <fx@gnu.org>
parents: 32292
diff changeset
105 If nil add it at top level (see also `easy-menu-change')."
30416
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
106 :group 'recentf
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
107 :type '(choice (const :tag "Top Level" nil)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
108 (sexp :tag "Menu Path"))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
109 :set 'recentf-menu-customization-changed)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
110
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
111 (defcustom recentf-menu-before "open-file"
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
112 "*Name of the menu before which the recentf menu will be added.
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
113 If nil add it at end of menu (see also `easy-menu-change')."
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
114 :group 'recentf
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
115 :type '(choice (string :tag "Name")
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
116 (const :tag "Last" nil))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
117 :set 'recentf-menu-customization-changed)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
118
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
119 (defcustom recentf-menu-action 'recentf-find-file
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
120 "*Function to invoke with a filename item of the recentf menu.
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
121 The default action `recentf-find-file' calls `find-file' to edit an
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
122 existing file. If the file does not exist or is not readable, it is
32292
11bee5bae414 Doc fixes.
Dave Love <fx@gnu.org>
parents: 30778
diff changeset
123 not edited and its name is removed from `recentf-list'. You can use
30416
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
124 `find-file' instead to open non-existing files and keep them in the
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
125 list of recently opened files."
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
126 :group 'recentf
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
127 :type 'function
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
128 :set 'recentf-menu-customization-changed)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
129
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
130 (defcustom recentf-max-menu-items 10
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
131 "*Maximum number of items in the recentf menu."
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
132 :group 'recentf
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
133 :type 'integer
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
134 :set 'recentf-menu-customization-changed)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
135
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
136 (defcustom recentf-menu-filter nil
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
137 "*Function used to filter files displayed in the recentf menu.
42205
7308bbc423d5 Doc fixes.
Pavel Janík <Pavel@Janik.cz>
parents: 38662
diff changeset
138 nil means no filter. The following functions are predefined:
30416
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
139
35971
6dd6fce1542a (recentf-menu-filter): Fix :type.
Dave Love <fx@gnu.org>
parents: 33770
diff changeset
140 - `recentf-sort-ascending' to sort menu items in ascending order.
6dd6fce1542a (recentf-menu-filter): Fix :type.
Dave Love <fx@gnu.org>
parents: 33770
diff changeset
141 - `recentf-sort-descending' to sort menu items in descending order.
6dd6fce1542a (recentf-menu-filter): Fix :type.
Dave Love <fx@gnu.org>
parents: 33770
diff changeset
142 - `recentf-sort-basenames-ascending' to sort file names in descending order.
6dd6fce1542a (recentf-menu-filter): Fix :type.
Dave Love <fx@gnu.org>
parents: 33770
diff changeset
143 - `recentf-sort-basenames-descending' to sort file names in descending order.
6dd6fce1542a (recentf-menu-filter): Fix :type.
Dave Love <fx@gnu.org>
parents: 33770
diff changeset
144 - `recentf-sort-directories-ascending' to sort directories in ascending order.
6dd6fce1542a (recentf-menu-filter): Fix :type.
Dave Love <fx@gnu.org>
parents: 33770
diff changeset
145 - `recentf-sort-directories-descending' to sort directories in descending order.
6dd6fce1542a (recentf-menu-filter): Fix :type.
Dave Love <fx@gnu.org>
parents: 33770
diff changeset
146 - `recentf-show-basenames' to show file names (no directories) in menu items.
6dd6fce1542a (recentf-menu-filter): Fix :type.
Dave Love <fx@gnu.org>
parents: 33770
diff changeset
147 - `recentf-show-basenames-ascending' to show file names in ascending order.
6dd6fce1542a (recentf-menu-filter): Fix :type.
Dave Love <fx@gnu.org>
parents: 33770
diff changeset
148 - `recentf-show-basenames-descending' to show file names in descending order.
6dd6fce1542a (recentf-menu-filter): Fix :type.
Dave Love <fx@gnu.org>
parents: 33770
diff changeset
149 - `recentf-relative-filter' to show file names relative to `default-directory'.
6dd6fce1542a (recentf-menu-filter): Fix :type.
Dave Love <fx@gnu.org>
parents: 33770
diff changeset
150 - `recentf-arrange-by-rule' to show sub-menus following user defined rules.
6dd6fce1542a (recentf-menu-filter): Fix :type.
Dave Love <fx@gnu.org>
parents: 33770
diff changeset
151 - `recentf-arrange-by-mode' to show a sub-menu for each major mode.
6dd6fce1542a (recentf-menu-filter): Fix :type.
Dave Love <fx@gnu.org>
parents: 33770
diff changeset
152 - `recentf-arrange-by-dir' to show a sub-menu for each directory.
6dd6fce1542a (recentf-menu-filter): Fix :type.
Dave Love <fx@gnu.org>
parents: 33770
diff changeset
153 - `recentf-filter-changer' to manage a ring of filters.
30416
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
154
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
155 The filter function is called with one argument, the list of menu elements
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
156 used to build the menu and must return a new list of menu elements (see
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
157 `recentf-make-menu-element' for menu element form)."
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
158 :group 'recentf
35971
6dd6fce1542a (recentf-menu-filter): Fix :type.
Dave Love <fx@gnu.org>
parents: 33770
diff changeset
159 :type '(radio (const nil)
6dd6fce1542a (recentf-menu-filter): Fix :type.
Dave Love <fx@gnu.org>
parents: 33770
diff changeset
160 (function-item recentf-sort-ascending)
6dd6fce1542a (recentf-menu-filter): Fix :type.
Dave Love <fx@gnu.org>
parents: 33770
diff changeset
161 (function-item recentf-sort-descending)
6dd6fce1542a (recentf-menu-filter): Fix :type.
Dave Love <fx@gnu.org>
parents: 33770
diff changeset
162 (function-item recentf-sort-basenames-ascending)
6dd6fce1542a (recentf-menu-filter): Fix :type.
Dave Love <fx@gnu.org>
parents: 33770
diff changeset
163 (function-item recentf-sort-basenames-descending)
6dd6fce1542a (recentf-menu-filter): Fix :type.
Dave Love <fx@gnu.org>
parents: 33770
diff changeset
164 (function-item recentf-sort-directories-ascending)
6dd6fce1542a (recentf-menu-filter): Fix :type.
Dave Love <fx@gnu.org>
parents: 33770
diff changeset
165 (function-item recentf-sort-directories-descending)
6dd6fce1542a (recentf-menu-filter): Fix :type.
Dave Love <fx@gnu.org>
parents: 33770
diff changeset
166 (function-item recentf-show-basenames)
6dd6fce1542a (recentf-menu-filter): Fix :type.
Dave Love <fx@gnu.org>
parents: 33770
diff changeset
167 (function-item recentf-show-basenames-ascending)
6dd6fce1542a (recentf-menu-filter): Fix :type.
Dave Love <fx@gnu.org>
parents: 33770
diff changeset
168 (function-item recentf-show-basenames-descending)
6dd6fce1542a (recentf-menu-filter): Fix :type.
Dave Love <fx@gnu.org>
parents: 33770
diff changeset
169 (function-item recentf-relative-filter)
6dd6fce1542a (recentf-menu-filter): Fix :type.
Dave Love <fx@gnu.org>
parents: 33770
diff changeset
170 (function-item recentf-arrange-by-rule)
6dd6fce1542a (recentf-menu-filter): Fix :type.
Dave Love <fx@gnu.org>
parents: 33770
diff changeset
171 (function-item recentf-arrange-by-mode)
6dd6fce1542a (recentf-menu-filter): Fix :type.
Dave Love <fx@gnu.org>
parents: 33770
diff changeset
172 (function-item recentf-arrange-by-dir)
6dd6fce1542a (recentf-menu-filter): Fix :type.
Dave Love <fx@gnu.org>
parents: 33770
diff changeset
173 (function-item recentf-filter-changer)
6dd6fce1542a (recentf-menu-filter): Fix :type.
Dave Love <fx@gnu.org>
parents: 33770
diff changeset
174 function)
30416
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
175 :set 'recentf-menu-customization-changed)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
176
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
177 (defcustom recentf-menu-append-commands-p t
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
178 "*If not-nil command items are appended to the menu."
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
179 :group 'recentf
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
180 :type 'boolean
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
181 :set 'recentf-menu-customization-changed)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
182
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
183 (defcustom recentf-keep-non-readable-files-p nil
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
184 "*If nil (default), non-readable files are not kept in `recentf-list'."
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
185 :group 'recentf
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
186 :type 'boolean
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
187 :require 'recentf
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
188 :initialize 'custom-initialize-default
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
189 :set (lambda (sym val)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
190 (if val
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
191 (remove-hook 'kill-buffer-hook 'recentf-remove-file-hook)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
192 (add-hook 'kill-buffer-hook 'recentf-remove-file-hook))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
193 (custom-set-default sym val)))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
194
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
195 (defcustom recentf-load-hook nil
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
196 "*Normal hook run at end of loading the `recentf' package."
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
197 :group 'recentf
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
198 :type 'hook)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
199
32429
0e626f0c2b8a Maintainer's checkdoc fixes.
Dave Love <fx@gnu.org>
parents: 32292
diff changeset
200 ;;;;
0e626f0c2b8a Maintainer's checkdoc fixes.
Dave Love <fx@gnu.org>
parents: 32292
diff changeset
201 ;;;; Common functions
0e626f0c2b8a Maintainer's checkdoc fixes.
Dave Love <fx@gnu.org>
parents: 32292
diff changeset
202 ;;;;
30416
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
203 (defconst recentf-case-fold-search
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
204 (memq system-type '(vax-vms windows-nt))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
205 "Non-nil if recentf searches and matches should ignore case.")
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
206
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
207 (defun recentf-include-p (filename)
32429
0e626f0c2b8a Maintainer's checkdoc fixes.
Dave Love <fx@gnu.org>
parents: 32292
diff changeset
208 "Return t if FILENAME match none of the `recentf-exclude' regexps."
30416
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
209 (let ((case-fold-search recentf-case-fold-search)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
210 (rl recentf-exclude))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
211 (while (and rl (not (string-match (car rl) filename)))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
212 (setq rl (cdr rl)))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
213 (null rl)))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
214
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
215 (defun recentf-add-file (filename)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
216 "Add or move FILENAME at the beginning of `recentf-list'.
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
217 Does nothing if FILENAME matches one of the `recentf-exclude' regexps."
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
218 (let ((filename (expand-file-name filename)))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
219 (when (recentf-include-p filename)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
220 (setq recentf-list (cons filename (delete filename recentf-list)))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
221 (setq recentf-update-menu-p t))))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
222
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
223 (defun recentf-remove-if-non-readable (filename)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
224 "Remove FILENAME from `recentf-list' if not readable."
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
225 (unless (file-readable-p filename)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
226 (setq recentf-list (delete filename recentf-list))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
227 (setq recentf-update-menu-p t)))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
228
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
229 (defun recentf-find-file (filename)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
230 "Edit file FILENAME using `find-file'.
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
231 If FILENAME is not readable it is removed from `recentf-list'."
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
232 (if (file-readable-p filename)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
233 (find-file filename)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
234 (progn
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
235 (message "File `%s' not found." filename)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
236 (setq recentf-list (delete filename recentf-list))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
237 (setq recentf-update-menu-p t))))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
238
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
239 (defun recentf-trunc-list (l n)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
240 "Return a list of the first N elements of L."
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
241 (let ((lh nil))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
242 (while (and l (> n 0))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
243 (setq lh (cons (car l) lh))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
244 (setq n (1- n))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
245 (setq l (cdr l)))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
246 (nreverse lh)))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
247
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
248 (defun recentf-elements (n)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
249 "Return a list of the first N elements of `recentf-list'."
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
250 (recentf-trunc-list recentf-list n))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
251
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
252 (defun recentf-make-menu-element (menu-item menu-value)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
253 "Create a new menu-element.
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
254
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
255 A menu element is a pair (MENU-ITEM . MENU-VALUE) where:
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
256
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
257 - - MENU-ITEM is the menu item string displayed.
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
258 - - MENU-VALUE is the path used to open the file when the
32292
11bee5bae414 Doc fixes.
Dave Love <fx@gnu.org>
parents: 30778
diff changeset
259 corresponding MENU-ITEM is selected. Or it is
30416
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
260 a pair (SUB-MENU-TITLE . MENU-ELEMENTS) where
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
261 SUB-MENU-TITLE is a sub-menu title and
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
262 MENU-ELEMENTS is the list of menu elements in
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
263 the sub-menu."
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
264 (cons menu-item menu-value))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
265
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
266 (defun recentf-menu-element-item (e)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
267 "Return the item part of the menu-element E."
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
268 (car e))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
269
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
270 (defun recentf-menu-element-value (e)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
271 "Return the value part of the menu-element E."
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
272 (cdr e))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
273
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
274 (defun recentf-set-menu-element-item (e item)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
275 "Change the item part of menu-element E to ITEM."
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
276 (setcar e item))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
277
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
278 (defun recentf-set-menu-element-value (e value)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
279 "Change the value part of menu-element E to VALUE."
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
280 (setcdr e value))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
281
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
282 (defun recentf-sub-menu-element-p (e)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
283 "Return non-nil if menu-element E defines a sub-menu."
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
284 (consp (recentf-menu-element-value e)))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
285
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
286 (defun recentf-make-default-menu-element (file-path)
32292
11bee5bae414 Doc fixes.
Dave Love <fx@gnu.org>
parents: 30778
diff changeset
287 "Make a new default menu element (MENU-ITEM . MENU-VALUE).
11bee5bae414 Doc fixes.
Dave Love <fx@gnu.org>
parents: 30778
diff changeset
288 Do so for the given recent file path FILE-PATH. MENU-ITEM and
11bee5bae414 Doc fixes.
Dave Love <fx@gnu.org>
parents: 30778
diff changeset
289 MENU-VALUE are set to FILE-PATH. See also
11bee5bae414 Doc fixes.
Dave Love <fx@gnu.org>
parents: 30778
diff changeset
290 `recentf-make-menu-element'."
30416
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
291 (recentf-make-menu-element file-path file-path))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
292
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
293 (defun recentf-menu-elements (n)
32292
11bee5bae414 Doc fixes.
Dave Love <fx@gnu.org>
parents: 30778
diff changeset
294 "Return a list of the first N default menu elements from `recentf-list'.
11bee5bae414 Doc fixes.
Dave Love <fx@gnu.org>
parents: 30778
diff changeset
295 See also `recentf-make-default-menu-element'."
30416
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
296 (mapcar 'recentf-make-default-menu-element
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
297 (recentf-elements n)))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
298
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
299 (defun recentf-apply-menu-filter (filter l)
32292
11bee5bae414 Doc fixes.
Dave Love <fx@gnu.org>
parents: 30778
diff changeset
300 "Apply function FILTER to the list of menu-elements L.
11bee5bae414 Doc fixes.
Dave Love <fx@gnu.org>
parents: 30778
diff changeset
301 It takes care of sub-menu elements in L and recursively apply FILTER
32429
0e626f0c2b8a Maintainer's checkdoc fixes.
Dave Love <fx@gnu.org>
parents: 32292
diff changeset
302 to them. It is guaranteed that FILTER receives only a list of single
32292
11bee5bae414 Doc fixes.
Dave Love <fx@gnu.org>
parents: 30778
diff changeset
303 menu-elements (no sub-menu)."
30416
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
304 (if (and (functionp filter) l)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
305 (let ((case-fold-search recentf-case-fold-search)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
306 menu-element sub-menu-elements single-elements)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
307 ;; split L in two sub-listes:
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
308 ;; one of sub-menus elements and
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
309 ;; one of single menu elements
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
310 (while l
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
311 (setq menu-element (car l))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
312 (if (recentf-sub-menu-element-p menu-element)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
313 (setq sub-menu-elements
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
314 (cons menu-element sub-menu-elements))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
315 (setq single-elements
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
316 (cons menu-element single-elements)))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
317 (setq l (cdr l)))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
318 ;; apply FILTER to the list of single menu elements
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
319 (if single-elements
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
320 (setq single-elements (funcall filter
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
321 (nreverse single-elements))))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
322 ;; apply FILTER to sub-menu menu element list
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
323 (setq l sub-menu-elements)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
324 (setq sub-menu-elements nil)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
325 (while l
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
326 (setq menu-element (car l))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
327 (recentf-set-menu-element-value
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
328 menu-element
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
329 (recentf-apply-menu-filter
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
330 filter
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
331 (recentf-menu-element-value menu-element)))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
332 (setq sub-menu-elements (cons menu-element sub-menu-elements))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
333 (setq l (cdr l)))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
334 ;; build and return the new filtered menu element list
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
335 (nconc sub-menu-elements single-elements))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
336 l))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
337
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
338 (defvar recentf-menu-items-for-commands
33770
4408efb1d628 (recentf-menu-items-for-commands)
Gerd Moellmann <gerd@gnu.org>
parents: 33196
diff changeset
339 (list ["Cleanup list"
4408efb1d628 (recentf-menu-items-for-commands)
Gerd Moellmann <gerd@gnu.org>
parents: 33196
diff changeset
340 recentf-cleanup
4408efb1d628 (recentf-menu-items-for-commands)
Gerd Moellmann <gerd@gnu.org>
parents: 33196
diff changeset
341 :help "Remove all non-readable and excluded files from the recent list"
4408efb1d628 (recentf-menu-items-for-commands)
Gerd Moellmann <gerd@gnu.org>
parents: 33196
diff changeset
342 :active t]
4408efb1d628 (recentf-menu-items-for-commands)
Gerd Moellmann <gerd@gnu.org>
parents: 33196
diff changeset
343 ["Edit list..."
4408efb1d628 (recentf-menu-items-for-commands)
Gerd Moellmann <gerd@gnu.org>
parents: 33196
diff changeset
344 recentf-edit-list
4408efb1d628 (recentf-menu-items-for-commands)
Gerd Moellmann <gerd@gnu.org>
parents: 33196
diff changeset
345 :help "Edit the files that are kept in the recent list"
4408efb1d628 (recentf-menu-items-for-commands)
Gerd Moellmann <gerd@gnu.org>
parents: 33196
diff changeset
346 :active t]
4408efb1d628 (recentf-menu-items-for-commands)
Gerd Moellmann <gerd@gnu.org>
parents: 33196
diff changeset
347 ["Save list now"
4408efb1d628 (recentf-menu-items-for-commands)
Gerd Moellmann <gerd@gnu.org>
parents: 33196
diff changeset
348 recentf-save-list
4408efb1d628 (recentf-menu-items-for-commands)
Gerd Moellmann <gerd@gnu.org>
parents: 33196
diff changeset
349 :help "Save the list of recently opened files now"
4408efb1d628 (recentf-menu-items-for-commands)
Gerd Moellmann <gerd@gnu.org>
parents: 33196
diff changeset
350 :active t]
4408efb1d628 (recentf-menu-items-for-commands)
Gerd Moellmann <gerd@gnu.org>
parents: 33196
diff changeset
351 ["Options..."
4408efb1d628 (recentf-menu-items-for-commands)
Gerd Moellmann <gerd@gnu.org>
parents: 33196
diff changeset
352 (customize-group "recentf")
4408efb1d628 (recentf-menu-items-for-commands)
Gerd Moellmann <gerd@gnu.org>
parents: 33196
diff changeset
353 :help "Customize recently opened files menu and options"
4408efb1d628 (recentf-menu-items-for-commands)
Gerd Moellmann <gerd@gnu.org>
parents: 33196
diff changeset
354 :active t]
4408efb1d628 (recentf-menu-items-for-commands)
Gerd Moellmann <gerd@gnu.org>
parents: 33196
diff changeset
355 )
30416
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
356 "List of menu items for recentf commands.")
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
357
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
358 (defvar recentf-menu-filter-commands nil
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
359 "This variable can be used by menu filters to setup their own command menu.
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
360
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
361 If non-nil it must contain a list of valid menu-items to be appended
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
362 to the recent file list part of the menu. Before calling a menu
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
363 filter function this variable is reset to nil.")
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
364
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
365 (defun recentf-make-menu-items ()
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
366 "Make menu items from `recentf-list'."
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
367 (setq recentf-menu-filter-commands nil)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
368 (let ((file-items
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
369 (mapcar 'recentf-make-menu-item
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
370 (recentf-apply-menu-filter
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
371 recentf-menu-filter
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
372 (recentf-menu-elements recentf-max-menu-items)))))
33770
4408efb1d628 (recentf-menu-items-for-commands)
Gerd Moellmann <gerd@gnu.org>
parents: 33196
diff changeset
373 (append (or file-items (list ["No files" t
4408efb1d628 (recentf-menu-items-for-commands)
Gerd Moellmann <gerd@gnu.org>
parents: 33196
diff changeset
374 :help "No recent file to open"
4408efb1d628 (recentf-menu-items-for-commands)
Gerd Moellmann <gerd@gnu.org>
parents: 33196
diff changeset
375 :active nil]))
30416
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
376 (and (< recentf-max-menu-items (length recentf-list))
33770
4408efb1d628 (recentf-menu-items-for-commands)
Gerd Moellmann <gerd@gnu.org>
parents: 33196
diff changeset
377 (list ["More..." recentf-open-more-files
4408efb1d628 (recentf-menu-items-for-commands)
Gerd Moellmann <gerd@gnu.org>
parents: 33196
diff changeset
378 :help "Open files that are not in the menu"
4408efb1d628 (recentf-menu-items-for-commands)
Gerd Moellmann <gerd@gnu.org>
parents: 33196
diff changeset
379 :active t]))
30416
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
380 (and recentf-menu-filter-commands
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
381 (cons "---"
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
382 recentf-menu-filter-commands))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
383 (and recentf-menu-append-commands-p
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
384 (cons "---"
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
385 recentf-menu-items-for-commands)))))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
386
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
387 (defun recentf-make-menu-item (menu-element)
32429
0e626f0c2b8a Maintainer's checkdoc fixes.
Dave Love <fx@gnu.org>
parents: 32292
diff changeset
388 "Make a menu item from MENU-ELEMENT (see `recentf-make-menu-element')."
30416
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
389 (let ((menu-item (recentf-menu-element-item menu-element))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
390 (menu-value (recentf-menu-element-value menu-element)))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
391 (if (recentf-sub-menu-element-p menu-element)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
392 (cons menu-item (mapcar 'recentf-make-menu-item menu-value))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
393 (vector menu-item
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
394 (list recentf-menu-action menu-value)
33770
4408efb1d628 (recentf-menu-items-for-commands)
Gerd Moellmann <gerd@gnu.org>
parents: 33196
diff changeset
395 :help (concat "Open " menu-value)
4408efb1d628 (recentf-menu-items-for-commands)
Gerd Moellmann <gerd@gnu.org>
parents: 33196
diff changeset
396 :active t))))
30416
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
397
32429
0e626f0c2b8a Maintainer's checkdoc fixes.
Dave Love <fx@gnu.org>
parents: 32292
diff changeset
398 ;;;;
0e626f0c2b8a Maintainer's checkdoc fixes.
Dave Love <fx@gnu.org>
parents: 32292
diff changeset
399 ;;;; Predefined menu filter functions
0e626f0c2b8a Maintainer's checkdoc fixes.
Dave Love <fx@gnu.org>
parents: 32292
diff changeset
400 ;;;;
30416
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
401
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
402 (defun recentf-sort-ascending (l)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
403 "Sort the list of menu elements L in ascending order.
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
404 The MENU-ITEM part of each menu element is compared."
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
405 (sort (copy-sequence l)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
406 (function
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
407 (lambda (e1 e2)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
408 (string-lessp (recentf-menu-element-item e1)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
409 (recentf-menu-element-item e2))))))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
410
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
411 (defun recentf-sort-descending (l)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
412 "Sort the list of menu elements L in descending order.
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
413 The MENU-ITEM part of each menu element is compared."
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
414 (sort (copy-sequence l)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
415 (function
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
416 (lambda (e1 e2)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
417 (string-lessp (recentf-menu-element-item e2)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
418 (recentf-menu-element-item e1))))))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
419
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
420 (defun recentf-sort-basenames-ascending (l)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
421 "Sort the list of menu elements L in ascending order.
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
422 Only file names (without directories) are compared."
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
423 (sort (copy-sequence l)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
424 (function
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
425 (lambda (e1 e2)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
426 (string-lessp
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
427 (file-name-nondirectory (recentf-menu-element-value e1))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
428 (file-name-nondirectory (recentf-menu-element-value e2)))))))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
429
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
430 (defun recentf-sort-basenames-descending (l)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
431 "Sort the list of menu elements L in descending order.
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
432 Only file names (without directories) are compared."
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
433 (sort (copy-sequence l)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
434 (function
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
435 (lambda (e1 e2)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
436 (string-lessp
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
437 (file-name-nondirectory (recentf-menu-element-value e2))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
438 (file-name-nondirectory (recentf-menu-element-value e1)))))))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
439
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
440 (defun recentf-directory-compare (p1 p2)
32292
11bee5bae414 Doc fixes.
Dave Love <fx@gnu.org>
parents: 30778
diff changeset
441 "Compare directories then filenames in paths P1 and P2.
11bee5bae414 Doc fixes.
Dave Love <fx@gnu.org>
parents: 30778
diff changeset
442 Return non-nil if P1 is less than P2."
30416
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
443 (let ((d1 (file-name-directory p1))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
444 (f1 (file-name-nondirectory p1))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
445 (d2 (file-name-directory p2))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
446 (f2 (file-name-nondirectory p2)))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
447 (if (string= d1 d2)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
448 (string-lessp f1 f2)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
449 (string-lessp d1 d2))))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
450
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
451 (defun recentf-sort-directories-ascending (l)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
452 "Sort the list of menu elements L in ascending order.
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
453 Compares directories then filenames to order the list."
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
454 (sort (copy-sequence l)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
455 (function
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
456 (lambda (e1 e2)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
457 (recentf-directory-compare (recentf-menu-element-value e1)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
458 (recentf-menu-element-value e2))))))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
459
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
460 (defun recentf-sort-directories-descending (l)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
461 "Sort the list of menu elements L in descending order.
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
462 Compares directories then filenames to order the list."
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
463 (sort (copy-sequence l)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
464 (function
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
465 (lambda (e1 e2)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
466 (recentf-directory-compare (recentf-menu-element-value e2)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
467 (recentf-menu-element-value e1))))))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
468
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
469 (defun recentf-show-basenames (l)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
470 "Filter the list of menu elements L to show only file names (no directories)
32292
11bee5bae414 Doc fixes.
Dave Love <fx@gnu.org>
parents: 30778
diff changeset
471 in the menu. When file names are duplicated their directory component is added."
30416
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
472 (let ((names (mapcar (function
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
473 (lambda (item)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
474 (file-name-nondirectory
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
475 (recentf-menu-element-value item))))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
476 l))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
477 (dirs (mapcar (function
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
478 (lambda (item)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
479 (file-name-directory
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
480 (recentf-menu-element-value item))))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
481 l))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
482 (pathes (mapcar 'recentf-menu-element-value l))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
483 (pos -1)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
484 item filtered-items filtered-list)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
485 (while names
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
486 (setq item (car names))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
487 (setq names (cdr names))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
488 (setq pos (1+ pos))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
489 (setq filtered-list
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
490 (cons (recentf-make-menu-element
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
491 (if (or (member item names) (member item filtered-items))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
492 (concat item " (" (nth pos dirs) ")")
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
493 item)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
494 (nth pos pathes))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
495 filtered-list))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
496 (setq filtered-items (cons item filtered-items)))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
497 (nreverse filtered-list)))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
498
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
499 (defun recentf-show-basenames-ascending (l)
32292
11bee5bae414 Doc fixes.
Dave Love <fx@gnu.org>
parents: 30778
diff changeset
500 "Filter the list of menu elements L.
11bee5bae414 Doc fixes.
Dave Love <fx@gnu.org>
parents: 30778
diff changeset
501 Show only file names in the menu, sorted in ascending order. This
11bee5bae414 Doc fixes.
Dave Love <fx@gnu.org>
parents: 30778
diff changeset
502 filter combines the `recentf-sort-basenames-ascending' and
11bee5bae414 Doc fixes.
Dave Love <fx@gnu.org>
parents: 30778
diff changeset
503 `recentf-show-basenames' filters."
30416
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
504 (recentf-show-basenames (recentf-sort-basenames-ascending l)))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
505
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
506 (defun recentf-show-basenames-descending (l)
32292
11bee5bae414 Doc fixes.
Dave Love <fx@gnu.org>
parents: 30778
diff changeset
507 "Filter the list of menu elements L.
11bee5bae414 Doc fixes.
Dave Love <fx@gnu.org>
parents: 30778
diff changeset
508 Show only file names in the menu, sorted in descending order. This
11bee5bae414 Doc fixes.
Dave Love <fx@gnu.org>
parents: 30778
diff changeset
509 filter combines the `recentf-sort-basenames-descending' and
11bee5bae414 Doc fixes.
Dave Love <fx@gnu.org>
parents: 30778
diff changeset
510 `recentf-show-basenames' filters."
30416
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
511 (recentf-show-basenames (recentf-sort-basenames-descending l)))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
512
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
513 (defun recentf-relative-filter (l)
32292
11bee5bae414 Doc fixes.
Dave Love <fx@gnu.org>
parents: 30778
diff changeset
514 "Filter the list of `recentf-menu-elements' L.
11bee5bae414 Doc fixes.
Dave Love <fx@gnu.org>
parents: 30778
diff changeset
515 Show filenames relative to `default-directory'."
30416
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
516 (setq recentf-update-menu-p t) ; force menu update
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
517 (mapcar (function
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
518 (lambda (menu-element)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
519 (let* ((ful-path (recentf-menu-element-value menu-element))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
520 (rel-path (file-relative-name ful-path)))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
521 (if (string-match "^\\.\\." rel-path)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
522 menu-element
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
523 (recentf-make-menu-element rel-path ful-path)))))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
524 l))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
525
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
526 (defcustom recentf-arrange-rules
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
527 '(
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
528 ("Elisp files (%d)" ".\\.el$")
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
529 ("Java files (%d)" ".\\.java$")
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
530 ("C/C++ files (%d)" "c\\(pp\\)?$")
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
531 )
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
532 "*List of rules used by `recentf-arrange-by-rule' to build sub-menus.
32292
11bee5bae414 Doc fixes.
Dave Love <fx@gnu.org>
parents: 30778
diff changeset
533 A rule is a pair (SUB-MENU-TITLE . MATCHER). SUB-MENU-TITLE is the
30416
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
534 displayed title of the sub-menu where a '%d' `format' pattern is
32292
11bee5bae414 Doc fixes.
Dave Love <fx@gnu.org>
parents: 30778
diff changeset
535 replaced by the number of items in the sub-menu. MATCHER is a regexp
11bee5bae414 Doc fixes.
Dave Love <fx@gnu.org>
parents: 30778
diff changeset
536 or a list of regexps. Items matching one of the regular expressions in
30416
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
537 MATCHER are added to the corresponding sub-menu."
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
538 :group 'recentf-filters
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
539 :type '(repeat (cons string (repeat regexp)))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
540 :set 'recentf-menu-customization-changed)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
541
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
542 (defcustom recentf-arrange-by-rule-others "Other files (%d)"
32292
11bee5bae414 Doc fixes.
Dave Love <fx@gnu.org>
parents: 30778
diff changeset
543 "*Title of the `recentf-arrange-by-rule' sub-menu.
11bee5bae414 Doc fixes.
Dave Love <fx@gnu.org>
parents: 30778
diff changeset
544 This is for the menu where items that don't match any
11bee5bae414 Doc fixes.
Dave Love <fx@gnu.org>
parents: 30778
diff changeset
545 `recentf-arrange-rules' are displayed. If nil these items are
11bee5bae414 Doc fixes.
Dave Love <fx@gnu.org>
parents: 30778
diff changeset
546 displayed in the main recent files menu. A '%d' `format' pattern in
11bee5bae414 Doc fixes.
Dave Love <fx@gnu.org>
parents: 30778
diff changeset
547 the title is replaced by the number of items in the sub-menu."
30416
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
548 :group 'recentf-filters
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
549 :type '(choice (const :tag "Main menu" nil)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
550 (string :tag "Title"))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
551 :set 'recentf-menu-customization-changed)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
552
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
553 (defcustom recentf-arrange-by-rules-min-items 0
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
554 "*Minimum number of items in a `recentf-arrange-by-rule' sub-menu.
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
555 If the number of items in a sub-menu is less than this value the
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
556 corresponding sub-menu items are displayed in the main recent files
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
557 menu or in the `recentf-arrange-by-rule-others' sub-menu if
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
558 defined."
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
559 :group 'recentf-filters
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
560 :type 'number
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
561 :set 'recentf-menu-customization-changed)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
562
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
563 (defcustom recentf-arrange-by-rule-subfilter nil
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
564 "*Function used by `recentf-arrange-by-rule' to filter sub-menu elements.
42205
7308bbc423d5 Doc fixes.
Pavel Janík <Pavel@Janik.cz>
parents: 38662
diff changeset
565 nil means no filter. See also `recentf-menu-filter'. You can't use
30416
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
566 `recentf-arrange-by-rule' itself here!"
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
567 :group 'recentf-filters
35971
6dd6fce1542a (recentf-menu-filter): Fix :type.
Dave Love <fx@gnu.org>
parents: 33770
diff changeset
568 :type '(choice (const nil) function)
30416
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
569 :set (lambda (sym val)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
570 (if (eq val 'recentf-arrange-by-rule)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
571 (error "Can't use `recentf-arrange-by-rule' itself here!")
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
572 (recentf-menu-customization-changed sym val))))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
573
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
574 (defun recentf-match-rule-p (matcher file-path)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
575 "Return non-nil if FILE-PATH match the rule specified by MATCHER.
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
576 See `recentf-arrange-rules' for details on MATCHER."
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
577 (if (stringp matcher)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
578 (string-match matcher file-path)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
579 (while (and (consp matcher)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
580 (not (string-match (car matcher) file-path)))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
581 (setq matcher (cdr matcher)))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
582 matcher))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
583
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
584 (defun recentf-arrange-by-rule (l)
32292
11bee5bae414 Doc fixes.
Dave Love <fx@gnu.org>
parents: 30778
diff changeset
585 "Filter the list of menu-elements L.
11bee5bae414 Doc fixes.
Dave Love <fx@gnu.org>
parents: 30778
diff changeset
586 Arrange them in sub-menus following rules in `recentf-arrange-rules'."
30416
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
587 (let ((sub-menus-number (length recentf-arrange-rules)))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
588 (if (> sub-menus-number 0)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
589 (let ((sub-menus (apply 'vector
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
590 (mapcar (function
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
591 (lambda (pair)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
592 (list (car pair))))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
593 recentf-arrange-rules)))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
594 other-menu-elements index min-size)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
595 (while l
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
596 (let* ((menu-element (car l))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
597 (file-path (recentf-menu-element-value menu-element))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
598 (rules recentf-arrange-rules)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
599 (found nil))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
600 (setq index 0)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
601 (while (and (not found) rules)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
602 (if (recentf-match-rule-p (cdar rules) file-path)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
603 (let ((sub-menu (aref sub-menus index)))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
604 (setq found t)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
605 (recentf-set-menu-element-value
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
606 sub-menu
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
607 (cons menu-element (recentf-menu-element-value sub-menu)))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
608 ))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
609 (setq index (1+ index))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
610 (setq rules (cdr rules)))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
611 (or found
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
612 (setq other-menu-elements
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
613 (cons menu-element other-menu-elements)))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
614 (setq l (cdr l))))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
615 (setq index 0)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
616 (setq l nil)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
617 (setq min-size (if (integerp recentf-arrange-by-rules-min-items)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
618 (max 0 recentf-arrange-by-rules-min-items)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
619 0))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
620 (while (< index sub-menus-number)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
621 (let* ((sub-menu (aref sub-menus index))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
622 (sub-menu-title (recentf-menu-element-item sub-menu))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
623 (sub-menu-elements (recentf-menu-element-value sub-menu))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
624 (sub-menu-length (length sub-menu-elements)))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
625 (if (> sub-menu-length 0)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
626 (cond
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
627 ((< sub-menu-length min-size)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
628 (setq other-menu-elements
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
629 (nconc sub-menu-elements other-menu-elements)))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
630 ((>= sub-menu-length min-size)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
631 (recentf-set-menu-element-item
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
632 sub-menu
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
633 (format sub-menu-title sub-menu-length))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
634 (recentf-set-menu-element-value
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
635 sub-menu
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
636 (recentf-apply-menu-filter
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
637 recentf-arrange-by-rule-subfilter
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
638 (nreverse sub-menu-elements)))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
639 (setq l (cons sub-menu l)))))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
640 (setq index (1+ index))))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
641 (if (and (stringp recentf-arrange-by-rule-others)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
642 other-menu-elements)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
643 (setq l
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
644 (nreverse
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
645 (cons (recentf-make-menu-element
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
646 (format recentf-arrange-by-rule-others
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
647 (length other-menu-elements))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
648 (recentf-apply-menu-filter
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
649 recentf-arrange-by-rule-subfilter
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
650 (nreverse other-menu-elements)))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
651 l)))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
652 (setq l (nconc (nreverse l)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
653 (recentf-apply-menu-filter
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
654 recentf-arrange-by-rule-subfilter
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
655 (nreverse other-menu-elements)))))))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
656 l))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
657
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
658 (defun recentf-build-mode-rules ()
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
659 "Convert `auto-mode-alist' to `recentf-arrange-rules' format."
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
660 (let ((case-fold-search recentf-case-fold-search)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
661 (modes auto-mode-alist)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
662 regexp mode rule-name rule rules)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
663 (while modes
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
664 (setq regexp (caar modes))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
665 (setq mode (cdar modes))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
666 (when (symbolp mode)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
667 (setq rule-name (symbol-name mode))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
668 (if (string-match "\\(.*\\)-mode$" rule-name)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
669 (setq rule-name (match-string 1 rule-name)))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
670 (setq rule-name (concat rule-name " (%d)"))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
671 (setq rule (assoc rule-name rules))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
672 (if rule
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
673 (setcdr rule (cons regexp (cdr rule)))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
674 (setq rules (cons (list rule-name regexp) rules))))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
675 (setq modes (cdr modes)))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
676 ;; It is important to preserve auto-mode-alist order
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
677 ;; to ensure the right file <-> mode association
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
678 (nreverse rules)))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
679
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
680 (defun recentf-arrange-by-mode (l)
32292
11bee5bae414 Doc fixes.
Dave Love <fx@gnu.org>
parents: 30778
diff changeset
681 "Filter the list of menu-elements L to build sub-menus for each major mode."
30416
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
682 (let ((recentf-arrange-rules (recentf-build-mode-rules))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
683 (recentf-arrange-by-rule-others "others (%d)"))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
684 (recentf-arrange-by-rule l)))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
685
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
686 (defun recentf-build-dir-rules (l)
32292
11bee5bae414 Doc fixes.
Dave Love <fx@gnu.org>
parents: 30778
diff changeset
687 "Convert directories in menu-elements L to rules in `recentf-arrange-rules' format."
30416
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
688 (let (dirs)
33770
4408efb1d628 (recentf-menu-items-for-commands)
Gerd Moellmann <gerd@gnu.org>
parents: 33196
diff changeset
689 (mapc (function
4408efb1d628 (recentf-menu-items-for-commands)
Gerd Moellmann <gerd@gnu.org>
parents: 33196
diff changeset
690 (lambda (e)
4408efb1d628 (recentf-menu-items-for-commands)
Gerd Moellmann <gerd@gnu.org>
parents: 33196
diff changeset
691 (let ((dir (file-name-directory
4408efb1d628 (recentf-menu-items-for-commands)
Gerd Moellmann <gerd@gnu.org>
parents: 33196
diff changeset
692 (recentf-menu-element-value e))))
4408efb1d628 (recentf-menu-items-for-commands)
Gerd Moellmann <gerd@gnu.org>
parents: 33196
diff changeset
693 (or (member dir dirs)
4408efb1d628 (recentf-menu-items-for-commands)
Gerd Moellmann <gerd@gnu.org>
parents: 33196
diff changeset
694 (setq dirs (cons dir dirs))))))
4408efb1d628 (recentf-menu-items-for-commands)
Gerd Moellmann <gerd@gnu.org>
parents: 33196
diff changeset
695 l)
30416
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
696 (mapcar (function
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
697 (lambda (d)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
698 (cons (concat d " (%d)")
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
699 (concat "\\`" d))))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
700 (nreverse (sort dirs 'string-lessp)))))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
701
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
702 (defun recentf-file-name-nondir (l)
32292
11bee5bae414 Doc fixes.
Dave Love <fx@gnu.org>
parents: 30778
diff changeset
703 "Filter the list of menu-elements L to show only filenames.
11bee5bae414 Doc fixes.
Dave Love <fx@gnu.org>
parents: 30778
diff changeset
704 This simplified version of `recentf-show-basenames' does not handle
11bee5bae414 Doc fixes.
Dave Love <fx@gnu.org>
parents: 30778
diff changeset
705 duplicates. It is used by `recentf-arrange-by-dir' as its
30416
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
706 `recentf-arrange-by-rule-subfilter'."
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
707 (mapcar (function
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
708 (lambda (e)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
709 (recentf-make-menu-element
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
710 (file-name-nondirectory (recentf-menu-element-value e))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
711 (recentf-menu-element-value e))))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
712 l))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
713
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
714 (defun recentf-arrange-by-dir (l)
32292
11bee5bae414 Doc fixes.
Dave Love <fx@gnu.org>
parents: 30778
diff changeset
715 "Filter the list of menu-elements L to build sub-menus for each directory."
30416
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
716 (let ((recentf-arrange-rules (recentf-build-dir-rules l))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
717 (recentf-arrange-by-rule-subfilter 'recentf-file-name-nondir)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
718 recentf-arrange-by-rule-others)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
719 (nreverse (recentf-arrange-by-rule l))))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
720
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
721 (defvar recentf-filter-changer-state nil
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
722 "Used by `recentf-filter-changer' to hold its state.")
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
723
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
724 (defcustom recentf-filter-changer-alist
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
725 '(
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
726 (recentf-arrange-by-mode . "*Files by Mode*")
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
727 (recentf-arrange-by-dir . "*Files by Directory*")
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
728 (recentf-arrange-by-rule . "*Files by User Rule*")
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
729 )
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
730 "*List of filters managed by `recentf-filter-changer'.
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
731 Each filter is defined by a pair (FILTER-FUN . FILTER-LBL) where:
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
732
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
733 - - FILTER-FUN is the function that filters menu-elements
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
734 - - FILTER-LBL is the menu item used to activate the filter"
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
735 :group 'recentf-filters
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
736 :type '(repeat (cons function string))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
737 :set (lambda (sym val)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
738 (setq recentf-filter-changer-state nil)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
739 (recentf-menu-customization-changed sym val)))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
740
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
741 (defun recentf-filter-changer-goto-next ()
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
742 "Go to the next filter available (see `recentf-filter-changer')."
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
743 (and (consp recentf-filter-changer-state)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
744 (setq recentf-filter-changer-state
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
745 (cdr recentf-filter-changer-state)))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
746 (setq recentf-update-menu-p t))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
747
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
748 (defun recentf-filter-changer-get-current ()
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
749 "Get the current filter available (see `recentf-filter-changer')."
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
750 (if (null recentf-filter-changer-state)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
751 (setq recentf-filter-changer-state recentf-filter-changer-alist))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
752 (and (consp recentf-filter-changer-state)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
753 (car recentf-filter-changer-state)))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
754
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
755 (defun recentf-filter-changer-get-next ()
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
756 "Get the next filter available (see `recentf-filter-changer')."
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
757 (let ((filters recentf-filter-changer-state))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
758 (cond ((consp filters)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
759 (setq filters (cdr filters))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
760 (if (null filters)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
761 (setq filters recentf-filter-changer-alist)))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
762 (t
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
763 (setq filters recentf-filter-changer-alist)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
764 (if (consp filters)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
765 (setq filters (cdr filters)))))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
766 (if (consp filters)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
767 (car filters))))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
768
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
769 (defun recentf-filter-changer (l)
32292
11bee5bae414 Doc fixes.
Dave Love <fx@gnu.org>
parents: 30778
diff changeset
770 "Manage a ring of filters.
11bee5bae414 Doc fixes.
Dave Love <fx@gnu.org>
parents: 30778
diff changeset
771 `recentf-filter-changer-alist' defines the filters in the ring.
11bee5bae414 Doc fixes.
Dave Love <fx@gnu.org>
parents: 30778
diff changeset
772 Actual filtering of L is delegated to the current filter in the
11bee5bae414 Doc fixes.
Dave Love <fx@gnu.org>
parents: 30778
diff changeset
773 ring. A filter menu item is displayed allowing to dynamically activate
11bee5bae414 Doc fixes.
Dave Love <fx@gnu.org>
parents: 30778
diff changeset
774 the next filter in the ring. If the filter ring is empty L is left
11bee5bae414 Doc fixes.
Dave Love <fx@gnu.org>
parents: 30778
diff changeset
775 unchanged."
30416
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
776 (let ((current-filter-item (recentf-filter-changer-get-current))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
777 (next-filter-item (recentf-filter-changer-get-next)))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
778 (when current-filter-item
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
779 (setq l (recentf-apply-menu-filter (car current-filter-item) l))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
780 (if next-filter-item
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
781 (setq recentf-menu-filter-commands
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
782 (list (vector (cdr next-filter-item)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
783 '(recentf-filter-changer-goto-next)
33770
4408efb1d628 (recentf-menu-items-for-commands)
Gerd Moellmann <gerd@gnu.org>
parents: 33196
diff changeset
784 :active t)))))
30416
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
785 l))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
786
32429
0e626f0c2b8a Maintainer's checkdoc fixes.
Dave Love <fx@gnu.org>
parents: 32292
diff changeset
787 ;;;;
0e626f0c2b8a Maintainer's checkdoc fixes.
Dave Love <fx@gnu.org>
parents: 32292
diff changeset
788 ;;;; Dialogs stuff
0e626f0c2b8a Maintainer's checkdoc fixes.
Dave Love <fx@gnu.org>
parents: 32292
diff changeset
789 ;;;;
30416
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
790
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
791 (defun recentf-cancel-dialog (&rest ignore)
32292
11bee5bae414 Doc fixes.
Dave Love <fx@gnu.org>
parents: 30778
diff changeset
792 "Cancel the current dialog.
11bee5bae414 Doc fixes.
Dave Love <fx@gnu.org>
parents: 30778
diff changeset
793 Used by `recentf-edit-list' and `recentf-open-files' dialogs."
30416
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
794 (interactive)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
795 (kill-buffer (current-buffer))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
796 (message "Dialog canceled."))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
797
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
798 (defvar recentf-dialog-mode-map nil
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
799 "`recentf-dialog-mode' keymap.")
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
800
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
801 (if recentf-dialog-mode-map
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
802 ()
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
803 (setq recentf-dialog-mode-map (make-sparse-keymap))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
804 (define-key recentf-dialog-mode-map "q" 'recentf-cancel-dialog)
30778
293a86f4d8aa (recent-dialog-mode-map): Bind down-mouse-1 to
Gerd Moellmann <gerd@gnu.org>
parents: 30416
diff changeset
805 (define-key recentf-dialog-mode-map [down-mouse-1] 'widget-button-click)
30416
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
806 (set-keymap-parent recentf-dialog-mode-map widget-keymap))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
807
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
808 (defun recentf-dialog-mode ()
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
809 "Major mode used in recentf dialogs.
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
810
32429
0e626f0c2b8a Maintainer's checkdoc fixes.
Dave Love <fx@gnu.org>
parents: 32292
diff changeset
811 These are the special commands of `recentf-dialog-mode' mode:
30416
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
812 q -- cancel this dialog."
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
813 (interactive)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
814 (setq major-mode 'recentf-dialog-mode)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
815 (setq mode-name "recentf-dialog")
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
816 (use-local-map recentf-dialog-mode-map))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
817
32429
0e626f0c2b8a Maintainer's checkdoc fixes.
Dave Love <fx@gnu.org>
parents: 32292
diff changeset
818 ;;;;
0e626f0c2b8a Maintainer's checkdoc fixes.
Dave Love <fx@gnu.org>
parents: 32292
diff changeset
819 ;;;; Hooks and Commands
0e626f0c2b8a Maintainer's checkdoc fixes.
Dave Love <fx@gnu.org>
parents: 32292
diff changeset
820 ;;;;
30416
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
821
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
822 (defun recentf-add-file-hook ()
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
823 "Insert the name of the file just opened or written into `recentf-list'."
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
824 (and buffer-file-name (recentf-add-file buffer-file-name))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
825 nil)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
826
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
827 (defun recentf-remove-file-hook ()
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
828 "When a buffer is killed remove a non readable file from `recentf-list'."
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
829 (and buffer-file-name (recentf-remove-if-non-readable buffer-file-name))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
830 nil)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
831
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
832 (defun recentf-update-menu-hook ()
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
833 "Update the recentf menu from the current `recentf-list'."
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
834 (when recentf-update-menu-p
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
835 (condition-case nil
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
836 (progn
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
837 (setq recentf-update-menu-p nil)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
838 (easy-menu-change recentf-menu-path
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
839 recentf-menu-title
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
840 (recentf-make-menu-items)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
841 recentf-menu-before))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
842 (error nil))))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
843
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
844 (defun recentf-dump-variable (variable &optional limit)
32292
11bee5bae414 Doc fixes.
Dave Love <fx@gnu.org>
parents: 30778
diff changeset
845 "Insert a \"(setq VARIABLE value)\" in the current buffer.
11bee5bae414 Doc fixes.
Dave Love <fx@gnu.org>
parents: 30778
diff changeset
846 Optional argument LIMIT specifies a maximum length when VARIABLE value
11bee5bae414 Doc fixes.
Dave Love <fx@gnu.org>
parents: 30778
diff changeset
847 is a list (default to the full list)."
30416
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
848 (let ((value (symbol-value variable)))
38662
dd6bc9395c61 (recentf-dump-variable): Handle a value of nil
Gerd Moellmann <gerd@gnu.org>
parents: 38436
diff changeset
849 (if (listp value)
dd6bc9395c61 (recentf-dump-variable): Handle a value of nil
Gerd Moellmann <gerd@gnu.org>
parents: 38436
diff changeset
850 (progn
dd6bc9395c61 (recentf-dump-variable): Handle a value of nil
Gerd Moellmann <gerd@gnu.org>
parents: 38436
diff changeset
851 (when (and (integerp limit) (> limit 0))
dd6bc9395c61 (recentf-dump-variable): Handle a value of nil
Gerd Moellmann <gerd@gnu.org>
parents: 38436
diff changeset
852 (setq value (recentf-trunc-list value limit)))
dd6bc9395c61 (recentf-dump-variable): Handle a value of nil
Gerd Moellmann <gerd@gnu.org>
parents: 38436
diff changeset
853 (insert (format "(setq %S '(" variable))
dd6bc9395c61 (recentf-dump-variable): Handle a value of nil
Gerd Moellmann <gerd@gnu.org>
parents: 38436
diff changeset
854 (mapc (lambda (e) (insert (format "\n%S" e))) value)
dd6bc9395c61 (recentf-dump-variable): Handle a value of nil
Gerd Moellmann <gerd@gnu.org>
parents: 38436
diff changeset
855 (insert "))\n"))
dd6bc9395c61 (recentf-dump-variable): Handle a value of nil
Gerd Moellmann <gerd@gnu.org>
parents: 38436
diff changeset
856 (insert (format "(setq %S %S)\n" variable value)))))
30416
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
857
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
858 ;;;###autoload
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
859 (defun recentf-save-list ()
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
860 "Save the current `recentf-list' to the file `recentf-save-file'."
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
861 (interactive)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
862 (with-temp-buffer
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
863 (erase-buffer)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
864 (insert (format recentf-save-file-header (current-time-string)))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
865 (recentf-dump-variable 'recentf-list recentf-max-saved-items)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
866 (recentf-dump-variable 'recentf-filter-changer-state)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
867 (if (file-writable-p recentf-save-file)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
868 (write-region (point-min) (point-max) recentf-save-file))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
869 (kill-buffer (current-buffer)))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
870 nil)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
871
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
872 (defvar recentf-edit-selected-items nil
32292
11bee5bae414 Doc fixes.
Dave Love <fx@gnu.org>
parents: 30778
diff changeset
873 "Used by `recentf-edit-list'.
11bee5bae414 Doc fixes.
Dave Love <fx@gnu.org>
parents: 30778
diff changeset
874 Holds list of files to be deleted from `recentf-list'.")
30416
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
875
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
876 (defun recentf-edit-list-action (widget &rest ignore)
32429
0e626f0c2b8a Maintainer's checkdoc fixes.
Dave Love <fx@gnu.org>
parents: 32292
diff changeset
877 "Checkbox WIDGET action used by `recentf-edit-list' to select/unselect a file."
30416
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
878 (let ((value (widget-get widget ':tag)))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
879 ;; if value is already in the selected items
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
880 (if (memq value recentf-edit-selected-items)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
881 ;; then remove it
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
882 (progn
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
883 (setq recentf-edit-selected-items
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
884 (delq value recentf-edit-selected-items))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
885 (message "%s removed from selection." value))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
886 ;; else add it
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
887 (progn
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
888 (setq recentf-edit-selected-items
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
889 (nconc (list value) recentf-edit-selected-items))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
890 (message "%s added to selection." value)))))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
891
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
892 ;;;###autoload
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
893 (defun recentf-edit-list ()
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
894 "Allow the user to edit the files that are kept in the recent list."
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
895 (interactive)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
896 (with-current-buffer (get-buffer-create (concat "*" recentf-menu-title " - Edit list*"))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
897 (switch-to-buffer (current-buffer))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
898 (kill-all-local-variables)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
899 (let ((inhibit-read-only t))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
900 (erase-buffer))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
901 (let ((all (overlay-lists)))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
902 ;; Delete all the overlays.
33770
4408efb1d628 (recentf-menu-items-for-commands)
Gerd Moellmann <gerd@gnu.org>
parents: 33196
diff changeset
903 (mapc 'delete-overlay (car all))
4408efb1d628 (recentf-menu-items-for-commands)
Gerd Moellmann <gerd@gnu.org>
parents: 33196
diff changeset
904 (mapc 'delete-overlay (cdr all)))
30416
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
905 (setq recentf-edit-selected-items nil)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
906 ;; Insert the dialog header
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
907 (widget-insert "Select the files to be deleted from the 'recentf-list'.\n\n")
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
908 (widget-insert "Click on Ok to update the list. ")
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
909 (widget-insert "Click on Cancel or type \"q\" to quit.\n")
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
910 ;; Insert the list of files as checkboxes
33770
4408efb1d628 (recentf-menu-items-for-commands)
Gerd Moellmann <gerd@gnu.org>
parents: 33196
diff changeset
911 (mapc (function
4408efb1d628 (recentf-menu-items-for-commands)
Gerd Moellmann <gerd@gnu.org>
parents: 33196
diff changeset
912 (lambda (item)
4408efb1d628 (recentf-menu-items-for-commands)
Gerd Moellmann <gerd@gnu.org>
parents: 33196
diff changeset
913 (widget-create 'checkbox
4408efb1d628 (recentf-menu-items-for-commands)
Gerd Moellmann <gerd@gnu.org>
parents: 33196
diff changeset
914 :value nil ; unselected checkbox
4408efb1d628 (recentf-menu-items-for-commands)
Gerd Moellmann <gerd@gnu.org>
parents: 33196
diff changeset
915 :format "\n %[%v%] %t"
4408efb1d628 (recentf-menu-items-for-commands)
Gerd Moellmann <gerd@gnu.org>
parents: 33196
diff changeset
916 :tag item
4408efb1d628 (recentf-menu-items-for-commands)
Gerd Moellmann <gerd@gnu.org>
parents: 33196
diff changeset
917 :notify 'recentf-edit-list-action)))
4408efb1d628 (recentf-menu-items-for-commands)
Gerd Moellmann <gerd@gnu.org>
parents: 33196
diff changeset
918 recentf-list)
30416
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
919 (widget-insert "\n\n")
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
920 ;; Insert the Ok button
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
921 (widget-create 'push-button
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
922 :notify (lambda (&rest ignore)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
923 (if recentf-edit-selected-items
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
924 (progn (kill-buffer (current-buffer))
33770
4408efb1d628 (recentf-menu-items-for-commands)
Gerd Moellmann <gerd@gnu.org>
parents: 33196
diff changeset
925 (mapc (function
4408efb1d628 (recentf-menu-items-for-commands)
Gerd Moellmann <gerd@gnu.org>
parents: 33196
diff changeset
926 (lambda (item)
4408efb1d628 (recentf-menu-items-for-commands)
Gerd Moellmann <gerd@gnu.org>
parents: 33196
diff changeset
927 (setq recentf-list
4408efb1d628 (recentf-menu-items-for-commands)
Gerd Moellmann <gerd@gnu.org>
parents: 33196
diff changeset
928 (delq item recentf-list))))
4408efb1d628 (recentf-menu-items-for-commands)
Gerd Moellmann <gerd@gnu.org>
parents: 33196
diff changeset
929 recentf-edit-selected-items)
30416
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
930 (message "%S file(s) removed from the list"
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
931 (length recentf-edit-selected-items))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
932 (setq recentf-update-menu-p t))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
933 (message "No file selected.")))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
934 "Ok")
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
935 (widget-insert " ")
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
936 ;; Insert the Cancel button
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
937 (widget-create 'push-button
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
938 :notify 'recentf-cancel-dialog
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
939 "Cancel")
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
940 (recentf-dialog-mode)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
941 (widget-setup)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
942 (goto-char (point-min))))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
943
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
944 ;;;###autoload
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
945 (defun recentf-cleanup ()
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
946 "Remove all non-readable and excluded files from `recentf-list'."
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
947 (interactive)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
948 (let ((count (length recentf-list)))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
949 (setq recentf-list
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
950 (delq nil
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
951 (mapcar (function
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
952 (lambda (filename)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
953 (and (file-readable-p filename)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
954 (recentf-include-p filename)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
955 filename)))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
956 recentf-list)))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
957 (setq count (- count (length recentf-list)))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
958 (message "%s removed from the list"
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
959 (cond ((= count 0) "No file")
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
960 ((= count 1) "One file")
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
961 (t (format "%d files" count)))))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
962 (setq recentf-update-menu-p t))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
963
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
964 (defun recentf-open-files-action (widget &rest ignore)
32429
0e626f0c2b8a Maintainer's checkdoc fixes.
Dave Love <fx@gnu.org>
parents: 32292
diff changeset
965 "Button WIDGET action used by `recentf-open-files' to open a file."
30416
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
966 (kill-buffer (current-buffer))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
967 (funcall recentf-menu-action (widget-value widget)))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
968
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
969 (defvar recentf-open-files-item-shift ""
32292
11bee5bae414 Doc fixes.
Dave Love <fx@gnu.org>
parents: 30778
diff changeset
970 "String used by `recentf-open-files' to shift right sub-menu items.")
30416
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
971
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
972 (defun recentf-open-files-item (menu-element)
32429
0e626f0c2b8a Maintainer's checkdoc fixes.
Dave Love <fx@gnu.org>
parents: 32292
diff changeset
973 "Insert MENU-ELEMENT item in the current interaction buffer."
30416
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
974 (let ((menu-item (car menu-element))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
975 (file-path (cdr menu-element)))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
976 (if (consp file-path) ; This is a sub-menu
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
977 (let* ((shift recentf-open-files-item-shift)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
978 (recentf-open-files-item-shift (concat shift " ")))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
979 (widget-create 'item
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
980 :tag menu-item
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
981 :sample-face 'bold
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
982 :format (concat shift "%{%t%}:\n"))
33770
4408efb1d628 (recentf-menu-items-for-commands)
Gerd Moellmann <gerd@gnu.org>
parents: 33196
diff changeset
983 (mapc 'recentf-open-files-item
4408efb1d628 (recentf-menu-items-for-commands)
Gerd Moellmann <gerd@gnu.org>
parents: 33196
diff changeset
984 file-path)
30416
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
985 (widget-insert "\n"))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
986 (widget-create 'push-button
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
987 :button-face 'default
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
988 :tag menu-item
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
989 :help-echo (concat "Open " file-path)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
990 :format (concat recentf-open-files-item-shift "%[%t%]")
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
991 :notify 'recentf-open-files-action
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
992 file-path)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
993 (widget-insert "\n"))))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
994
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
995 ;;;###autoload
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
996 (defun recentf-open-files (&optional files buffer-name)
32292
11bee5bae414 Doc fixes.
Dave Love <fx@gnu.org>
parents: 30778
diff changeset
997 "Display buffer allowing user to choose a file from recently-opened list.
11bee5bae414 Doc fixes.
Dave Love <fx@gnu.org>
parents: 30778
diff changeset
998 The optional argument FILES may be used to specify the list, otherwise
32429
0e626f0c2b8a Maintainer's checkdoc fixes.
Dave Love <fx@gnu.org>
parents: 32292
diff changeset
999 `recentf-list' is used. The optional argument BUFFER-NAME specifies
32292
11bee5bae414 Doc fixes.
Dave Love <fx@gnu.org>
parents: 30778
diff changeset
1000 which buffer to use for the interaction."
30416
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
1001 (interactive)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
1002 (if (null files)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
1003 (setq files recentf-list))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
1004 (if (null buffer-name)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
1005 (setq buffer-name (concat "*" recentf-menu-title "*")))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
1006 (with-current-buffer (get-buffer-create buffer-name)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
1007 (switch-to-buffer (current-buffer))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
1008 (kill-all-local-variables)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
1009 (let ((inhibit-read-only t))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
1010 (erase-buffer))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
1011 (let ((all (overlay-lists)))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
1012 ;; Delete all the overlays.
33770
4408efb1d628 (recentf-menu-items-for-commands)
Gerd Moellmann <gerd@gnu.org>
parents: 33196
diff changeset
1013 (mapc 'delete-overlay (car all))
4408efb1d628 (recentf-menu-items-for-commands)
Gerd Moellmann <gerd@gnu.org>
parents: 33196
diff changeset
1014 (mapc 'delete-overlay (cdr all)))
30416
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
1015 ;; Insert the dialog header
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
1016 (widget-insert "Click on a file to open it. ")
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
1017 (widget-insert "Click on Cancel or type \"q\" to quit.\n\n" )
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
1018 ;; Insert the list of files as buttons
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
1019 (let ((recentf-open-files-item-shift ""))
33770
4408efb1d628 (recentf-menu-items-for-commands)
Gerd Moellmann <gerd@gnu.org>
parents: 33196
diff changeset
1020 (mapc 'recentf-open-files-item
4408efb1d628 (recentf-menu-items-for-commands)
Gerd Moellmann <gerd@gnu.org>
parents: 33196
diff changeset
1021 (recentf-apply-menu-filter
4408efb1d628 (recentf-menu-items-for-commands)
Gerd Moellmann <gerd@gnu.org>
parents: 33196
diff changeset
1022 recentf-menu-filter
4408efb1d628 (recentf-menu-items-for-commands)
Gerd Moellmann <gerd@gnu.org>
parents: 33196
diff changeset
1023 (mapcar 'recentf-make-default-menu-element files))))
30416
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
1024 (widget-insert "\n")
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
1025 ;; Insert the Cancel button
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
1026 (widget-create 'push-button
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
1027 :notify 'recentf-cancel-dialog
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
1028 "Cancel")
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
1029 (recentf-dialog-mode)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
1030 (widget-setup)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
1031 (goto-char (point-min))))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
1032
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
1033 ;;;###autoload
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
1034 (defun recentf-open-more-files ()
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
1035 "Allow the user to open files that are not in the menu."
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
1036 (interactive)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
1037 (recentf-open-files (nthcdr recentf-max-menu-items recentf-list)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
1038 (concat "*" recentf-menu-title " - More*")))
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
1039
32866
8ef794e21542 (recentf-mode): Variable removed.
Miles Bader <miles@gnu.org>
parents: 32429
diff changeset
1040
8ef794e21542 (recentf-mode): Variable removed.
Miles Bader <miles@gnu.org>
parents: 32429
diff changeset
1041 ;;; Note this definition must be at the end of the file, because
8ef794e21542 (recentf-mode): Variable removed.
Miles Bader <miles@gnu.org>
parents: 32429
diff changeset
1042 ;;; `define-minor-mode' actually calls the mode-function if the
8ef794e21542 (recentf-mode): Variable removed.
Miles Bader <miles@gnu.org>
parents: 32429
diff changeset
1043 ;;; associated variable is non-nil, which requires that all needed
8ef794e21542 (recentf-mode): Variable removed.
Miles Bader <miles@gnu.org>
parents: 32429
diff changeset
1044 ;;; functions be already defined. [This is arguably a bug in d-m-m]
30416
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
1045 ;;;###autoload
32866
8ef794e21542 (recentf-mode): Variable removed.
Miles Bader <miles@gnu.org>
parents: 32429
diff changeset
1046 (define-minor-mode recentf-mode
30416
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
1047 "Toggle recentf mode.
32866
8ef794e21542 (recentf-mode): Variable removed.
Miles Bader <miles@gnu.org>
parents: 32429
diff changeset
1048 With prefix argument ARG, turn on if positive, otherwise off.
8ef794e21542 (recentf-mode): Variable removed.
Miles Bader <miles@gnu.org>
parents: 32429
diff changeset
1049 Returns non-nil if the new state is enabled.
30416
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
1050
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
1051 When recentf mode is enabled, it maintains a menu for visiting files that
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
1052 were operated on recently."
32866
8ef794e21542 (recentf-mode): Variable removed.
Miles Bader <miles@gnu.org>
parents: 32429
diff changeset
1053 :global t
8ef794e21542 (recentf-mode): Variable removed.
Miles Bader <miles@gnu.org>
parents: 32429
diff changeset
1054 :group 'recentf
8ef794e21542 (recentf-mode): Variable removed.
Miles Bader <miles@gnu.org>
parents: 32429
diff changeset
1055 (if recentf-mode
8ef794e21542 (recentf-mode): Variable removed.
Miles Bader <miles@gnu.org>
parents: 32429
diff changeset
1056 (unless recentf-initialized-p
8ef794e21542 (recentf-mode): Variable removed.
Miles Bader <miles@gnu.org>
parents: 32429
diff changeset
1057 (setq recentf-initialized-p t)
8ef794e21542 (recentf-mode): Variable removed.
Miles Bader <miles@gnu.org>
parents: 32429
diff changeset
1058 (if (file-readable-p recentf-save-file)
8ef794e21542 (recentf-mode): Variable removed.
Miles Bader <miles@gnu.org>
parents: 32429
diff changeset
1059 (load-file recentf-save-file))
8ef794e21542 (recentf-mode): Variable removed.
Miles Bader <miles@gnu.org>
parents: 32429
diff changeset
1060 (setq recentf-update-menu-p t)
8ef794e21542 (recentf-mode): Variable removed.
Miles Bader <miles@gnu.org>
parents: 32429
diff changeset
1061 (add-hook 'find-file-hooks 'recentf-add-file-hook)
8ef794e21542 (recentf-mode): Variable removed.
Miles Bader <miles@gnu.org>
parents: 32429
diff changeset
1062 (add-hook 'write-file-hooks 'recentf-add-file-hook)
8ef794e21542 (recentf-mode): Variable removed.
Miles Bader <miles@gnu.org>
parents: 32429
diff changeset
1063 (add-hook 'menu-bar-update-hook 'recentf-update-menu-hook)
8ef794e21542 (recentf-mode): Variable removed.
Miles Bader <miles@gnu.org>
parents: 32429
diff changeset
1064 (add-hook 'kill-emacs-hook 'recentf-save-list))
8ef794e21542 (recentf-mode): Variable removed.
Miles Bader <miles@gnu.org>
parents: 32429
diff changeset
1065 (when recentf-initialized-p
8ef794e21542 (recentf-mode): Variable removed.
Miles Bader <miles@gnu.org>
parents: 32429
diff changeset
1066 (setq recentf-initialized-p nil)
8ef794e21542 (recentf-mode): Variable removed.
Miles Bader <miles@gnu.org>
parents: 32429
diff changeset
1067 (recentf-save-list)
8ef794e21542 (recentf-mode): Variable removed.
Miles Bader <miles@gnu.org>
parents: 32429
diff changeset
1068 (easy-menu-remove-item nil recentf-menu-path recentf-menu-title)
8ef794e21542 (recentf-mode): Variable removed.
Miles Bader <miles@gnu.org>
parents: 32429
diff changeset
1069 (remove-hook 'find-file-hooks 'recentf-add-file-hook)
8ef794e21542 (recentf-mode): Variable removed.
Miles Bader <miles@gnu.org>
parents: 32429
diff changeset
1070 (remove-hook 'write-file-hooks 'recentf-add-file-hook)
8ef794e21542 (recentf-mode): Variable removed.
Miles Bader <miles@gnu.org>
parents: 32429
diff changeset
1071 (remove-hook 'menu-bar-update-hook 'recentf-update-menu-hook)
8ef794e21542 (recentf-mode): Variable removed.
Miles Bader <miles@gnu.org>
parents: 32429
diff changeset
1072 (remove-hook 'kill-emacs-hook 'recentf-save-list))))
8ef794e21542 (recentf-mode): Variable removed.
Miles Bader <miles@gnu.org>
parents: 32429
diff changeset
1073
30416
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
1074
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
1075 (provide 'recentf)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
1076
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
1077 (run-hooks 'recentf-load-hook)
cc08ed656c8c Fix CRLF eols.
Dave Love <fx@gnu.org>
parents: 30286
diff changeset
1078
32429
0e626f0c2b8a Maintainer's checkdoc fixes.
Dave Love <fx@gnu.org>
parents: 32292
diff changeset
1079 ;;; recentf.el ends here