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