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