annotate lisp/recentf.el @ 52543:ead8baf4d882

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