Mercurial > emacs
annotate lisp/recentf.el @ 27164:7e06ce5ebfe3
*** empty log message ***
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Wed, 05 Jan 2000 08:13:59 +0000 |
parents | 40b9e5591aac |
children | b84ee89aaf37 |
rev | line source |
---|---|
25997
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1 ;; recentf.el --- setup a menu of recently opened files |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2 |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
3 ;; Copyright (C) 1999 Free Software Foundation, Inc. |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
4 |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
5 ;; Author: David Ponce <david.ponce@wanadoo.fr> |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
6 ;; Created: July 19 1999 |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
7 ;; Keywords: customization |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
8 |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
9 ;; This file is part of GNU Emacs. |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
10 |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
11 ;; GNU Emacs is free software; you can redistribute it and/or modify |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
12 ;; it under the terms of the GNU General Public License as published by |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
13 ;; the Free Software Foundation; either version 2, or (at your option) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
14 ;; any later version. |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
15 |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
16 ;; GNU Emacs is distributed in the hope that it will be useful, |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
19 ;; GNU General Public License for more details. |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
20 |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
21 ;; You should have received a copy of the GNU General Public License |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
24 ;; Boston, MA 02111-1307, USA. |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
25 |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
26 ;;; Commentary: |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
27 |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
28 ;;; Code: |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
29 |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
30 (require 'easymenu) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
31 |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
32 (defconst recentf-save-file-header |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
33 ";;; Automatically generated by `recentf' on %s.\n" |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
34 "Header to be written into the `recentf-save-file'.") |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
35 |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
36 (defvar recentf-list nil |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
37 "List of recently opened files.") |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
38 |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
39 (defvar recentf-update-menu-p t |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
40 "Non-nil if the recentf menu must be updated.") |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
41 |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
42 (defvar recentf-initialized-p nil |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
43 "Non-nil if recentf already initialized.") |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
44 |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
45 ;; IMPORTANT: This function must be defined before the following defcustoms |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
46 ;; because it is used in their :set clause. To avoid byte-compiler warnings |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
47 ;; the `symbol-value' function is used to access the `recentf-menu-path' |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
48 ;; and `recentf-menu-title' values. |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
49 (defun recentf-menu-customization-changed (sym val) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
50 "Function called when menu customization has changed. |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
51 It removes the recentf menu and forces its complete redrawing." |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
52 (when recentf-initialized-p |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
53 (easy-menu-remove-item nil |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
54 (symbol-value 'recentf-menu-path) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
55 (symbol-value 'recentf-menu-title)) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
56 (setq recentf-update-menu-p t)) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
57 (custom-set-default sym val)) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
58 |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
59 (defgroup recentf nil |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
60 "Maintain a menu of recently opened files." |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
61 :group 'files) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
62 |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
63 (defcustom recentf-max-saved-items 20 |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
64 "*Maximum number of items saved to `recentf-save-file'." |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
65 :group 'recentf |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
66 :type 'integer) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
67 |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
68 (defcustom recentf-save-file (expand-file-name "~/.recentf") |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
69 "*File to save `recentf-list' into." |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
70 :group 'recentf |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
71 :type 'file) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
72 |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
73 (defcustom recentf-exclude nil |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
74 "*List of regexps for filenames excluded from `recentf-list'." |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
75 :group 'recentf |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
76 :type '(repeat regexp)) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
77 |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
78 (defcustom recentf-menu-title "Open Recent" |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
79 "*Name of the recentf menu." |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
80 :group 'recentf |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
81 :type 'string |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
82 :set 'recentf-menu-customization-changed) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
83 |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
84 (defcustom recentf-menu-path '("files") |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
85 "*Path where to add the recentf menu. |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
86 If nil add it at top-level (see also `easy-menu-change')." |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
87 :group 'recentf |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
88 :type '(choice (const :tag "Top Level" nil) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
89 (sexp :tag "Menu Path")) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
90 :set 'recentf-menu-customization-changed) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
91 |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
92 (defcustom recentf-menu-before "open-file" |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
93 "*Name of the menu before which the recentf menu will be added. |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
94 If nil add it at end of menu (see also `easy-menu-change')." |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
95 :group 'recentf |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
96 :type '(choice (string :tag "Name") |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
97 (const :tag "Last" nil)) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
98 :set 'recentf-menu-customization-changed) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
99 |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
100 (defcustom recentf-menu-action 'recentf-find-file |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
101 "*Function to invoke with a filename item of the recentf menu. |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
102 The default action `recentf-find-file' calls `find-file' to edit an |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
103 existing file. If the file does not exist or is not readable, it is |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
104 not edited and its name is removed from `recentf-list'. You can use |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
105 `find-file' instead to open non-existing files and keep them is the |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
106 list of recently opened files." |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
107 :group 'recentf |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
108 :type 'function |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
109 :set 'recentf-menu-customization-changed) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
110 |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
111 (defcustom recentf-max-menu-items 10 |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
112 "*Maximum number of items in the recentf menu." |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
113 :group 'recentf |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
114 :type 'integer |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
115 :set 'recentf-menu-customization-changed) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
116 |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
117 (defcustom recentf-menu-filter nil |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
118 "*Function used to filter files displayed in the recentf menu. |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
119 Nil means no filter. The following functions are predefined: |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
120 |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
121 - - `recentf-sort-ascending' to sort menu items in ascending order. |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
122 - - `recentf-sort-descending' to sort menu items in descending order. |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
123 |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
124 The filter function is called with one argument, the list of filenames to be |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
125 displayed in the menu and must return a new list of filenames." |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
126 :group 'recentf |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
127 :type 'function |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
128 :set 'recentf-menu-customization-changed) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
129 |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
130 (defcustom recentf-menu-append-commands-p t |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
131 "*If not-nil command items are appended to the menu." |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
132 :group 'recentf |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
133 :type 'boolean |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
134 :set 'recentf-menu-customization-changed) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
135 |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
136 (defcustom recentf-keep-non-readable-files-p nil |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
137 "*If nil (default), non-readable files are not kept in `recentf-list'." |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
138 :group 'recentf |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
139 :type 'boolean |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
140 :set '(lambda (sym val) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
141 (if val |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
142 (remove-hook kill-buffer-hook recentf-remove-file-hook) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
143 (add-hook kill-buffer-hook recentf-remove-file-hook)) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
144 (custom-set-default sym val))) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
145 |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
146 (defcustom recentf-mode nil |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
147 "Toggle recentf mode. |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
148 When recentf mode is enabled, it maintains a menu for visiting files that |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
149 were operated on recently. |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
150 Setting this variable directly does not take effect; |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
151 use either \\[customize] or the function `recentf-mode'." |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
152 :set (lambda (symbol value) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
153 (recentf-mode (or value 0))) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
154 :initialize 'custom-initialize-default |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
155 :type 'boolean |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
156 :group 'recentf |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
157 :require 'recentf) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
158 |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
159 (defcustom recentf-load-hook nil |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
160 "*Normal hook run at end of loading the `recentf' package." |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
161 :group 'recentf |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
162 :type 'hook) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
163 |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
164 ;;;###autoload |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
165 (defun recentf-mode (&optional arg) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
166 "Toggle recentf mode. |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
167 With prefix ARG, turn recentf mode on if and only if ARG is positive. |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
168 Returns the new status of recentf mode (non-nil means on). |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
169 |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
170 When recentf mode is enabled, it maintains a menu for visiting files that |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
171 were operated on recently." |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
172 (interactive "P") |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
173 (when window-system |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
174 (let ((on-p (if arg |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
175 (> (prefix-numeric-value arg) 0) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
176 (not recentf-mode)))) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
177 (if on-p |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
178 (unless recentf-initialized-p |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
179 (setq recentf-initialized-p t) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
180 (if (file-readable-p recentf-save-file) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
181 (load-file recentf-save-file)) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
182 (setq recentf-update-menu-p t) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
183 (add-hook 'find-file-hooks 'recentf-add-file-hook) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
184 (add-hook 'write-file-hooks 'recentf-add-file-hook) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
185 ;; (add-hook 'activate-menubar-hook 'recentf-update-menu-hook) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
186 (add-hook 'menu-bar-update-hook 'recentf-update-menu-hook) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
187 (add-hook 'kill-emacs-hook 'recentf-save-list)) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
188 (when recentf-initialized-p |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
189 (setq recentf-initialized-p nil) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
190 (recentf-save-list) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
191 (easy-menu-remove-item nil recentf-menu-path recentf-menu-title) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
192 (remove-hook 'find-file-hooks 'recentf-add-file-hook) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
193 (remove-hook 'write-file-hooks 'recentf-add-file-hook) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
194 ;; (remove-hook 'activate-menubar-hook 'recentf-update-menu-hook) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
195 (remove-hook 'menu-bar-update-hook 'recentf-update-menu-hook) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
196 (remove-hook 'kill-emacs-hook 'recentf-save-list))) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
197 (setq recentf-mode on-p)))) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
198 |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
199 (defun recentf-add-file-hook () |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
200 "Insert the name of the file just opened or written into `recentf-list'." |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
201 (and buffer-file-name (recentf-add-file buffer-file-name)) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
202 nil) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
203 |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
204 (defun recentf-remove-file-hook () |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
205 "When a buffer is killed remove a non readable file from `recentf-list'." |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
206 (and buffer-file-name (recentf-remove-if-non-readable buffer-file-name)) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
207 nil) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
208 |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
209 (defun recentf-update-menu-hook () |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
210 "Update the recentf menu from the current `recentf-list'." |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
211 (when recentf-update-menu-p |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
212 (condition-case nil |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
213 (progn |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
214 (easy-menu-change recentf-menu-path |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
215 recentf-menu-title |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
216 (recentf-make-menu-items) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
217 recentf-menu-before) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
218 (setq recentf-update-menu-p nil)) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
219 (error nil)))) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
220 |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
221 ;;;###autoload |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
222 (defun recentf-save-list () |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
223 "Save the current `recentf-list' to the file `recentf-save-file'." |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
224 (interactive) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
225 (let ((saved-list (recentf-elements recentf-max-saved-items))) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
226 (with-temp-buffer |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
227 (erase-buffer) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
228 (insert (format recentf-save-file-header (current-time-string))) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
229 (insert "(setq recentf-list\n '(\n") |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
230 (mapcar '(lambda (e) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
231 (insert (format " %S\n" e))) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
232 saved-list) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
233 (insert " ))") |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
234 (if (file-writable-p recentf-save-file) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
235 (write-region (point-min) (point-max) recentf-save-file)) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
236 (kill-buffer (current-buffer)))) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
237 nil) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
238 |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
239 ;;;###autoload |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
240 (defun recentf-cleanup () |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
241 "Remove all non-readable files from `recentf-list'." |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
242 (interactive) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
243 (setq recentf-list (delq nil (mapcar '(lambda (f) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
244 (and (file-readable-p f) f)) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
245 recentf-list))) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
246 (setq recentf-update-menu-p t)) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
247 |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
248 (defvar recentf-menu-items-for-commands |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
249 (list ["Cleanup list" recentf-cleanup t] |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
250 ["Save list now" recentf-save-list t] |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
251 (vector (format "Recentf Options...") |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
252 '(customize-group "recentf") t)) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
253 "List of menu items for recentf commands.") |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
254 |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
255 (defun recentf-make-menu-items () |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
256 "Make menu items from `recentf-list'." |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
257 (let ((file-items |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
258 (mapcar '(lambda (entry) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
259 (vector entry (list recentf-menu-action entry) t)) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
260 (funcall (or recentf-menu-filter 'identity) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
261 (recentf-elements recentf-max-menu-items))))) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
262 (append (or file-items (list ["No files" t nil])) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
263 (and recentf-menu-append-commands-p |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
264 (cons ["---" nil nil] |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
265 recentf-menu-items-for-commands))))) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
266 |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
267 (defun recentf-add-file (filename) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
268 "Add or move FILENAME at the beginning of `recentf-list'. |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
269 Does nothing if FILENAME matches one of the `recentf-exclude' regexps." |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
270 (when (recentf-include-p filename) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
271 (setq recentf-list (cons filename (delete filename recentf-list))) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
272 (setq recentf-update-menu-p t))) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
273 |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
274 (defun recentf-remove-if-non-readable (filename) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
275 "Remove FILENAME from `recentf-list' if not readable." |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
276 (unless (file-readable-p filename) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
277 (setq recentf-list (delete filename recentf-list)) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
278 (setq recentf-update-menu-p t))) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
279 |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
280 (defun recentf-find-file (filename) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
281 "Edit file FILENAME using `find-file'. |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
282 If FILENAME is not readable it is removed from `recentf-list'." |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
283 (if (file-readable-p filename) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
284 (find-file filename) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
285 (progn |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
286 (message "File `%s' not found." filename) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
287 (setq recentf-list (delete filename recentf-list)) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
288 (setq recentf-update-menu-p t)))) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
289 |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
290 (defun recentf-include-p (filename) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
291 "Return t if FILENAME matches none of the `recentf-exclude' regexps." |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
292 (let ((rl recentf-exclude)) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
293 (while (and rl (not (string-match (car rl) filename))) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
294 (setq rl (cdr rl))) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
295 (null rl))) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
296 |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
297 (defun recentf-elements (n) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
298 "Return a list of the first N elements of `recentf-list'." |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
299 (let ((lh nil) (l recentf-list)) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
300 (while (and l (> n 0)) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
301 (setq lh (cons (car l) lh)) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
302 (setq n (1- n)) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
303 (setq l (cdr l))) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
304 (nreverse lh))) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
305 |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
306 (defun recentf-sort-ascending (l) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
307 "Sort the list of strings L in ascending order." |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
308 (sort l '(lambda (e1 e2) (string-lessp e1 e2)))) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
309 |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
310 (defun recentf-sort-descending (l) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
311 "Sort the list of strings L in descending order." |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
312 (sort l '(lambda (e1 e2) (string-lessp e2 e1)))) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
313 |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
314 (provide 'recentf) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
315 |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
316 (run-hooks 'recentf-load-hook) |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
317 |
40b9e5591aac
New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
318 ;;; recentf.el ends here. |