Mercurial > emacs
annotate lisp/recentf.el @ 65842:6b4c115f4d14
(outline-mark-subtree): Activate the mark.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Tue, 04 Oct 2005 20:54:26 +0000 |
parents | 4bbd95905599 |
children | e0cf1ed38749 2a679c81f552 b1c1fc853d2f |
rev | line source |
---|---|
38436
b174db545cfd
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
35971
diff
changeset
|
1 ;;; recentf.el --- setup a menu of recently opened files |
30416 | 2 |
64762
41bb365f41c4
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64664
diff
changeset
|
3 ;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, |
41bb365f41c4
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64664
diff
changeset
|
4 ;; 2005 Free Software Foundation, Inc. |
30416 | 5 |
6 ;; Author: David Ponce <david@dponce.com> | |
7 ;; Created: July 19 1999 | |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
8 ;; Keywords: files |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
9 |
30416 | 10 ;; This file is part of GNU Emacs. |
11 | |
12 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
13 ;; it under the terms of the GNU General Public License as published |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
14 ;; by the Free Software Foundation; either version 2, or (at your |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
15 ;; option) any later version. |
30416 | 16 |
17 ;; GNU Emacs is distributed in the hope that it will be useful, | |
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 ;; GNU General Public License for more details. | |
21 | |
22 ;; You should have received a copy of the GNU General Public License | |
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
64091 | 24 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
25 ;; Boston, MA 02110-1301, USA. | |
30416 | 26 |
27 ;;; Commentary: | |
28 | |
29 ;; This package maintains a menu for visiting files that were operated | |
63781
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
30 ;; on recently. When enabled a new "Open Recent" sub menu is |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
31 ;; displayed in the "Files" menu. The recent files list is |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
32 ;; automatically saved across Emacs sessions. You can customize the |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
33 ;; number of recent files displayed, the location of the menu and |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
34 ;; others options (see the source code for details). |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
35 |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
36 ;;; History: |
30416 | 37 ;; |
38 | |
39 ;;; Code: | |
40 (require 'easymenu) | |
63781
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
41 (require 'tree-widget) |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
42 (require 'timer) |
30416 | 43 |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
44 ;;; Internal data |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
45 ;; |
30416 | 46 (defvar recentf-list nil |
47 "List of recently opened files.") | |
48 | |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
49 (defvar recentf-data-cache nil |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
50 "Cache of data used to build the recentf menu. |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
51 The menu is rebuilt when this data has changed.") |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
52 |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
53 ;;; Customization |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
54 ;; |
30416 | 55 (defgroup recentf nil |
56 "Maintain a menu of recently opened files." | |
57 :version "21.1" | |
58 :group 'files) | |
59 | |
60 (defgroup recentf-filters nil | |
61 "Group to customize recentf menu filters. | |
62 You should define the options of your own filters in this group." | |
63 :group 'recentf) | |
64 | |
65 (defcustom recentf-max-saved-items 20 | |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
66 "*Maximum number of items of the recent list that will be saved. |
64664
3161d6027fd7
(recentf-menu-append-commands-p): Declare with `define-obsolete-variable-alias'.
Juanma Barranquero <lekktu@gmail.com>
parents:
64091
diff
changeset
|
67 A nil value means to save the whole list. |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
68 See the command `recentf-save-list'." |
30416 | 69 :group 'recentf |
70 :type 'integer) | |
71 | |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
72 (defcustom recentf-save-file "~/.recentf" |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
73 "*File to save the recent list into." |
30416 | 74 :group 'recentf |
75 :type 'file) | |
76 | |
65525
f68d6281086a
(recentf-save-file-modes): New option.
David Ponce <david@dponce.com>
parents:
65368
diff
changeset
|
77 (defcustom recentf-save-file-modes 384 ;; 0600 |
f68d6281086a
(recentf-save-file-modes): New option.
David Ponce <david@dponce.com>
parents:
65368
diff
changeset
|
78 "Mode bits of recentf save file, as an integer, or nil. |
f68d6281086a
(recentf-save-file-modes): New option.
David Ponce <david@dponce.com>
parents:
65368
diff
changeset
|
79 If non-nil, after writing `recentf-save-file', set its mode bits to |
f68d6281086a
(recentf-save-file-modes): New option.
David Ponce <david@dponce.com>
parents:
65368
diff
changeset
|
80 this value. By default give R/W access only to the user who owns that |
f68d6281086a
(recentf-save-file-modes): New option.
David Ponce <david@dponce.com>
parents:
65368
diff
changeset
|
81 file. See also the function `set-file-modes'." |
f68d6281086a
(recentf-save-file-modes): New option.
David Ponce <david@dponce.com>
parents:
65368
diff
changeset
|
82 :group 'recentf |
f68d6281086a
(recentf-save-file-modes): New option.
David Ponce <david@dponce.com>
parents:
65368
diff
changeset
|
83 :type '(choice (const :tag "Don't change" nil) |
f68d6281086a
(recentf-save-file-modes): New option.
David Ponce <david@dponce.com>
parents:
65368
diff
changeset
|
84 integer)) |
f68d6281086a
(recentf-save-file-modes): New option.
David Ponce <david@dponce.com>
parents:
65368
diff
changeset
|
85 |
30416 | 86 (defcustom recentf-exclude nil |
62916 | 87 "*List of regexps and predicates for filenames excluded from the recent list. |
52509
5308684cd360
David Ponce <david@dponce.com>
Glenn Morris <rgm@gnu.org>
parents:
52468
diff
changeset
|
88 When a filename matches any of the regexps or satisfies any of the |
5308684cd360
David Ponce <david@dponce.com>
Glenn Morris <rgm@gnu.org>
parents:
52468
diff
changeset
|
89 predicates it is excluded from the recent list. |
5308684cd360
David Ponce <david@dponce.com>
Glenn Morris <rgm@gnu.org>
parents:
52468
diff
changeset
|
90 A predicate is a function that is passed a filename to check and that |
5308684cd360
David Ponce <david@dponce.com>
Glenn Morris <rgm@gnu.org>
parents:
52468
diff
changeset
|
91 must return non-nil to exclude it." |
30416 | 92 :group 'recentf |
52509
5308684cd360
David Ponce <david@dponce.com>
Glenn Morris <rgm@gnu.org>
parents:
52468
diff
changeset
|
93 :type '(repeat (choice regexp function))) |
30416 | 94 |
60844
5bb0c1e05b1b
(recentf-keep): New option.
David Ponce <david@dponce.com>
parents:
60740
diff
changeset
|
95 (defcustom recentf-keep |
5bb0c1e05b1b
(recentf-keep): New option.
David Ponce <david@dponce.com>
parents:
60740
diff
changeset
|
96 '(file-readable-p) |
5bb0c1e05b1b
(recentf-keep): New option.
David Ponce <david@dponce.com>
parents:
60740
diff
changeset
|
97 "*List of regexps and predicates for filenames kept in the recent list. |
5bb0c1e05b1b
(recentf-keep): New option.
David Ponce <david@dponce.com>
parents:
60740
diff
changeset
|
98 Regexps and predicates are tried in the specified order. |
5bb0c1e05b1b
(recentf-keep): New option.
David Ponce <david@dponce.com>
parents:
60740
diff
changeset
|
99 When nil all filenames are kept in the recent list. |
5bb0c1e05b1b
(recentf-keep): New option.
David Ponce <david@dponce.com>
parents:
60740
diff
changeset
|
100 When a filename matches any of the regexps or satisfies any of the |
5bb0c1e05b1b
(recentf-keep): New option.
David Ponce <david@dponce.com>
parents:
60740
diff
changeset
|
101 predicates it is kept in the recent list. |
5bb0c1e05b1b
(recentf-keep): New option.
David Ponce <david@dponce.com>
parents:
60740
diff
changeset
|
102 The default is to keep readable files. |
5bb0c1e05b1b
(recentf-keep): New option.
David Ponce <david@dponce.com>
parents:
60740
diff
changeset
|
103 A predicate is a function that is passed a filename to check and that |
5bb0c1e05b1b
(recentf-keep): New option.
David Ponce <david@dponce.com>
parents:
60740
diff
changeset
|
104 must return non-nil to keep it. For example, you can add the |
5bb0c1e05b1b
(recentf-keep): New option.
David Ponce <david@dponce.com>
parents:
60740
diff
changeset
|
105 `file-remote-p' predicate in front of this list to keep remote file |
5bb0c1e05b1b
(recentf-keep): New option.
David Ponce <david@dponce.com>
parents:
60740
diff
changeset
|
106 names in the recent list without checking their readability through a |
5bb0c1e05b1b
(recentf-keep): New option.
David Ponce <david@dponce.com>
parents:
60740
diff
changeset
|
107 remote access." |
5bb0c1e05b1b
(recentf-keep): New option.
David Ponce <david@dponce.com>
parents:
60740
diff
changeset
|
108 :group 'recentf |
5bb0c1e05b1b
(recentf-keep): New option.
David Ponce <david@dponce.com>
parents:
60740
diff
changeset
|
109 :type '(repeat (choice regexp function))) |
5bb0c1e05b1b
(recentf-keep): New option.
David Ponce <david@dponce.com>
parents:
60740
diff
changeset
|
110 |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
111 (defun recentf-menu-customization-changed (variable value) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
112 "Function called when the recentf menu customization has changed. |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
113 Set VARIABLE with VALUE, and force a rebuild of the recentf menu." |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
114 (when (featurep 'recentf) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
115 ;; Unavailable until recentf has been loaded. |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
116 (recentf-clear-data)) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
117 (set-default variable value)) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
118 |
30416 | 119 (defcustom recentf-menu-title "Open Recent" |
120 "*Name of the recentf menu." | |
121 :group 'recentf | |
122 :type 'string | |
123 :set 'recentf-menu-customization-changed) | |
124 | |
57993
8e7d8d382255
(recentf-menu-path): Use menu item name.
David Ponce <david@dponce.com>
parents:
57451
diff
changeset
|
125 (defcustom recentf-menu-path '("File") |
30416 | 126 "*Path where to add the recentf menu. |
52468
de4ce9c67474
Ensure that recentf correctly update the menu bar:
Eli Zaretskii <eliz@gnu.org>
parents:
52401
diff
changeset
|
127 If nil add it at top level (see also `easy-menu-add-item')." |
30416 | 128 :group 'recentf |
129 :type '(choice (const :tag "Top Level" nil) | |
130 (sexp :tag "Menu Path")) | |
131 :set 'recentf-menu-customization-changed) | |
132 | |
44915
ea21866100eb
(recentf-menu-before): Use string to specify path in the menu.
Pavel Janík <Pavel@Janik.cz>
parents:
42205
diff
changeset
|
133 (defcustom recentf-menu-before "Open File..." |
30416 | 134 "*Name of the menu before which the recentf menu will be added. |
52468
de4ce9c67474
Ensure that recentf correctly update the menu bar:
Eli Zaretskii <eliz@gnu.org>
parents:
52401
diff
changeset
|
135 If nil add it at end of menu (see also `easy-menu-add-item')." |
30416 | 136 :group 'recentf |
137 :type '(choice (string :tag "Name") | |
138 (const :tag "Last" nil)) | |
139 :set 'recentf-menu-customization-changed) | |
140 | |
60844
5bb0c1e05b1b
(recentf-keep): New option.
David Ponce <david@dponce.com>
parents:
60740
diff
changeset
|
141 (defcustom recentf-menu-action 'find-file |
30416 | 142 "*Function to invoke with a filename item of the recentf menu. |
60844
5bb0c1e05b1b
(recentf-keep): New option.
David Ponce <david@dponce.com>
parents:
60740
diff
changeset
|
143 The default is to call `find-file' to edit the selected file." |
30416 | 144 :group 'recentf |
145 :type 'function | |
146 :set 'recentf-menu-customization-changed) | |
147 | |
148 (defcustom recentf-max-menu-items 10 | |
149 "*Maximum number of items in the recentf menu." | |
150 :group 'recentf | |
151 :type 'integer | |
152 :set 'recentf-menu-customization-changed) | |
153 | |
154 (defcustom recentf-menu-filter nil | |
155 "*Function used to filter files displayed in the recentf menu. | |
64664
3161d6027fd7
(recentf-menu-append-commands-p): Declare with `define-obsolete-variable-alias'.
Juanma Barranquero <lekktu@gmail.com>
parents:
64091
diff
changeset
|
156 A nil value means no filter. The following functions are predefined: |
30416 | 157 |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
158 - `recentf-sort-ascending' |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
159 Sort menu items in ascending order. |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
160 - `recentf-sort-descending' |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
161 Sort menu items in descending order. |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
162 - `recentf-sort-basenames-ascending' |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
163 Sort menu items by filenames sans directory in ascending order. |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
164 - `recentf-sort-basenames-descending' |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
165 Sort menu items by filenames sans directory in descending order. |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
166 - `recentf-sort-directories-ascending' |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
167 Sort menu items by directories in ascending order. |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
168 - `recentf-sort-directories-descending' |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
169 Sort menu items by directories in descending order. |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
170 - `recentf-show-basenames' |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
171 Show filenames sans directory in menu items. |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
172 - `recentf-show-basenames-ascending' |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
173 Show filenames sans directory in ascending order. |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
174 - `recentf-show-basenames-descending' |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
175 Show filenames sans directory in descending order. |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
176 - `recentf-relative-filter' |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
177 Show filenames relative to `default-directory'. |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
178 - `recentf-arrange-by-rule' |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
179 Show sub-menus following user defined rules. |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
180 - `recentf-arrange-by-mode' |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
181 Show a sub-menu for each major mode. |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
182 - `recentf-arrange-by-dir' |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
183 Show a sub-menu for each directory. |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
184 - `recentf-filter-changer' |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
185 Manage a ring of filters. |
30416 | 186 |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
187 The filter function is called with one argument, the list of menu |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
188 elements used to build the menu and must return a new list of menu |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
189 elements (see `recentf-make-menu-element' for menu element form)." |
30416 | 190 :group 'recentf |
49549
99be3a1e2589
Cygwin support patch.
Juanma Barranquero <lekktu@gmail.com>
parents:
44967
diff
changeset
|
191 :type '(radio (const nil) |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
192 (function-item recentf-sort-ascending) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
193 (function-item recentf-sort-descending) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
194 (function-item recentf-sort-basenames-ascending) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
195 (function-item recentf-sort-basenames-descending) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
196 (function-item recentf-sort-directories-ascending) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
197 (function-item recentf-sort-directories-descending) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
198 (function-item recentf-show-basenames) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
199 (function-item recentf-show-basenames-ascending) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
200 (function-item recentf-show-basenames-descending) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
201 (function-item recentf-relative-filter) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
202 (function-item recentf-arrange-by-rule) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
203 (function-item recentf-arrange-by-mode) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
204 (function-item recentf-arrange-by-dir) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
205 (function-item recentf-filter-changer) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
206 function) |
30416 | 207 :set 'recentf-menu-customization-changed) |
208 | |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
209 (defcustom recentf-menu-append-commands-flag t |
64664
3161d6027fd7
(recentf-menu-append-commands-p): Declare with `define-obsolete-variable-alias'.
Juanma Barranquero <lekktu@gmail.com>
parents:
64091
diff
changeset
|
210 "*Non-nil means to append command items to the menu." |
30416 | 211 :group 'recentf |
212 :type 'boolean | |
213 :set 'recentf-menu-customization-changed) | |
214 | |
64664
3161d6027fd7
(recentf-menu-append-commands-p): Declare with `define-obsolete-variable-alias'.
Juanma Barranquero <lekktu@gmail.com>
parents:
64091
diff
changeset
|
215 (define-obsolete-variable-alias 'recentf-menu-append-commands-p |
3161d6027fd7
(recentf-menu-append-commands-p): Declare with `define-obsolete-variable-alias'.
Juanma Barranquero <lekktu@gmail.com>
parents:
64091
diff
changeset
|
216 'recentf-menu-append-commands-flag |
3161d6027fd7
(recentf-menu-append-commands-p): Declare with `define-obsolete-variable-alias'.
Juanma Barranquero <lekktu@gmail.com>
parents:
64091
diff
changeset
|
217 "22.1") |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
218 |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
219 (defcustom recentf-auto-cleanup 'mode |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
220 "*Define when to automatically cleanup the recent list. |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
221 The following values can be set: |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
222 |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
223 - `mode' |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
224 Cleanup when turning the mode on (default). |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
225 - `never' |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
226 Never cleanup the list automatically. |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
227 - A number |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
228 Cleanup each time Emacs has been idle that number of seconds. |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
229 - A time string |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
230 Cleanup at specified time string, for example at \"11:00pm\". |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
231 |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
232 Setting this variable directly does not take effect; |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
233 use \\[customize]. |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
234 |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
235 See also the command `recentf-cleanup', that can be used to manually |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
236 cleanup the list." |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
237 :group 'recentf |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
238 :type '(radio (const :tag "When mode enabled" |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
239 :value mode) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
240 (const :tag "Never" |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
241 :value never) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
242 (number :tag "When idle that seconds" |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
243 :value 300) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
244 (string :tag "At time" |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
245 :value "11:00pm")) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
246 :set (lambda (variable value) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
247 (set-default variable value) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
248 (when (featurep 'recentf) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
249 ;; Unavailable until recentf has been loaded. |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
250 (recentf-auto-cleanup)))) |
30416 | 251 |
52638
2a2c48cb8b59
(recentf-initialize-file-name-history): New defcustom.
Eli Zaretskii <eliz@gnu.org>
parents:
52509
diff
changeset
|
252 (defcustom recentf-initialize-file-name-history t |
64664
3161d6027fd7
(recentf-menu-append-commands-p): Declare with `define-obsolete-variable-alias'.
Juanma Barranquero <lekktu@gmail.com>
parents:
64091
diff
changeset
|
253 "*Non-nil means to initialize `file-name-history' with the recent list. |
52638
2a2c48cb8b59
(recentf-initialize-file-name-history): New defcustom.
Eli Zaretskii <eliz@gnu.org>
parents:
52509
diff
changeset
|
254 If `file-name-history' is not empty, do nothing." |
2a2c48cb8b59
(recentf-initialize-file-name-history): New defcustom.
Eli Zaretskii <eliz@gnu.org>
parents:
52509
diff
changeset
|
255 :group 'recentf |
2a2c48cb8b59
(recentf-initialize-file-name-history): New defcustom.
Eli Zaretskii <eliz@gnu.org>
parents:
52509
diff
changeset
|
256 :type 'boolean) |
2a2c48cb8b59
(recentf-initialize-file-name-history): New defcustom.
Eli Zaretskii <eliz@gnu.org>
parents:
52509
diff
changeset
|
257 |
30416 | 258 (defcustom recentf-load-hook nil |
259 "*Normal hook run at end of loading the `recentf' package." | |
260 :group 'recentf | |
261 :type 'hook) | |
262 | |
65744
4bbd95905599
(recentf-filename-handlers): Rename from
David Ponce <david@dponce.com>
parents:
65525
diff
changeset
|
263 (defcustom recentf-filename-handlers nil |
4bbd95905599
(recentf-filename-handlers): Rename from
David Ponce <david@dponce.com>
parents:
65525
diff
changeset
|
264 "Functions to post process recent file names. |
4bbd95905599
(recentf-filename-handlers): Rename from
David Ponce <david@dponce.com>
parents:
65525
diff
changeset
|
265 They are successively passed a file name to transform it." |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
266 :group 'recentf |
65744
4bbd95905599
(recentf-filename-handlers): Rename from
David Ponce <david@dponce.com>
parents:
65525
diff
changeset
|
267 :type '(choice |
4bbd95905599
(recentf-filename-handlers): Rename from
David Ponce <david@dponce.com>
parents:
65525
diff
changeset
|
268 (const :tag "None" nil) |
4bbd95905599
(recentf-filename-handlers): Rename from
David Ponce <david@dponce.com>
parents:
65525
diff
changeset
|
269 (repeat :tag "Functions" |
4bbd95905599
(recentf-filename-handlers): Rename from
David Ponce <david@dponce.com>
parents:
65525
diff
changeset
|
270 (choice |
4bbd95905599
(recentf-filename-handlers): Rename from
David Ponce <david@dponce.com>
parents:
65525
diff
changeset
|
271 (const file-truename) |
4bbd95905599
(recentf-filename-handlers): Rename from
David Ponce <david@dponce.com>
parents:
65525
diff
changeset
|
272 (const abbreviate-file-name) |
4bbd95905599
(recentf-filename-handlers): Rename from
David Ponce <david@dponce.com>
parents:
65525
diff
changeset
|
273 (function :tag "Other function"))))) |
65365
83aa6efe327f
(recentf-show-file-shortcuts-flag): New option.
David Ponce <david@dponce.com>
parents:
64762
diff
changeset
|
274 |
83aa6efe327f
(recentf-show-file-shortcuts-flag): New option.
David Ponce <david@dponce.com>
parents:
64762
diff
changeset
|
275 (defcustom recentf-show-file-shortcuts-flag t |
83aa6efe327f
(recentf-show-file-shortcuts-flag): New option.
David Ponce <david@dponce.com>
parents:
64762
diff
changeset
|
276 "Whether to show ``[N]'' for the Nth item up to 10. |
83aa6efe327f
(recentf-show-file-shortcuts-flag): New option.
David Ponce <david@dponce.com>
parents:
64762
diff
changeset
|
277 If non-nil, `recentf-open-files' will show labels for keys that can be |
83aa6efe327f
(recentf-show-file-shortcuts-flag): New option.
David Ponce <david@dponce.com>
parents:
64762
diff
changeset
|
278 used as shortcuts to open the Nth file." |
83aa6efe327f
(recentf-show-file-shortcuts-flag): New option.
David Ponce <david@dponce.com>
parents:
64762
diff
changeset
|
279 :group 'recentf |
83aa6efe327f
(recentf-show-file-shortcuts-flag): New option.
David Ponce <david@dponce.com>
parents:
64762
diff
changeset
|
280 :type 'boolean) |
83aa6efe327f
(recentf-show-file-shortcuts-flag): New option.
David Ponce <david@dponce.com>
parents:
64762
diff
changeset
|
281 |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
282 |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
283 ;;; Utilities |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
284 ;; |
30416 | 285 (defconst recentf-case-fold-search |
49549
99be3a1e2589
Cygwin support patch.
Juanma Barranquero <lekktu@gmail.com>
parents:
44967
diff
changeset
|
286 (memq system-type '(vax-vms windows-nt cygwin)) |
30416 | 287 "Non-nil if recentf searches and matches should ignore case.") |
288 | |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
289 (defsubst recentf-string-equal (s1 s2) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
290 "Return non-nil if strings S1 and S2 have identical contents. |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
291 Ignore case if `recentf-case-fold-search' is non-nil." |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
292 (if recentf-case-fold-search |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
293 (string-equal (downcase s1) (downcase s2)) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
294 (string-equal s1 s2))) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
295 |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
296 (defsubst recentf-string-lessp (s1 s2) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
297 "Return non-nil if string S1 is less than S2 in lexicographic order. |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
298 Ignore case if `recentf-case-fold-search' is non-nil." |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
299 (if recentf-case-fold-search |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
300 (string-lessp (downcase s1) (downcase s2)) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
301 (string-lessp s1 s2))) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
302 |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
303 (defun recentf-string-member (elt list) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
304 "Return non-nil if ELT is an element of LIST. |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
305 The value is actually the tail of LIST whose car is ELT. |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
306 ELT must be a string and LIST a list of strings. |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
307 Ignore case if `recentf-case-fold-search' is non-nil." |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
308 (while (and list (not (recentf-string-equal elt (car list)))) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
309 (setq list (cdr list))) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
310 list) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
311 |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
312 (defsubst recentf-trunc-list (l n) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
313 "Return from L the list of its first N elements." |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
314 (let (nl) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
315 (while (and l (> n 0)) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
316 (setq nl (cons (car l) nl) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
317 n (1- n) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
318 l (cdr l))) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
319 (nreverse nl))) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
320 |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
321 (defun recentf-dump-variable (variable &optional limit) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
322 "Insert a \"(setq VARIABLE value)\" in the current buffer. |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
323 When the value of VARIABLE is a list, optional argument LIMIT |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
324 specifies a maximum number of elements to insert. By default insert |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
325 the full list." |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
326 (let ((value (symbol-value variable))) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
327 (if (atom value) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
328 (insert (format "\n(setq %S %S)\n" variable value)) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
329 (when (and (integerp limit) (> limit 0)) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
330 (setq value (recentf-trunc-list value limit))) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
331 (insert (format "\n(setq %S\n '(" variable)) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
332 (dolist (e value) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
333 (insert (format "\n %S" e))) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
334 (insert "\n ))\n")))) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
335 |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
336 (defvar recentf-auto-cleanup-timer nil |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
337 "Timer used to automatically cleanup the recent list. |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
338 See also the option `recentf-auto-cleanup'.") |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
339 |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
340 (defun recentf-auto-cleanup () |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
341 "Automatic cleanup of the recent list." |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
342 (when (timerp recentf-auto-cleanup-timer) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
343 (cancel-timer recentf-auto-cleanup-timer)) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
344 (when recentf-mode |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
345 (setq recentf-auto-cleanup-timer |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
346 (cond |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
347 ((eq 'mode recentf-auto-cleanup) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
348 (recentf-cleanup) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
349 nil) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
350 ((numberp recentf-auto-cleanup) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
351 (run-with-idle-timer |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
352 recentf-auto-cleanup t 'recentf-cleanup)) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
353 ((stringp recentf-auto-cleanup) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
354 (run-at-time |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
355 recentf-auto-cleanup nil 'recentf-cleanup)))))) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
356 |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
357 ;;; File functions |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
358 ;; |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
359 (defsubst recentf-push (filename) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
360 "Push FILENAME into the recent list, if it isn't there yet. |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
361 If it is there yet, move it at the beginning of the list. |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
362 If `recentf-case-fold-search' is non-nil, ignore case when comparing |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
363 filenames." |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
364 (let ((m (recentf-string-member filename recentf-list))) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
365 (and m (setq recentf-list (delq (car m) recentf-list))) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
366 (push filename recentf-list))) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
367 |
65744
4bbd95905599
(recentf-filename-handlers): Rename from
David Ponce <david@dponce.com>
parents:
65525
diff
changeset
|
368 (defun recentf-apply-filename-handlers (name) |
4bbd95905599
(recentf-filename-handlers): Rename from
David Ponce <david@dponce.com>
parents:
65525
diff
changeset
|
369 "Apply `recentf-filename-handlers' to file NAME. |
4bbd95905599
(recentf-filename-handlers): Rename from
David Ponce <david@dponce.com>
parents:
65525
diff
changeset
|
370 Return the transformed file name, or NAME if any handler failed, or |
4bbd95905599
(recentf-filename-handlers): Rename from
David Ponce <david@dponce.com>
parents:
65525
diff
changeset
|
371 returned nil." |
4bbd95905599
(recentf-filename-handlers): Rename from
David Ponce <david@dponce.com>
parents:
65525
diff
changeset
|
372 (or (condition-case nil |
4bbd95905599
(recentf-filename-handlers): Rename from
David Ponce <david@dponce.com>
parents:
65525
diff
changeset
|
373 (let ((handlers recentf-filename-handlers) |
4bbd95905599
(recentf-filename-handlers): Rename from
David Ponce <david@dponce.com>
parents:
65525
diff
changeset
|
374 (filename name)) |
4bbd95905599
(recentf-filename-handlers): Rename from
David Ponce <david@dponce.com>
parents:
65525
diff
changeset
|
375 (while (and filename handlers) |
4bbd95905599
(recentf-filename-handlers): Rename from
David Ponce <david@dponce.com>
parents:
65525
diff
changeset
|
376 (setq filename (funcall (car handlers) filename) |
4bbd95905599
(recentf-filename-handlers): Rename from
David Ponce <david@dponce.com>
parents:
65525
diff
changeset
|
377 handlers (cdr handlers))) |
4bbd95905599
(recentf-filename-handlers): Rename from
David Ponce <david@dponce.com>
parents:
65525
diff
changeset
|
378 filename) |
4bbd95905599
(recentf-filename-handlers): Rename from
David Ponce <david@dponce.com>
parents:
65525
diff
changeset
|
379 (error nil)) |
4bbd95905599
(recentf-filename-handlers): Rename from
David Ponce <david@dponce.com>
parents:
65525
diff
changeset
|
380 name)) |
4bbd95905599
(recentf-filename-handlers): Rename from
David Ponce <david@dponce.com>
parents:
65525
diff
changeset
|
381 |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
382 (defsubst recentf-expand-file-name (name) |
65744
4bbd95905599
(recentf-filename-handlers): Rename from
David Ponce <david@dponce.com>
parents:
65525
diff
changeset
|
383 "Convert file NAME to absolute, and canonicalize it. |
4bbd95905599
(recentf-filename-handlers): Rename from
David Ponce <david@dponce.com>
parents:
65525
diff
changeset
|
384 NAME is first passed to the function `expand-file-name', then to |
4bbd95905599
(recentf-filename-handlers): Rename from
David Ponce <david@dponce.com>
parents:
65525
diff
changeset
|
385 `recentf-filename-handlers' to post process it." |
4bbd95905599
(recentf-filename-handlers): Rename from
David Ponce <david@dponce.com>
parents:
65525
diff
changeset
|
386 (recentf-apply-filename-handlers (expand-file-name name))) |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
387 |
30416 | 388 (defun recentf-include-p (filename) |
52509
5308684cd360
David Ponce <david@dponce.com>
Glenn Morris <rgm@gnu.org>
parents:
52468
diff
changeset
|
389 "Return non-nil if FILENAME should be included in the recent list. |
5308684cd360
David Ponce <david@dponce.com>
Glenn Morris <rgm@gnu.org>
parents:
52468
diff
changeset
|
390 That is, if it doesn't match any of the `recentf-exclude' checks." |
30416 | 391 (let ((case-fold-search recentf-case-fold-search) |
52509
5308684cd360
David Ponce <david@dponce.com>
Glenn Morris <rgm@gnu.org>
parents:
52468
diff
changeset
|
392 (checks recentf-exclude) |
60844
5bb0c1e05b1b
(recentf-keep): New option.
David Ponce <david@dponce.com>
parents:
60740
diff
changeset
|
393 (keepit t)) |
52509
5308684cd360
David Ponce <david@dponce.com>
Glenn Morris <rgm@gnu.org>
parents:
52468
diff
changeset
|
394 (while (and checks keepit) |
60844
5bb0c1e05b1b
(recentf-keep): New option.
David Ponce <david@dponce.com>
parents:
60740
diff
changeset
|
395 (setq keepit (condition-case nil |
5bb0c1e05b1b
(recentf-keep): New option.
David Ponce <david@dponce.com>
parents:
60740
diff
changeset
|
396 (not (if (stringp (car checks)) |
5bb0c1e05b1b
(recentf-keep): New option.
David Ponce <david@dponce.com>
parents:
60740
diff
changeset
|
397 ;; A regexp |
5bb0c1e05b1b
(recentf-keep): New option.
David Ponce <david@dponce.com>
parents:
60740
diff
changeset
|
398 (string-match (car checks) filename) |
5bb0c1e05b1b
(recentf-keep): New option.
David Ponce <david@dponce.com>
parents:
60740
diff
changeset
|
399 ;; A predicate |
5bb0c1e05b1b
(recentf-keep): New option.
David Ponce <david@dponce.com>
parents:
60740
diff
changeset
|
400 (funcall (car checks) filename))) |
5bb0c1e05b1b
(recentf-keep): New option.
David Ponce <david@dponce.com>
parents:
60740
diff
changeset
|
401 (error nil)) |
5bb0c1e05b1b
(recentf-keep): New option.
David Ponce <david@dponce.com>
parents:
60740
diff
changeset
|
402 checks (cdr checks))) |
5bb0c1e05b1b
(recentf-keep): New option.
David Ponce <david@dponce.com>
parents:
60740
diff
changeset
|
403 keepit)) |
5bb0c1e05b1b
(recentf-keep): New option.
David Ponce <david@dponce.com>
parents:
60740
diff
changeset
|
404 |
5bb0c1e05b1b
(recentf-keep): New option.
David Ponce <david@dponce.com>
parents:
60740
diff
changeset
|
405 (defun recentf-keep-p (filename) |
5bb0c1e05b1b
(recentf-keep): New option.
David Ponce <david@dponce.com>
parents:
60740
diff
changeset
|
406 "Return non-nil if FILENAME should be kept in the recent list. |
5bb0c1e05b1b
(recentf-keep): New option.
David Ponce <david@dponce.com>
parents:
60740
diff
changeset
|
407 That is, if it matches any of the `recentf-keep' checks." |
5bb0c1e05b1b
(recentf-keep): New option.
David Ponce <david@dponce.com>
parents:
60740
diff
changeset
|
408 (let* ((case-fold-search recentf-case-fold-search) |
5bb0c1e05b1b
(recentf-keep): New option.
David Ponce <david@dponce.com>
parents:
60740
diff
changeset
|
409 (checks recentf-keep) |
5bb0c1e05b1b
(recentf-keep): New option.
David Ponce <david@dponce.com>
parents:
60740
diff
changeset
|
410 (keepit (null checks))) |
5bb0c1e05b1b
(recentf-keep): New option.
David Ponce <david@dponce.com>
parents:
60740
diff
changeset
|
411 (while (and checks (not keepit)) |
5bb0c1e05b1b
(recentf-keep): New option.
David Ponce <david@dponce.com>
parents:
60740
diff
changeset
|
412 (setq keepit (condition-case nil |
5bb0c1e05b1b
(recentf-keep): New option.
David Ponce <david@dponce.com>
parents:
60740
diff
changeset
|
413 (if (stringp (car checks)) |
5bb0c1e05b1b
(recentf-keep): New option.
David Ponce <david@dponce.com>
parents:
60740
diff
changeset
|
414 ;; A regexp |
5bb0c1e05b1b
(recentf-keep): New option.
David Ponce <david@dponce.com>
parents:
60740
diff
changeset
|
415 (string-match (car checks) filename) |
5bb0c1e05b1b
(recentf-keep): New option.
David Ponce <david@dponce.com>
parents:
60740
diff
changeset
|
416 ;; A predicate |
5bb0c1e05b1b
(recentf-keep): New option.
David Ponce <david@dponce.com>
parents:
60740
diff
changeset
|
417 (funcall (car checks) filename)) |
5bb0c1e05b1b
(recentf-keep): New option.
David Ponce <david@dponce.com>
parents:
60740
diff
changeset
|
418 (error nil)) |
5bb0c1e05b1b
(recentf-keep): New option.
David Ponce <david@dponce.com>
parents:
60740
diff
changeset
|
419 checks (cdr checks))) |
52509
5308684cd360
David Ponce <david@dponce.com>
Glenn Morris <rgm@gnu.org>
parents:
52468
diff
changeset
|
420 keepit)) |
30416 | 421 |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
422 (defsubst recentf-add-file (filename) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
423 "Add or move FILENAME at the beginning of the recent list. |
60844
5bb0c1e05b1b
(recentf-keep): New option.
David Ponce <david@dponce.com>
parents:
60740
diff
changeset
|
424 Does nothing if the name satisfies any of the `recentf-exclude' |
5bb0c1e05b1b
(recentf-keep): New option.
David Ponce <david@dponce.com>
parents:
60740
diff
changeset
|
425 regexps or predicates." |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
426 (setq filename (recentf-expand-file-name filename)) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
427 (when (recentf-include-p filename) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
428 (recentf-push filename))) |
30416 | 429 |
60844
5bb0c1e05b1b
(recentf-keep): New option.
David Ponce <david@dponce.com>
parents:
60740
diff
changeset
|
430 (defsubst recentf-remove-if-non-kept (filename) |
5bb0c1e05b1b
(recentf-keep): New option.
David Ponce <david@dponce.com>
parents:
60740
diff
changeset
|
431 "Remove FILENAME from the recent list, if file is not kept. |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
432 Return non-nil if FILENAME has been removed." |
60844
5bb0c1e05b1b
(recentf-keep): New option.
David Ponce <david@dponce.com>
parents:
60740
diff
changeset
|
433 (unless (recentf-keep-p filename) |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
434 (let ((m (recentf-string-member |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
435 (recentf-expand-file-name filename) recentf-list))) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
436 (and m (setq recentf-list (delq (car m) recentf-list)))))) |
30416 | 437 |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
438 (defsubst recentf-directory-compare (f1 f2) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
439 "Compare absolute filenames F1 and F2. |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
440 First compare directories, then filenames sans directory. |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
441 Return non-nil if F1 is less than F2." |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
442 (let ((d1 (file-name-directory f1)) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
443 (d2 (file-name-directory f2))) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
444 (if (recentf-string-equal d1 d2) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
445 (recentf-string-lessp (file-name-nondirectory f1) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
446 (file-name-nondirectory f2)) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
447 (recentf-string-lessp d1 d2)))) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
448 |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
449 ;;; Menu building |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
450 ;; |
30416 | 451 (defvar recentf-menu-items-for-commands |
65744
4bbd95905599
(recentf-filename-handlers): Rename from
David Ponce <david@dponce.com>
parents:
65525
diff
changeset
|
452 (list |
4bbd95905599
(recentf-filename-handlers): Rename from
David Ponce <david@dponce.com>
parents:
65525
diff
changeset
|
453 ["Cleanup list" |
4bbd95905599
(recentf-filename-handlers): Rename from
David Ponce <david@dponce.com>
parents:
65525
diff
changeset
|
454 recentf-cleanup |
4bbd95905599
(recentf-filename-handlers): Rename from
David Ponce <david@dponce.com>
parents:
65525
diff
changeset
|
455 :help "Remove duplicates, and obsoletes files from the recent list" |
4bbd95905599
(recentf-filename-handlers): Rename from
David Ponce <david@dponce.com>
parents:
65525
diff
changeset
|
456 :active t] |
4bbd95905599
(recentf-filename-handlers): Rename from
David Ponce <david@dponce.com>
parents:
65525
diff
changeset
|
457 ["Edit list..." |
4bbd95905599
(recentf-filename-handlers): Rename from
David Ponce <david@dponce.com>
parents:
65525
diff
changeset
|
458 recentf-edit-list |
4bbd95905599
(recentf-filename-handlers): Rename from
David Ponce <david@dponce.com>
parents:
65525
diff
changeset
|
459 :help "Manually remove files from the recent list" |
4bbd95905599
(recentf-filename-handlers): Rename from
David Ponce <david@dponce.com>
parents:
65525
diff
changeset
|
460 :active t] |
4bbd95905599
(recentf-filename-handlers): Rename from
David Ponce <david@dponce.com>
parents:
65525
diff
changeset
|
461 ["Save list now" |
4bbd95905599
(recentf-filename-handlers): Rename from
David Ponce <david@dponce.com>
parents:
65525
diff
changeset
|
462 recentf-save-list |
4bbd95905599
(recentf-filename-handlers): Rename from
David Ponce <david@dponce.com>
parents:
65525
diff
changeset
|
463 :help "Save the list of recently opened files now" |
4bbd95905599
(recentf-filename-handlers): Rename from
David Ponce <david@dponce.com>
parents:
65525
diff
changeset
|
464 :active t] |
4bbd95905599
(recentf-filename-handlers): Rename from
David Ponce <david@dponce.com>
parents:
65525
diff
changeset
|
465 ["Options..." |
4bbd95905599
(recentf-filename-handlers): Rename from
David Ponce <david@dponce.com>
parents:
65525
diff
changeset
|
466 (customize-group "recentf") |
4bbd95905599
(recentf-filename-handlers): Rename from
David Ponce <david@dponce.com>
parents:
65525
diff
changeset
|
467 :help "Customize recently opened files menu and options" |
4bbd95905599
(recentf-filename-handlers): Rename from
David Ponce <david@dponce.com>
parents:
65525
diff
changeset
|
468 :active t] |
4bbd95905599
(recentf-filename-handlers): Rename from
David Ponce <david@dponce.com>
parents:
65525
diff
changeset
|
469 ) |
30416 | 470 "List of menu items for recentf commands.") |
471 | |
472 (defvar recentf-menu-filter-commands nil | |
473 "This variable can be used by menu filters to setup their own command menu. | |
474 If non-nil it must contain a list of valid menu-items to be appended | |
475 to the recent file list part of the menu. Before calling a menu | |
476 filter function this variable is reset to nil.") | |
477 | |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
478 (defsubst recentf-elements (n) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
479 "Return a list of the first N elements of the recent list." |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
480 (recentf-trunc-list recentf-list n)) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
481 |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
482 (defsubst recentf-make-menu-element (menu-item menu-value) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
483 "Create a new menu-element. |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
484 A menu element is a pair (MENU-ITEM . MENU-VALUE), where MENU-ITEM is |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
485 the menu item string displayed. MENU-VALUE is the file to be open |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
486 when the corresponding MENU-ITEM is selected. Or it is a |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
487 pair (SUB-MENU-TITLE . MENU-ELEMENTS) where SUB-MENU-TITLE is a |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
488 sub-menu title and MENU-ELEMENTS is the list of menu elements in the |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
489 sub-menu." |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
490 (cons menu-item menu-value)) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
491 |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
492 (defsubst recentf-menu-element-item (e) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
493 "Return the item part of the menu-element E." |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
494 (car e)) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
495 |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
496 (defsubst recentf-menu-element-value (e) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
497 "Return the value part of the menu-element E." |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
498 (cdr e)) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
499 |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
500 (defsubst recentf-set-menu-element-item (e item) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
501 "Change the item part of menu-element E to ITEM." |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
502 (setcar e item)) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
503 |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
504 (defsubst recentf-set-menu-element-value (e value) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
505 "Change the value part of menu-element E to VALUE." |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
506 (setcdr e value)) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
507 |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
508 (defsubst recentf-sub-menu-element-p (e) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
509 "Return non-nil if menu-element E defines a sub-menu." |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
510 (consp (recentf-menu-element-value e))) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
511 |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
512 (defsubst recentf-make-default-menu-element (file) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
513 "Make a new default menu element with FILE. |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
514 This a menu element (FILE . FILE)." |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
515 (recentf-make-menu-element file file)) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
516 |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
517 (defsubst recentf-menu-elements (n) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
518 "Return a list of the first N default menu elements from the recent list. |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
519 See also `recentf-make-default-menu-element'." |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
520 (mapcar 'recentf-make-default-menu-element |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
521 (recentf-elements n))) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
522 |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
523 (defun recentf-apply-menu-filter (filter l) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
524 "Apply function FILTER to the list of menu-elements L. |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
525 It takes care of sub-menu elements in L and recursively apply FILTER |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
526 to them. It is guaranteed that FILTER receives only a list of single |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
527 menu-elements (no sub-menu)." |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
528 (if (and l (functionp filter)) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
529 (let ((case-fold-search recentf-case-fold-search) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
530 elts others) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
531 ;; split L into two sub-listes, one of sub-menus elements and |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
532 ;; another of single menu elements. |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
533 (dolist (elt l) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
534 (if (recentf-sub-menu-element-p elt) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
535 (push elt elts) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
536 (push elt others))) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
537 ;; Apply FILTER to single elements. |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
538 (when others |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
539 (setq others (funcall filter (nreverse others)))) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
540 ;; Apply FILTER to sub-menu elements. |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
541 (setq l nil) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
542 (dolist (elt elts) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
543 (recentf-set-menu-element-value |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
544 elt (recentf-apply-menu-filter |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
545 filter (recentf-menu-element-value elt))) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
546 (push elt l)) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
547 ;; Return the new filtered menu element list. |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
548 (nconc l others)) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
549 l)) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
550 |
30416 | 551 (defun recentf-make-menu-items () |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
552 "Make menu items from the recent list." |
30416 | 553 (setq recentf-menu-filter-commands nil) |
554 (let ((file-items | |
555 (mapcar 'recentf-make-menu-item | |
556 (recentf-apply-menu-filter | |
557 recentf-menu-filter | |
558 (recentf-menu-elements recentf-max-menu-items))))) | |
33770
4408efb1d628
(recentf-menu-items-for-commands)
Gerd Moellmann <gerd@gnu.org>
parents:
33196
diff
changeset
|
559 (append (or file-items (list ["No files" t |
4408efb1d628
(recentf-menu-items-for-commands)
Gerd Moellmann <gerd@gnu.org>
parents:
33196
diff
changeset
|
560 :help "No recent file to open" |
4408efb1d628
(recentf-menu-items-for-commands)
Gerd Moellmann <gerd@gnu.org>
parents:
33196
diff
changeset
|
561 :active nil])) |
30416 | 562 (and (< recentf-max-menu-items (length recentf-list)) |
33770
4408efb1d628
(recentf-menu-items-for-commands)
Gerd Moellmann <gerd@gnu.org>
parents:
33196
diff
changeset
|
563 (list ["More..." recentf-open-more-files |
4408efb1d628
(recentf-menu-items-for-commands)
Gerd Moellmann <gerd@gnu.org>
parents:
33196
diff
changeset
|
564 :help "Open files that are not in the menu" |
4408efb1d628
(recentf-menu-items-for-commands)
Gerd Moellmann <gerd@gnu.org>
parents:
33196
diff
changeset
|
565 :active t])) |
30416 | 566 (and recentf-menu-filter-commands |
567 (cons "---" | |
568 recentf-menu-filter-commands)) | |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
569 (and recentf-menu-append-commands-flag |
30416 | 570 (cons "---" |
571 recentf-menu-items-for-commands))))) | |
572 | |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
573 (defsubst recentf-make-menu-item (elt) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
574 "Make a menu item from menu element ELT." |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
575 (let ((item (recentf-menu-element-item elt)) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
576 (value (recentf-menu-element-value elt))) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
577 (if (recentf-sub-menu-element-p elt) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
578 (cons item (mapcar 'recentf-make-menu-item value)) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
579 (vector item (list recentf-menu-action value) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
580 :help (concat "Open " value) |
33770
4408efb1d628
(recentf-menu-items-for-commands)
Gerd Moellmann <gerd@gnu.org>
parents:
33196
diff
changeset
|
581 :active t)))) |
30416 | 582 |
52468
de4ce9c67474
Ensure that recentf correctly update the menu bar:
Eli Zaretskii <eliz@gnu.org>
parents:
52401
diff
changeset
|
583 (defsubst recentf-menu-bar () |
de4ce9c67474
Ensure that recentf correctly update the menu bar:
Eli Zaretskii <eliz@gnu.org>
parents:
52401
diff
changeset
|
584 "Return the keymap of the global menu bar." |
de4ce9c67474
Ensure that recentf correctly update the menu bar:
Eli Zaretskii <eliz@gnu.org>
parents:
52401
diff
changeset
|
585 (lookup-key global-map [menu-bar])) |
de4ce9c67474
Ensure that recentf correctly update the menu bar:
Eli Zaretskii <eliz@gnu.org>
parents:
52401
diff
changeset
|
586 |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
587 (defun recentf-clear-data () |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
588 "Clear data used to build the recentf menu. |
64664
3161d6027fd7
(recentf-menu-append-commands-p): Declare with `define-obsolete-variable-alias'.
Juanma Barranquero <lekktu@gmail.com>
parents:
64091
diff
changeset
|
589 This forces a rebuild of the menu." |
52468
de4ce9c67474
Ensure that recentf correctly update the menu bar:
Eli Zaretskii <eliz@gnu.org>
parents:
52401
diff
changeset
|
590 (easy-menu-remove-item (recentf-menu-bar) |
de4ce9c67474
Ensure that recentf correctly update the menu bar:
Eli Zaretskii <eliz@gnu.org>
parents:
52401
diff
changeset
|
591 recentf-menu-path recentf-menu-title) |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
592 (setq recentf-data-cache nil)) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
593 |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
594 ;;; Predefined menu filters |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
595 ;; |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
596 (defsubst recentf-sort-ascending (l) |
30416 | 597 "Sort the list of menu elements L in ascending order. |
598 The MENU-ITEM part of each menu element is compared." | |
599 (sort (copy-sequence l) | |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
600 #'(lambda (e1 e2) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
601 (recentf-string-lessp |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
602 (recentf-menu-element-item e1) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
603 (recentf-menu-element-item e2))))) |
30416 | 604 |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
605 (defsubst recentf-sort-descending (l) |
30416 | 606 "Sort the list of menu elements L in descending order. |
607 The MENU-ITEM part of each menu element is compared." | |
608 (sort (copy-sequence l) | |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
609 #'(lambda (e1 e2) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
610 (recentf-string-lessp |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
611 (recentf-menu-element-item e2) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
612 (recentf-menu-element-item e1))))) |
30416 | 613 |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
614 (defsubst recentf-sort-basenames-ascending (l) |
30416 | 615 "Sort the list of menu elements L in ascending order. |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
616 Only filenames sans directory are compared." |
30416 | 617 (sort (copy-sequence l) |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
618 #'(lambda (e1 e2) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
619 (recentf-string-lessp |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
620 (file-name-nondirectory (recentf-menu-element-value e1)) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
621 (file-name-nondirectory (recentf-menu-element-value e2)))))) |
30416 | 622 |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
623 (defsubst recentf-sort-basenames-descending (l) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
624 "Sort the list of menu elements L in descending order. |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
625 Only filenames sans directory are compared." |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
626 (sort (copy-sequence l) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
627 #'(lambda (e1 e2) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
628 (recentf-string-lessp |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
629 (file-name-nondirectory (recentf-menu-element-value e2)) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
630 (file-name-nondirectory (recentf-menu-element-value e1)))))) |
30416 | 631 |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
632 (defsubst recentf-sort-directories-ascending (l) |
30416 | 633 "Sort the list of menu elements L in ascending order. |
634 Compares directories then filenames to order the list." | |
635 (sort (copy-sequence l) | |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
636 #'(lambda (e1 e2) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
637 (recentf-directory-compare |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
638 (recentf-menu-element-value e1) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
639 (recentf-menu-element-value e2))))) |
30416 | 640 |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
641 (defsubst recentf-sort-directories-descending (l) |
30416 | 642 "Sort the list of menu elements L in descending order. |
643 Compares directories then filenames to order the list." | |
644 (sort (copy-sequence l) | |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
645 #'(lambda (e1 e2) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
646 (recentf-directory-compare |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
647 (recentf-menu-element-value e2) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
648 (recentf-menu-element-value e1))))) |
30416 | 649 |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
650 (defun recentf-show-basenames (l &optional no-dir) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
651 "Filter the list of menu elements L to show filenames sans directory. |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
652 When a filename is duplicated, it is appended a sequence number if |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
653 optional argument NO-DIR is non-nil, or its directory otherwise." |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
654 (let (filtered-names filtered-list full name counters sufx) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
655 (dolist (elt l (nreverse filtered-list)) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
656 (setq full (recentf-menu-element-value elt) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
657 name (file-name-nondirectory full)) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
658 (if (not (member name filtered-names)) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
659 (push name filtered-names) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
660 (if no-dir |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
661 (if (setq sufx (assoc name counters)) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
662 (setcdr sufx (1+ (cdr sufx))) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
663 (setq sufx 1) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
664 (push (cons name sufx) counters)) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
665 (setq sufx (file-name-directory full))) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
666 (setq name (format "%s(%s)" name sufx))) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
667 (push (recentf-make-menu-element name full) filtered-list)))) |
30416 | 668 |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
669 (defsubst recentf-show-basenames-ascending (l) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
670 "Filter the list of menu elements L to show filenames sans directory. |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
671 Filenames are sorted in ascending order. |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
672 This filter combines the `recentf-sort-basenames-ascending' and |
32292 | 673 `recentf-show-basenames' filters." |
30416 | 674 (recentf-show-basenames (recentf-sort-basenames-ascending l))) |
675 | |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
676 (defsubst recentf-show-basenames-descending (l) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
677 "Filter the list of menu elements L to show filenames sans directory. |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
678 Filenames are sorted in descending order. |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
679 This filter combines the `recentf-sort-basenames-descending' and |
32292 | 680 `recentf-show-basenames' filters." |
30416 | 681 (recentf-show-basenames (recentf-sort-basenames-descending l))) |
682 | |
683 (defun recentf-relative-filter (l) | |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
684 "Filter the list of menu-elements L to show relative filenames. |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
685 Filenames are relative to the `default-directory'." |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
686 (mapcar #'(lambda (menu-element) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
687 (let* ((ful (recentf-menu-element-value menu-element)) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
688 (rel (file-relative-name ful default-directory))) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
689 (if (string-match "^\\.\\." rel) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
690 menu-element |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
691 (recentf-make-menu-element rel ful)))) |
30416 | 692 l)) |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
693 |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
694 ;;; Rule based menu filters |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
695 ;; |
30416 | 696 (defcustom recentf-arrange-rules |
697 '( | |
698 ("Elisp files (%d)" ".\\.el$") | |
699 ("Java files (%d)" ".\\.java$") | |
700 ("C/C++ files (%d)" "c\\(pp\\)?$") | |
701 ) | |
702 "*List of rules used by `recentf-arrange-by-rule' to build sub-menus. | |
32292 | 703 A rule is a pair (SUB-MENU-TITLE . MATCHER). SUB-MENU-TITLE is the |
30416 | 704 displayed title of the sub-menu where a '%d' `format' pattern is |
32292 | 705 replaced by the number of items in the sub-menu. MATCHER is a regexp |
706 or a list of regexps. Items matching one of the regular expressions in | |
30416 | 707 MATCHER are added to the corresponding sub-menu." |
708 :group 'recentf-filters | |
709 :type '(repeat (cons string (repeat regexp))) | |
710 :set 'recentf-menu-customization-changed) | |
711 | |
712 (defcustom recentf-arrange-by-rule-others "Other files (%d)" | |
32292 | 713 "*Title of the `recentf-arrange-by-rule' sub-menu. |
714 This is for the menu where items that don't match any | |
715 `recentf-arrange-rules' are displayed. If nil these items are | |
716 displayed in the main recent files menu. A '%d' `format' pattern in | |
717 the title is replaced by the number of items in the sub-menu." | |
30416 | 718 :group 'recentf-filters |
719 :type '(choice (const :tag "Main menu" nil) | |
720 (string :tag "Title")) | |
721 :set 'recentf-menu-customization-changed) | |
722 | |
723 (defcustom recentf-arrange-by-rules-min-items 0 | |
724 "*Minimum number of items in a `recentf-arrange-by-rule' sub-menu. | |
725 If the number of items in a sub-menu is less than this value the | |
726 corresponding sub-menu items are displayed in the main recent files | |
727 menu or in the `recentf-arrange-by-rule-others' sub-menu if | |
728 defined." | |
729 :group 'recentf-filters | |
730 :type 'number | |
731 :set 'recentf-menu-customization-changed) | |
732 | |
733 (defcustom recentf-arrange-by-rule-subfilter nil | |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
734 "*Function called by a rule based filter to filter sub-menu elements. |
64664
3161d6027fd7
(recentf-menu-append-commands-p): Declare with `define-obsolete-variable-alias'.
Juanma Barranquero <lekktu@gmail.com>
parents:
64091
diff
changeset
|
735 A nil value means no filter. See also `recentf-menu-filter'. |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
736 You can't use another rule based filter here." |
30416 | 737 :group 'recentf-filters |
35971 | 738 :type '(choice (const nil) function) |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
739 :set (lambda (variable value) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
740 (when (memq value '(recentf-arrange-by-rule |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
741 recentf-arrange-by-mode |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
742 recentf-arrange-by-dir)) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
743 (error "Recursive use of a rule based filter")) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
744 (recentf-menu-customization-changed variable value))) |
30416 | 745 |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
746 (defun recentf-match-rule-p (matcher filename) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
747 "Return non-nil if the rule specified by MATCHER match FILENAME. |
30416 | 748 See `recentf-arrange-rules' for details on MATCHER." |
749 (if (stringp matcher) | |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
750 (string-match matcher filename) |
30416 | 751 (while (and (consp matcher) |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
752 (not (string-match (car matcher) filename))) |
30416 | 753 (setq matcher (cdr matcher))) |
754 matcher)) | |
755 | |
756 (defun recentf-arrange-by-rule (l) | |
32292 | 757 "Filter the list of menu-elements L. |
758 Arrange them in sub-menus following rules in `recentf-arrange-rules'." | |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
759 (if (not recentf-arrange-rules) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
760 l |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
761 (let ((menus (mapcar #'(lambda (r) (list (car r))) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
762 recentf-arrange-rules)) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
763 menu others min file rules elts count) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
764 (dolist (elt l) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
765 (setq file (recentf-menu-element-value elt) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
766 rules recentf-arrange-rules |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
767 elts menus |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
768 menu nil) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
769 (while (and (not menu) rules) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
770 (when (recentf-match-rule-p (cdar rules) file) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
771 (setq menu (car elts)) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
772 (recentf-set-menu-element-value |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
773 menu (cons elt (recentf-menu-element-value menu)))) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
774 (setq rules (cdr rules) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
775 elts (cdr elts))) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
776 (unless menu |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
777 (push elt others))) |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
57993
diff
changeset
|
778 |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
779 (setq l nil |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
780 min (if (natnump recentf-arrange-by-rules-min-items) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
781 recentf-arrange-by-rules-min-items 0)) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
782 (dolist (menu menus) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
783 (when (setq elts (recentf-menu-element-value menu)) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
784 (setq count (length elts)) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
785 (if (< count min) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
786 (setq others (nconc elts others)) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
787 (recentf-set-menu-element-item |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
788 menu (format (recentf-menu-element-item menu) count)) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
789 (recentf-set-menu-element-value |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
790 menu (recentf-apply-menu-filter |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
791 recentf-arrange-by-rule-subfilter (nreverse elts))) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
792 (push menu l)))) |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
57993
diff
changeset
|
793 |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
794 (if (and (stringp recentf-arrange-by-rule-others) others) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
795 (nreverse |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
796 (cons |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
797 (recentf-make-menu-element |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
798 (format recentf-arrange-by-rule-others (length others)) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
799 (recentf-apply-menu-filter |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
800 recentf-arrange-by-rule-subfilter (nreverse others))) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
801 l)) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
802 (nconc |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
803 (nreverse l) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
804 (recentf-apply-menu-filter |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
805 recentf-arrange-by-rule-subfilter (nreverse others))))) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
806 )) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
807 |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
808 ;;; Predefined rule based menu filters |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
809 ;; |
30416 | 810 (defun recentf-build-mode-rules () |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
811 "Convert `auto-mode-alist' to menu filter rules. |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
812 Rules obey `recentf-arrange-rules' format." |
30416 | 813 (let ((case-fold-search recentf-case-fold-search) |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
814 regexp rule-name rule rules) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
815 (dolist (mode auto-mode-alist) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
816 (setq regexp (car mode) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
817 mode (cdr mode)) |
30416 | 818 (when (symbolp mode) |
819 (setq rule-name (symbol-name mode)) | |
820 (if (string-match "\\(.*\\)-mode$" rule-name) | |
821 (setq rule-name (match-string 1 rule-name))) | |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
822 (setq rule-name (concat rule-name " (%d)") |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
823 rule (assoc rule-name rules)) |
30416 | 824 (if rule |
825 (setcdr rule (cons regexp (cdr rule))) | |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
826 (push (list rule-name regexp) rules)))) |
30416 | 827 ;; It is important to preserve auto-mode-alist order |
828 ;; to ensure the right file <-> mode association | |
829 (nreverse rules))) | |
49549
99be3a1e2589
Cygwin support patch.
Juanma Barranquero <lekktu@gmail.com>
parents:
44967
diff
changeset
|
830 |
30416 | 831 (defun recentf-arrange-by-mode (l) |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
832 "Split the list of menu-elements L into sub-menus by major mode." |
30416 | 833 (let ((recentf-arrange-rules (recentf-build-mode-rules)) |
834 (recentf-arrange-by-rule-others "others (%d)")) | |
835 (recentf-arrange-by-rule l))) | |
836 | |
837 (defun recentf-build-dir-rules (l) | |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
838 "Convert directories in menu-elements L to menu filter rules. |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
839 Rules obey `recentf-arrange-rules' format." |
30416 | 840 (let (dirs) |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
841 (mapcar #'(lambda (e) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
842 (let ((dir (file-name-directory |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
843 (recentf-menu-element-value e)))) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
844 (or (recentf-string-member dir dirs) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
845 (push dir dirs)))) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
846 l) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
847 (mapcar #'(lambda (d) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
848 (cons (concat d " (%d)") |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
849 (concat "\\`" d))) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
850 (nreverse (sort dirs 'recentf-string-lessp))))) |
30416 | 851 |
852 (defun recentf-file-name-nondir (l) | |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
853 "Filter the list of menu-elements L to show filenames sans directory. |
32292 | 854 This simplified version of `recentf-show-basenames' does not handle |
855 duplicates. It is used by `recentf-arrange-by-dir' as its | |
30416 | 856 `recentf-arrange-by-rule-subfilter'." |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
857 (mapcar #'(lambda (e) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
858 (recentf-make-menu-element |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
859 (file-name-nondirectory (recentf-menu-element-value e)) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
860 (recentf-menu-element-value e))) |
30416 | 861 l)) |
862 | |
863 (defun recentf-arrange-by-dir (l) | |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
864 "Split the list of menu-elements L into sub-menus by directory." |
30416 | 865 (let ((recentf-arrange-rules (recentf-build-dir-rules l)) |
866 (recentf-arrange-by-rule-subfilter 'recentf-file-name-nondir) | |
867 recentf-arrange-by-rule-others) | |
868 (nreverse (recentf-arrange-by-rule l)))) | |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
869 |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
870 ;;; Ring of menu filters |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
871 ;; |
30416 | 872 (defvar recentf-filter-changer-state nil |
873 "Used by `recentf-filter-changer' to hold its state.") | |
874 | |
875 (defcustom recentf-filter-changer-alist | |
876 '( | |
877 (recentf-arrange-by-mode . "*Files by Mode*") | |
878 (recentf-arrange-by-dir . "*Files by Directory*") | |
879 (recentf-arrange-by-rule . "*Files by User Rule*") | |
880 ) | |
881 "*List of filters managed by `recentf-filter-changer'. | |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
882 Each filter is defined by a pair (FUNCTION . LABEL), where FUNCTION is |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
883 the filter function, and LABEL is the menu item displayed to select |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
884 that filter." |
30416 | 885 :group 'recentf-filters |
886 :type '(repeat (cons function string)) | |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
887 :set (lambda (variable value) |
30416 | 888 (setq recentf-filter-changer-state nil) |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
889 (recentf-menu-customization-changed variable value))) |
30416 | 890 |
891 (defun recentf-filter-changer-goto-next () | |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
892 "Go to the next filter available. |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
893 See `recentf-filter-changer'." |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
894 (setq recentf-filter-changer-state (cdr recentf-filter-changer-state)) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
895 (recentf-clear-data)) |
30416 | 896 |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
897 (defsubst recentf-filter-changer-get-current () |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
898 "Get the current filter available. |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
899 See `recentf-filter-changer'." |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
900 (unless recentf-filter-changer-state |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
901 (setq recentf-filter-changer-state recentf-filter-changer-alist)) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
902 (car recentf-filter-changer-state)) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
903 |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
904 (defsubst recentf-filter-changer-get-next () |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
905 "Get the next filter available. |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
906 See `recentf-filter-changer'." |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
907 ;; At this point the current filter is the first element of |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
908 ;; `recentf-filter-changer-state'. |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
909 (car (or (cdr recentf-filter-changer-state) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
910 ;; There is no next element in |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
911 ;; `recentf-filter-changer-state', so loop back to the |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
912 ;; first element of `recentf-filter-changer-alist'. |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
913 recentf-filter-changer-alist))) |
49549
99be3a1e2589
Cygwin support patch.
Juanma Barranquero <lekktu@gmail.com>
parents:
44967
diff
changeset
|
914 |
30416 | 915 (defun recentf-filter-changer (l) |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
916 "Manage a ring of menu filters. |
32292 | 917 `recentf-filter-changer-alist' defines the filters in the ring. |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
918 Filtering of L is delegated to the current filter in the ring. A |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
919 filter menu item is displayed allowing to dynamically activate the |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
920 next filter in the ring. If the filter ring is empty, L is left |
32292 | 921 unchanged." |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
922 (let ((filter (recentf-filter-changer-get-current))) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
923 (when filter |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
924 (setq l (recentf-apply-menu-filter (car filter) l) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
925 filter (recentf-filter-changer-get-next)) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
926 (when filter |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
927 (setq recentf-menu-filter-commands |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
928 (list (vector (cdr filter) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
929 '(recentf-filter-changer-goto-next) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
930 t))))) |
30416 | 931 l)) |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
932 |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
933 ;;; Common dialog stuff |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
934 ;; |
30416 | 935 (defun recentf-cancel-dialog (&rest ignore) |
32292 | 936 "Cancel the current dialog. |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
937 IGNORE arguments." |
30416 | 938 (interactive) |
939 (kill-buffer (current-buffer)) | |
44967
e1faf9329d7e
Remove dot at the end of sentence.
Pavel Janík <Pavel@Janik.cz>
parents:
44915
diff
changeset
|
940 (message "Dialog canceled")) |
30416 | 941 |
63781
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
942 (defun recentf-dialog-goto-first (widget-type) |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
943 "Move the cursor to the first WIDGET-TYPE in current dialog. |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
944 Go to the beginning of buffer if not found." |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
945 (goto-char (point-min)) |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
946 (condition-case nil |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
947 (let (done) |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
948 (widget-move 1) |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
949 (while (not done) |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
950 (if (eq widget-type (widget-type (widget-at (point)))) |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
951 (setq done t) |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
952 (widget-move 1)))) |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
953 (goto-char (point-min)))) |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
954 |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
955 (defvar recentf-dialog-mode-map |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
956 (let ((km (make-sparse-keymap))) |
63781
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
957 (set-keymap-parent km widget-keymap) |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
958 (define-key km "q" 'recentf-cancel-dialog) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
959 (define-key km [down-mouse-1] 'widget-button-click) |
65365
83aa6efe327f
(recentf-show-file-shortcuts-flag): New option.
David Ponce <david@dponce.com>
parents:
64762
diff
changeset
|
960 ;; Keys in reverse order of appearence in help. |
83aa6efe327f
(recentf-show-file-shortcuts-flag): New option.
David Ponce <david@dponce.com>
parents:
64762
diff
changeset
|
961 (dolist (k '("0" "9" "8" "7" "6" "5" "4" "3" "2" "1")) |
83aa6efe327f
(recentf-show-file-shortcuts-flag): New option.
David Ponce <david@dponce.com>
parents:
64762
diff
changeset
|
962 (define-key km k 'recentf-open-file-with-key)) |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
963 km) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
964 "Keymap used in recentf dialogs.") |
30416 | 965 |
63781
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
966 (define-derived-mode recentf-dialog-mode nil "recentf-dialog" |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
967 "Major mode of recentf dialogs. |
30416 | 968 |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
969 \\{recentf-dialog-mode-map}" |
63781
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
970 :syntax-table nil |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
971 :abbrev-table nil |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
972 (setq truncate-lines t)) |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
973 |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
974 (defmacro recentf-dialog (name &rest forms) |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
975 "Show a dialog buffer with NAME, setup with FORMS." |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
976 (declare (indent 1) (debug t)) |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
977 `(with-current-buffer (get-buffer-create ,name) |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
978 ;; Cleanup buffer |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
979 (let ((inhibit-read-only t) |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
980 (ol (overlay-lists))) |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
981 (mapc 'delete-overlay (car ol)) |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
982 (mapc 'delete-overlay (cdr ol)) |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
983 (erase-buffer)) |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
984 (recentf-dialog-mode) |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
985 ,@forms |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
986 (widget-setup) |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
987 (switch-to-buffer (current-buffer)))) |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
988 |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
989 ;;; Hooks |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
990 ;; |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
991 (defun recentf-track-opened-file () |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
992 "Insert the name of the file just opened or written into the recent list." |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
993 (and buffer-file-name |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
994 (recentf-add-file buffer-file-name)) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
995 ;; Must return nil because it is run from `write-file-functions'. |
30416 | 996 nil) |
997 | |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
998 (defun recentf-track-closed-file () |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
999 "Update the recent list when a buffer is killed. |
60844
5bb0c1e05b1b
(recentf-keep): New option.
David Ponce <david@dponce.com>
parents:
60740
diff
changeset
|
1000 That is, remove a non kept file from the recent list." |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
1001 (and buffer-file-name |
60844
5bb0c1e05b1b
(recentf-keep): New option.
David Ponce <david@dponce.com>
parents:
60740
diff
changeset
|
1002 (recentf-remove-if-non-kept buffer-file-name))) |
30416 | 1003 |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
1004 (defun recentf-update-menu () |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
1005 "Update the recentf menu from the current recent list." |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
1006 (let ((cache (cons default-directory recentf-list))) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
1007 ;; Does nothing, if nothing has changed. |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
1008 (unless (equal recentf-data-cache cache) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
1009 (setq recentf-data-cache cache) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
1010 (condition-case err |
52468
de4ce9c67474
Ensure that recentf correctly update the menu bar:
Eli Zaretskii <eliz@gnu.org>
parents:
52401
diff
changeset
|
1011 (easy-menu-add-item |
de4ce9c67474
Ensure that recentf correctly update the menu bar:
Eli Zaretskii <eliz@gnu.org>
parents:
52401
diff
changeset
|
1012 (recentf-menu-bar) recentf-menu-path |
de4ce9c67474
Ensure that recentf correctly update the menu bar:
Eli Zaretskii <eliz@gnu.org>
parents:
52401
diff
changeset
|
1013 (easy-menu-create-menu recentf-menu-title |
de4ce9c67474
Ensure that recentf correctly update the menu bar:
Eli Zaretskii <eliz@gnu.org>
parents:
52401
diff
changeset
|
1014 (recentf-make-menu-items)) |
de4ce9c67474
Ensure that recentf correctly update the menu bar:
Eli Zaretskii <eliz@gnu.org>
parents:
52401
diff
changeset
|
1015 recentf-menu-before) |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
1016 (error |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
1017 (message "recentf update menu failed: %s" |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
1018 (error-message-string err))))))) |
30416 | 1019 |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
1020 (defconst recentf-used-hooks |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
1021 '( |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
1022 (find-file-hook recentf-track-opened-file) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
1023 (write-file-functions recentf-track-opened-file) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
1024 (kill-buffer-hook recentf-track-closed-file) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
1025 (menu-bar-update-hook recentf-update-menu) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
1026 (kill-emacs-hook recentf-save-list) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
1027 ) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
1028 "Hooks used by recentf.") |
30416 | 1029 |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
1030 (defsubst recentf-enabled-p () |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
1031 "Return non-nil if recentf mode is currently enabled." |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
1032 (memq 'recentf-update-menu menu-bar-update-hook)) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
1033 |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
1034 ;;; Commands |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
1035 ;; |
30416 | 1036 |
63781
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1037 ;;; Edit list dialog |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1038 ;; |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1039 (defvar recentf-edit-list nil) |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1040 |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1041 (defun recentf-edit-list-select (widget &rest ignore) |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1042 "Toggle a file selection based on the checkbox WIDGET state. |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
1043 IGNORE other arguments." |
63781
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1044 (let ((value (widget-get widget :tag)) |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1045 (check (widget-value widget))) |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1046 (if check |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1047 (add-to-list 'recentf-edit-list value) |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1048 (setq recentf-edit-list (delq value recentf-edit-list))) |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1049 (message "%s %sselected" value (if check "" "un")))) |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1050 |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1051 (defun recentf-edit-list-validate (&rest ignore) |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1052 "Process the recent list when the edit list dialog is committed. |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1053 IGNORE arguments." |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1054 (if recentf-edit-list |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1055 (let ((i 0)) |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1056 (dolist (e recentf-edit-list) |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1057 (setq recentf-list (delq e recentf-list) |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1058 i (1+ i))) |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1059 (kill-buffer (current-buffer)) |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1060 (message "%S file(s) removed from the list" i) |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1061 (recentf-clear-data)) |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1062 (message "No file selected"))) |
49549
99be3a1e2589
Cygwin support patch.
Juanma Barranquero <lekktu@gmail.com>
parents:
44967
diff
changeset
|
1063 |
30416 | 1064 (defun recentf-edit-list () |
63781
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1065 "Show a dialog to delete selected files from the recent list." |
30416 | 1066 (interactive) |
63781
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1067 (recentf-dialog (format "*%s - Edit list*" recentf-menu-title) |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1068 (set (make-local-variable 'recentf-edit-list) nil) |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
1069 (widget-insert |
63781
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1070 "Click on OK to delete selected files from the recent list. |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1071 Click on Cancel or type `q' to cancel.\n") |
30416 | 1072 ;; Insert the list of files as checkboxes |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
1073 (dolist (item recentf-list) |
63781
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1074 (widget-create 'checkbox |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1075 :value nil ; unselected checkbox |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1076 :format "\n %[%v%] %t" |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1077 :tag item |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1078 :notify 'recentf-edit-list-select)) |
30416 | 1079 (widget-insert "\n\n") |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
1080 (widget-create |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
1081 'push-button |
63781
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1082 :notify 'recentf-edit-list-validate |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1083 :help-echo "Delete selected files from the recent list" |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1084 "Ok") |
30416 | 1085 (widget-insert " ") |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
1086 (widget-create |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
1087 'push-button |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
1088 :notify 'recentf-cancel-dialog |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
1089 "Cancel") |
63781
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1090 (recentf-dialog-goto-first 'checkbox))) |
30416 | 1091 |
63781
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1092 ;;; Open file dialog |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1093 ;; |
30416 | 1094 (defun recentf-open-files-action (widget &rest ignore) |
63781
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1095 "Open the file stored in WIDGET's value when notified. |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
1096 IGNORE other arguments." |
30416 | 1097 (kill-buffer (current-buffer)) |
1098 (funcall recentf-menu-action (widget-value widget))) | |
1099 | |
65365
83aa6efe327f
(recentf-show-file-shortcuts-flag): New option.
David Ponce <david@dponce.com>
parents:
64762
diff
changeset
|
1100 ;; List of files associated to a digit shortcut key. |
83aa6efe327f
(recentf-show-file-shortcuts-flag): New option.
David Ponce <david@dponce.com>
parents:
64762
diff
changeset
|
1101 (defvar recentf--files-with-key nil) |
83aa6efe327f
(recentf-show-file-shortcuts-flag): New option.
David Ponce <david@dponce.com>
parents:
64762
diff
changeset
|
1102 |
83aa6efe327f
(recentf-show-file-shortcuts-flag): New option.
David Ponce <david@dponce.com>
parents:
64762
diff
changeset
|
1103 (defun recentf-show-digit-shortcut-filter (l) |
83aa6efe327f
(recentf-show-file-shortcuts-flag): New option.
David Ponce <david@dponce.com>
parents:
64762
diff
changeset
|
1104 "Filter the list of menu-elements L to show digit shortcuts." |
83aa6efe327f
(recentf-show-file-shortcuts-flag): New option.
David Ponce <david@dponce.com>
parents:
64762
diff
changeset
|
1105 (let ((i 0)) |
83aa6efe327f
(recentf-show-file-shortcuts-flag): New option.
David Ponce <david@dponce.com>
parents:
64762
diff
changeset
|
1106 (dolist (e l) |
83aa6efe327f
(recentf-show-file-shortcuts-flag): New option.
David Ponce <david@dponce.com>
parents:
64762
diff
changeset
|
1107 (setq i (1+ i)) |
83aa6efe327f
(recentf-show-file-shortcuts-flag): New option.
David Ponce <david@dponce.com>
parents:
64762
diff
changeset
|
1108 (recentf-set-menu-element-item |
83aa6efe327f
(recentf-show-file-shortcuts-flag): New option.
David Ponce <david@dponce.com>
parents:
64762
diff
changeset
|
1109 e (format "[%d] %s" (% i 10) (recentf-menu-element-item e)))) |
83aa6efe327f
(recentf-show-file-shortcuts-flag): New option.
David Ponce <david@dponce.com>
parents:
64762
diff
changeset
|
1110 l)) |
83aa6efe327f
(recentf-show-file-shortcuts-flag): New option.
David Ponce <david@dponce.com>
parents:
64762
diff
changeset
|
1111 |
30416 | 1112 (defun recentf-open-files-item (menu-element) |
63781
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1113 "Return a widget to display MENU-ELEMENT in a dialog buffer." |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1114 (if (consp (cdr menu-element)) |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1115 ;; Represent a sub-menu with a tree widget |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1116 `(tree-widget |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1117 :open t |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1118 :match ignore |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1119 :node (item :tag ,(car menu-element) |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1120 :sample-face bold |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1121 :format "%{%t%}:\n") |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1122 ,@(mapcar 'recentf-open-files-item |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1123 (cdr menu-element))) |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1124 ;; Represent a single file with a link widget |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1125 `(link :tag ,(car menu-element) |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1126 :button-prefix "" |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1127 :button-suffix "" |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1128 :button-face default |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1129 :format "%[%t%]\n" |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1130 :help-echo ,(concat "Open " (cdr menu-element)) |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1131 :action recentf-open-files-action |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1132 ,(cdr menu-element)))) |
30416 | 1133 |
65365
83aa6efe327f
(recentf-show-file-shortcuts-flag): New option.
David Ponce <david@dponce.com>
parents:
64762
diff
changeset
|
1134 (defun recentf-open-files-items (files) |
83aa6efe327f
(recentf-show-file-shortcuts-flag): New option.
David Ponce <david@dponce.com>
parents:
64762
diff
changeset
|
1135 "Return a list of widgets to display FILES in a dialog buffer." |
83aa6efe327f
(recentf-show-file-shortcuts-flag): New option.
David Ponce <david@dponce.com>
parents:
64762
diff
changeset
|
1136 (set (make-local-variable 'recentf--files-with-key) |
83aa6efe327f
(recentf-show-file-shortcuts-flag): New option.
David Ponce <david@dponce.com>
parents:
64762
diff
changeset
|
1137 (recentf-trunc-list files 10)) |
83aa6efe327f
(recentf-show-file-shortcuts-flag): New option.
David Ponce <david@dponce.com>
parents:
64762
diff
changeset
|
1138 (mapcar 'recentf-open-files-item |
83aa6efe327f
(recentf-show-file-shortcuts-flag): New option.
David Ponce <david@dponce.com>
parents:
64762
diff
changeset
|
1139 (append |
83aa6efe327f
(recentf-show-file-shortcuts-flag): New option.
David Ponce <david@dponce.com>
parents:
64762
diff
changeset
|
1140 ;; When requested group the files with shortcuts together |
83aa6efe327f
(recentf-show-file-shortcuts-flag): New option.
David Ponce <david@dponce.com>
parents:
64762
diff
changeset
|
1141 ;; at the top of the list. |
83aa6efe327f
(recentf-show-file-shortcuts-flag): New option.
David Ponce <david@dponce.com>
parents:
64762
diff
changeset
|
1142 (when recentf-show-file-shortcuts-flag |
83aa6efe327f
(recentf-show-file-shortcuts-flag): New option.
David Ponce <david@dponce.com>
parents:
64762
diff
changeset
|
1143 (setq files (nthcdr 10 files)) |
83aa6efe327f
(recentf-show-file-shortcuts-flag): New option.
David Ponce <david@dponce.com>
parents:
64762
diff
changeset
|
1144 (recentf-apply-menu-filter |
83aa6efe327f
(recentf-show-file-shortcuts-flag): New option.
David Ponce <david@dponce.com>
parents:
64762
diff
changeset
|
1145 'recentf-show-digit-shortcut-filter |
83aa6efe327f
(recentf-show-file-shortcuts-flag): New option.
David Ponce <david@dponce.com>
parents:
64762
diff
changeset
|
1146 (mapcar 'recentf-make-default-menu-element |
83aa6efe327f
(recentf-show-file-shortcuts-flag): New option.
David Ponce <david@dponce.com>
parents:
64762
diff
changeset
|
1147 recentf--files-with-key))) |
83aa6efe327f
(recentf-show-file-shortcuts-flag): New option.
David Ponce <david@dponce.com>
parents:
64762
diff
changeset
|
1148 ;; Then the other files. |
83aa6efe327f
(recentf-show-file-shortcuts-flag): New option.
David Ponce <david@dponce.com>
parents:
64762
diff
changeset
|
1149 (recentf-apply-menu-filter |
83aa6efe327f
(recentf-show-file-shortcuts-flag): New option.
David Ponce <david@dponce.com>
parents:
64762
diff
changeset
|
1150 recentf-menu-filter |
83aa6efe327f
(recentf-show-file-shortcuts-flag): New option.
David Ponce <david@dponce.com>
parents:
64762
diff
changeset
|
1151 (mapcar 'recentf-make-default-menu-element |
83aa6efe327f
(recentf-show-file-shortcuts-flag): New option.
David Ponce <david@dponce.com>
parents:
64762
diff
changeset
|
1152 files))))) |
83aa6efe327f
(recentf-show-file-shortcuts-flag): New option.
David Ponce <david@dponce.com>
parents:
64762
diff
changeset
|
1153 |
30416 | 1154 (defun recentf-open-files (&optional files buffer-name) |
63781
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1155 "Show a dialog to open a recent file. |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1156 If optional argument FILES is non-nil, it is a list of recently-opened |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1157 files to choose from. It defaults to the whole recent list. |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1158 If optional argument BUFFER-NAME is non-nil, it is a buffer name to |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1159 use for the dialog. It defaults to \"*`recentf-menu-title'*\"." |
30416 | 1160 (interactive) |
63781
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1161 (recentf-dialog (or buffer-name (format "*%s*" recentf-menu-title)) |
65365
83aa6efe327f
(recentf-show-file-shortcuts-flag): New option.
David Ponce <david@dponce.com>
parents:
64762
diff
changeset
|
1162 (widget-insert "Click on a file" |
83aa6efe327f
(recentf-show-file-shortcuts-flag): New option.
David Ponce <david@dponce.com>
parents:
64762
diff
changeset
|
1163 (if recentf-show-file-shortcuts-flag |
83aa6efe327f
(recentf-show-file-shortcuts-flag): New option.
David Ponce <david@dponce.com>
parents:
64762
diff
changeset
|
1164 ", or type the corresponding digit key," |
83aa6efe327f
(recentf-show-file-shortcuts-flag): New option.
David Ponce <david@dponce.com>
parents:
64762
diff
changeset
|
1165 "") |
83aa6efe327f
(recentf-show-file-shortcuts-flag): New option.
David Ponce <david@dponce.com>
parents:
64762
diff
changeset
|
1166 " to open it.\n" |
83aa6efe327f
(recentf-show-file-shortcuts-flag): New option.
David Ponce <david@dponce.com>
parents:
64762
diff
changeset
|
1167 "Click on Cancel or type `q' to cancel.\n") |
63781
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1168 ;; Use a L&F that looks like the recentf menu. |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1169 (tree-widget-set-theme "folder") |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1170 (apply 'widget-create |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1171 `(group |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1172 :indent 2 |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1173 :format "\n%v\n" |
65365
83aa6efe327f
(recentf-show-file-shortcuts-flag): New option.
David Ponce <david@dponce.com>
parents:
64762
diff
changeset
|
1174 ,@(recentf-open-files-items (or files recentf-list)))) |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
1175 (widget-create |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
1176 'push-button |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
1177 :notify 'recentf-cancel-dialog |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
1178 "Cancel") |
63781
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1179 (recentf-dialog-goto-first 'link))) |
30416 | 1180 |
65365
83aa6efe327f
(recentf-show-file-shortcuts-flag): New option.
David Ponce <david@dponce.com>
parents:
64762
diff
changeset
|
1181 (defun recentf-open-file-with-key (n) |
83aa6efe327f
(recentf-show-file-shortcuts-flag): New option.
David Ponce <david@dponce.com>
parents:
64762
diff
changeset
|
1182 "Open the recent file with the shortcut numeric key N. |
83aa6efe327f
(recentf-show-file-shortcuts-flag): New option.
David Ponce <david@dponce.com>
parents:
64762
diff
changeset
|
1183 N must be a valid digit. |
83aa6efe327f
(recentf-show-file-shortcuts-flag): New option.
David Ponce <david@dponce.com>
parents:
64762
diff
changeset
|
1184 `1' opens the first file, `2' the second file, ... `9' the ninth file. |
83aa6efe327f
(recentf-show-file-shortcuts-flag): New option.
David Ponce <david@dponce.com>
parents:
64762
diff
changeset
|
1185 `0' opens the tenth file." |
83aa6efe327f
(recentf-show-file-shortcuts-flag): New option.
David Ponce <david@dponce.com>
parents:
64762
diff
changeset
|
1186 (interactive |
83aa6efe327f
(recentf-show-file-shortcuts-flag): New option.
David Ponce <david@dponce.com>
parents:
64762
diff
changeset
|
1187 (list |
83aa6efe327f
(recentf-show-file-shortcuts-flag): New option.
David Ponce <david@dponce.com>
parents:
64762
diff
changeset
|
1188 (let ((n (string-to-number (this-command-keys)))) |
83aa6efe327f
(recentf-show-file-shortcuts-flag): New option.
David Ponce <david@dponce.com>
parents:
64762
diff
changeset
|
1189 (cond |
83aa6efe327f
(recentf-show-file-shortcuts-flag): New option.
David Ponce <david@dponce.com>
parents:
64762
diff
changeset
|
1190 ((zerop n) 10) |
83aa6efe327f
(recentf-show-file-shortcuts-flag): New option.
David Ponce <david@dponce.com>
parents:
64762
diff
changeset
|
1191 ((and (> n 0) (< n 10)) n) |
83aa6efe327f
(recentf-show-file-shortcuts-flag): New option.
David Ponce <david@dponce.com>
parents:
64762
diff
changeset
|
1192 ((error "Invalid digit key %d" n)))))) |
83aa6efe327f
(recentf-show-file-shortcuts-flag): New option.
David Ponce <david@dponce.com>
parents:
64762
diff
changeset
|
1193 (when recentf--files-with-key |
83aa6efe327f
(recentf-show-file-shortcuts-flag): New option.
David Ponce <david@dponce.com>
parents:
64762
diff
changeset
|
1194 (let ((file (nth (1- n) recentf--files-with-key))) |
83aa6efe327f
(recentf-show-file-shortcuts-flag): New option.
David Ponce <david@dponce.com>
parents:
64762
diff
changeset
|
1195 (unless file (error "Not that many recent files")) |
83aa6efe327f
(recentf-show-file-shortcuts-flag): New option.
David Ponce <david@dponce.com>
parents:
64762
diff
changeset
|
1196 (kill-buffer (current-buffer)) |
83aa6efe327f
(recentf-show-file-shortcuts-flag): New option.
David Ponce <david@dponce.com>
parents:
64762
diff
changeset
|
1197 (funcall recentf-menu-action file)))) |
83aa6efe327f
(recentf-show-file-shortcuts-flag): New option.
David Ponce <david@dponce.com>
parents:
64762
diff
changeset
|
1198 |
30416 | 1199 (defun recentf-open-more-files () |
63781
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1200 "Show a dialog to open a recent file that is not in the menu." |
30416 | 1201 (interactive) |
1202 (recentf-open-files (nthcdr recentf-max-menu-items recentf-list) | |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
1203 (format "*%s - More*" recentf-menu-title))) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
1204 |
63781
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1205 ;;; Save/load/cleanup the recent list |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1206 ;; |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
1207 (defconst recentf-save-file-header |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
1208 ";;; Automatically generated by `recentf' on %s.\n" |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
1209 "Header to be written into the `recentf-save-file'.") |
30416 | 1210 |
61733
34f8bb98e444
(recentf-save-file-coding-system): New variable.
Kenichi Handa <handa@m17n.org>
parents:
60844
diff
changeset
|
1211 (defconst recentf-save-file-coding-system |
34f8bb98e444
(recentf-save-file-coding-system): New variable.
Kenichi Handa <handa@m17n.org>
parents:
60844
diff
changeset
|
1212 (if (coding-system-p 'utf-8-emacs) |
34f8bb98e444
(recentf-save-file-coding-system): New variable.
Kenichi Handa <handa@m17n.org>
parents:
60844
diff
changeset
|
1213 'utf-8-emacs |
34f8bb98e444
(recentf-save-file-coding-system): New variable.
Kenichi Handa <handa@m17n.org>
parents:
60844
diff
changeset
|
1214 'emacs-mule) |
34f8bb98e444
(recentf-save-file-coding-system): New variable.
Kenichi Handa <handa@m17n.org>
parents:
60844
diff
changeset
|
1215 "Coding system of the file `recentf-save-file'.") |
34f8bb98e444
(recentf-save-file-coding-system): New variable.
Kenichi Handa <handa@m17n.org>
parents:
60844
diff
changeset
|
1216 |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
1217 (defun recentf-save-list () |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
1218 "Save the recent list. |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
1219 Write data into the file specified by `recentf-save-file'." |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
1220 (interactive) |
55012
13ef2f084366
(recentf-save-list): Catch and warn about errors.
Richard M. Stallman <rms@gnu.org>
parents:
54770
diff
changeset
|
1221 (condition-case error |
13ef2f084366
(recentf-save-list): Catch and warn about errors.
Richard M. Stallman <rms@gnu.org>
parents:
54770
diff
changeset
|
1222 (with-temp-buffer |
63781
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1223 (erase-buffer) |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1224 (set-buffer-file-coding-system recentf-save-file-coding-system) |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1225 (insert (format recentf-save-file-header (current-time-string))) |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1226 (recentf-dump-variable 'recentf-list recentf-max-saved-items) |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1227 (recentf-dump-variable 'recentf-filter-changer-state) |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1228 (insert "\n\n;;; Local Variables:\n" |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1229 (format ";;; coding: %s\n" recentf-save-file-coding-system) |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1230 ";;; End:\n") |
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1231 (write-file (expand-file-name recentf-save-file)) |
65525
f68d6281086a
(recentf-save-file-modes): New option.
David Ponce <david@dponce.com>
parents:
65368
diff
changeset
|
1232 (when recentf-save-file-modes |
f68d6281086a
(recentf-save-file-modes): New option.
David Ponce <david@dponce.com>
parents:
65368
diff
changeset
|
1233 (set-file-modes recentf-save-file recentf-save-file-modes)) |
63781
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1234 nil) |
55012
13ef2f084366
(recentf-save-list): Catch and warn about errors.
Richard M. Stallman <rms@gnu.org>
parents:
54770
diff
changeset
|
1235 (error |
13ef2f084366
(recentf-save-list): Catch and warn about errors.
Richard M. Stallman <rms@gnu.org>
parents:
54770
diff
changeset
|
1236 (warn "recentf mode: %s" (error-message-string error))))) |
32866
8ef794e21542
(recentf-mode): Variable removed.
Miles Bader <miles@gnu.org>
parents:
32429
diff
changeset
|
1237 |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
1238 (defun recentf-load-list () |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
1239 "Load a previously saved recent list. |
52638
2a2c48cb8b59
(recentf-initialize-file-name-history): New defcustom.
Eli Zaretskii <eliz@gnu.org>
parents:
52509
diff
changeset
|
1240 Read data from the file specified by `recentf-save-file'. |
2a2c48cb8b59
(recentf-initialize-file-name-history): New defcustom.
Eli Zaretskii <eliz@gnu.org>
parents:
52509
diff
changeset
|
1241 When `recentf-initialize-file-name-history' is non-nil, initialize an |
2a2c48cb8b59
(recentf-initialize-file-name-history): New defcustom.
Eli Zaretskii <eliz@gnu.org>
parents:
52509
diff
changeset
|
1242 empty `file-name-history' with the recent list." |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
1243 (interactive) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
1244 (let ((file (expand-file-name recentf-save-file))) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
1245 (when (file-readable-p file) |
52638
2a2c48cb8b59
(recentf-initialize-file-name-history): New defcustom.
Eli Zaretskii <eliz@gnu.org>
parents:
52509
diff
changeset
|
1246 (load-file file) |
2a2c48cb8b59
(recentf-initialize-file-name-history): New defcustom.
Eli Zaretskii <eliz@gnu.org>
parents:
52509
diff
changeset
|
1247 (and recentf-initialize-file-name-history |
2a2c48cb8b59
(recentf-initialize-file-name-history): New defcustom.
Eli Zaretskii <eliz@gnu.org>
parents:
52509
diff
changeset
|
1248 (not file-name-history) |
2a2c48cb8b59
(recentf-initialize-file-name-history): New defcustom.
Eli Zaretskii <eliz@gnu.org>
parents:
52509
diff
changeset
|
1249 (setq file-name-history (mapcar 'abbreviate-file-name |
2a2c48cb8b59
(recentf-initialize-file-name-history): New defcustom.
Eli Zaretskii <eliz@gnu.org>
parents:
52509
diff
changeset
|
1250 recentf-list)))))) |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
1251 |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
1252 (defun recentf-cleanup () |
65744
4bbd95905599
(recentf-filename-handlers): Rename from
David Ponce <david@dponce.com>
parents:
65525
diff
changeset
|
1253 "Cleanup the recent list. |
4bbd95905599
(recentf-filename-handlers): Rename from
David Ponce <david@dponce.com>
parents:
65525
diff
changeset
|
1254 That is, remove duplicates, non-kept, and excluded files." |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
1255 (interactive) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
1256 (message "Cleaning up the recentf list...") |
60844
5bb0c1e05b1b
(recentf-keep): New option.
David Ponce <david@dponce.com>
parents:
60740
diff
changeset
|
1257 (let ((n 0) newlist) |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
1258 (dolist (f recentf-list) |
65744
4bbd95905599
(recentf-filename-handlers): Rename from
David Ponce <david@dponce.com>
parents:
65525
diff
changeset
|
1259 (setq f (recentf-expand-file-name f)) |
60740
1e67e22bcc1b
(recentf-cleanup-remote): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
59996
diff
changeset
|
1260 (if (and (recentf-include-p f) |
65744
4bbd95905599
(recentf-filename-handlers): Rename from
David Ponce <david@dponce.com>
parents:
65525
diff
changeset
|
1261 (recentf-keep-p f) |
4bbd95905599
(recentf-filename-handlers): Rename from
David Ponce <david@dponce.com>
parents:
65525
diff
changeset
|
1262 (not (recentf-string-member f newlist))) |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
1263 (push f newlist) |
60844
5bb0c1e05b1b
(recentf-keep): New option.
David Ponce <david@dponce.com>
parents:
60740
diff
changeset
|
1264 (setq n (1+ n)) |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
1265 (message "File %s removed from the recentf list" f))) |
60844
5bb0c1e05b1b
(recentf-keep): New option.
David Ponce <david@dponce.com>
parents:
60740
diff
changeset
|
1266 (message "Cleaning up the recentf list...done (%d removed)" n) |
5bb0c1e05b1b
(recentf-keep): New option.
David Ponce <david@dponce.com>
parents:
60740
diff
changeset
|
1267 (setq recentf-list (nreverse newlist)))) |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
1268 |
30416 | 1269 ;;;###autoload |
32866
8ef794e21542
(recentf-mode): Variable removed.
Miles Bader <miles@gnu.org>
parents:
32429
diff
changeset
|
1270 (define-minor-mode recentf-mode |
30416 | 1271 "Toggle recentf mode. |
32866
8ef794e21542
(recentf-mode): Variable removed.
Miles Bader <miles@gnu.org>
parents:
32429
diff
changeset
|
1272 With prefix argument ARG, turn on if positive, otherwise off. |
8ef794e21542
(recentf-mode): Variable removed.
Miles Bader <miles@gnu.org>
parents:
32429
diff
changeset
|
1273 Returns non-nil if the new state is enabled. |
30416 | 1274 |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
1275 When recentf mode is enabled, it maintains a menu for visiting files |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
1276 that were operated on recently." |
32866
8ef794e21542
(recentf-mode): Variable removed.
Miles Bader <miles@gnu.org>
parents:
32429
diff
changeset
|
1277 :global t |
8ef794e21542
(recentf-mode): Variable removed.
Miles Bader <miles@gnu.org>
parents:
32429
diff
changeset
|
1278 :group 'recentf |
50715
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
1279 (unless (and recentf-mode (recentf-enabled-p)) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
1280 (if recentf-mode |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
1281 (recentf-load-list) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
1282 (recentf-save-list)) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
1283 (recentf-auto-cleanup) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
1284 (recentf-clear-data) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
1285 (let ((hook-setup (if recentf-mode 'add-hook 'remove-hook))) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
1286 (dolist (hook recentf-used-hooks) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
1287 (apply hook-setup hook))) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
1288 (run-hooks 'recentf-mode-hook) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
1289 (when (interactive-p) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
1290 (message "Recentf mode %sabled" (if recentf-mode "en" "dis")))) |
46229d46cbeb
Major rewrite. The code is reordered, cleaner and faster.
Juanma Barranquero <lekktu@gmail.com>
parents:
49549
diff
changeset
|
1291 recentf-mode) |
30416 | 1292 |
1293 (provide 'recentf) | |
1294 | |
1295 (run-hooks 'recentf-load-hook) | |
61733
34f8bb98e444
(recentf-save-file-coding-system): New variable.
Kenichi Handa <handa@m17n.org>
parents:
60844
diff
changeset
|
1296 |
63781
99d460dc50ca
Require 'tree-widget instead of 'wid-edit.
David Ponce <david@dponce.com>
parents:
63409
diff
changeset
|
1297 ;; arch-tag: 78f1eec9-0d16-4d19-a4eb-2e4529edb62a |
32429 | 1298 ;;; recentf.el ends here |