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