annotate lisp/recentf.el @ 64491:8764731ab214

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