annotate lisp/recentf.el @ 29658:7541a7e8924d

*** empty log message ***
author Kenichi Handa <handa@m17n.org>
date Thu, 15 Jun 2000 00:31:47 +0000
parents 94fe67994fcb
children d2eb35d88398
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
25997
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1 ;; recentf.el --- setup a menu of recently opened files
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2
29492
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
3 ;; Copyright (C) 1999, 2000 Free Software Foundation, Inc.
25997
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
4
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
5 ;; Author: David Ponce <david.ponce@wanadoo.fr>
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
6 ;; Created: July 19 1999
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
7 ;; Keywords: customization
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
8
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
9 ;; This file is part of GNU Emacs.
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
10
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
12 ;; it under the terms of the GNU General Public License as published by
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
13 ;; the Free Software Foundation; either version 2, or (at your option)
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
14 ;; any later version.
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
15
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
16 ;; GNU Emacs is distributed in the hope that it will be useful,
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
19 ;; GNU General Public License for more details.
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
20
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
24 ;; Boston, MA 02111-1307, USA.
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
25
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
26 ;;; Commentary:
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
27
29492
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
28 ;; This package maintains a menu for visiting files that were operated
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
29 ;; on recently. When enabled a new "Open Recent" submenu is displayed
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
30 ;; in the "Files" menu. The recent files list is automatically saved
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
31 ;; across Emacs sessions. You can customize the number of recent
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
32 ;; files displayed, the location of the menu and others options (see
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
33 ;; the source code for details). To install and use, put the file on
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
34 ;; your Emacs-Lisp load path and add the following into your ~/.emacs
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
35 ;; startup file:
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
36 ;;
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
37 ;; (require 'recentf)
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
38 ;; (recentf-mode 1)
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
39
25997
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
40 ;;; Code:
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
41
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
42 (require 'easymenu)
29492
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
43 (require 'wid-edit)
25997
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
44
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
45 (defconst recentf-save-file-header
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
46 ";;; Automatically generated by `recentf' on %s.\n"
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
47 "Header to be written into the `recentf-save-file'.")
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
48
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
49 (defvar recentf-list nil
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
50 "List of recently opened files.")
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
51
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
52 (defvar recentf-update-menu-p t
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
53 "Non-nil if the recentf menu must be updated.")
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
54
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
55 (defvar recentf-initialized-p nil
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
56 "Non-nil if recentf already initialized.")
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
57
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
58 ;; IMPORTANT: This function must be defined before the following defcustoms
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
59 ;; because it is used in their :set clause. To avoid byte-compiler warnings
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
60 ;; the `symbol-value' function is used to access the `recentf-menu-path'
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
61 ;; and `recentf-menu-title' values.
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
62 (defun recentf-menu-customization-changed (sym val)
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
63 "Function called when menu customization has changed.
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
64 It removes the recentf menu and forces its complete redrawing."
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
65 (when recentf-initialized-p
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
66 (easy-menu-remove-item nil
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
67 (symbol-value 'recentf-menu-path)
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
68 (symbol-value 'recentf-menu-title))
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
69 (setq recentf-update-menu-p t))
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
70 (custom-set-default sym val))
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
71
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
72 (defgroup recentf nil
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
73 "Maintain a menu of recently opened files."
27580
b84ee89aaf37 (recentf): Add :version to defgroup.
Dave Love <fx@gnu.org>
parents: 25997
diff changeset
74 :version "21.1"
25997
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
75 :group 'files)
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
76
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
77 (defcustom recentf-max-saved-items 20
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
78 "*Maximum number of items saved to `recentf-save-file'."
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
79 :group 'recentf
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
80 :type 'integer)
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
81
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
82 (defcustom recentf-save-file (expand-file-name "~/.recentf")
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
83 "*File to save `recentf-list' into."
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
84 :group 'recentf
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
85 :type 'file)
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
86
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
87 (defcustom recentf-exclude nil
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
88 "*List of regexps for filenames excluded from `recentf-list'."
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
89 :group 'recentf
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
90 :type '(repeat regexp))
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
91
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
92 (defcustom recentf-menu-title "Open Recent"
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
93 "*Name of the recentf menu."
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
94 :group 'recentf
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
95 :type 'string
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
96 :set 'recentf-menu-customization-changed)
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
97
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
98 (defcustom recentf-menu-path '("files")
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
99 "*Path where to add the recentf menu.
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
100 If nil add it at top-level (see also `easy-menu-change')."
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
101 :group 'recentf
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
102 :type '(choice (const :tag "Top Level" nil)
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
103 (sexp :tag "Menu Path"))
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
104 :set 'recentf-menu-customization-changed)
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
105
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
106 (defcustom recentf-menu-before "open-file"
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
107 "*Name of the menu before which the recentf menu will be added.
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
108 If nil add it at end of menu (see also `easy-menu-change')."
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
109 :group 'recentf
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
110 :type '(choice (string :tag "Name")
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
111 (const :tag "Last" nil))
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
112 :set 'recentf-menu-customization-changed)
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
113
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
114 (defcustom recentf-menu-action 'recentf-find-file
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
115 "*Function to invoke with a filename item of the recentf menu.
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
116 The default action `recentf-find-file' calls `find-file' to edit an
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
117 existing file. If the file does not exist or is not readable, it is
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
118 not edited and its name is removed from `recentf-list'. You can use
27920
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
119 `find-file' instead to open non-existing files and keep them in the
25997
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
120 list of recently opened files."
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
121 :group 'recentf
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
122 :type 'function
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
123 :set 'recentf-menu-customization-changed)
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
124
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
125 (defcustom recentf-max-menu-items 10
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
126 "*Maximum number of items in the recentf menu."
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
127 :group 'recentf
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
128 :type 'integer
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
129 :set 'recentf-menu-customization-changed)
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
130
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
131 (defcustom recentf-menu-filter nil
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
132 "*Function used to filter files displayed in the recentf menu.
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
133 Nil means no filter. The following functions are predefined:
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
134
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
135 - - `recentf-sort-ascending' to sort menu items in ascending order.
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
136 - - `recentf-sort-descending' to sort menu items in descending order.
29492
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
137 - - `recentf-sort-basenames-ascending' to sort file names in descending order.
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
138 - - `recentf-sort-basenames-descending' to sort file names in descending order.
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
139 - - `recentf-show-basenames' to show file names (no directories) in menu items.
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
140 - - `recentf-show-basenames-ascending' to show file names in ascending order.
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
141 - - `recentf-show-basenames-descending' to show file names in descending order.
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
142 - - `recentf-relative-filter' to show file names relative to `default-directory'.
25997
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
143
29492
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
144 The filter function is called with one argument, the list of menu elements
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
145 used to build the menu and must return a new list of menu elements (see
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
146 `recentf-menu-elements' for menu element form)."
25997
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
147 :group 'recentf
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
148 :type 'function
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
149 :set 'recentf-menu-customization-changed)
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
150
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
151 (defcustom recentf-menu-append-commands-p t
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
152 "*If not-nil command items are appended to the menu."
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
153 :group 'recentf
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
154 :type 'boolean
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
155 :set 'recentf-menu-customization-changed)
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
156
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
157 (defcustom recentf-keep-non-readable-files-p nil
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
158 "*If nil (default), non-readable files are not kept in `recentf-list'."
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
159 :group 'recentf
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
160 :type 'boolean
28042
0e8cc641145e (recentf-keep-non-readable-files-p): Add :set,
Dave Love <fx@gnu.org>
parents: 28032
diff changeset
161 :require 'recentf
0e8cc641145e (recentf-keep-non-readable-files-p): Add :set,
Dave Love <fx@gnu.org>
parents: 28032
diff changeset
162 :initialize 'custom-initialize-default
29492
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
163 :set (lambda (sym val)
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
164 (if val
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
165 (remove-hook 'kill-buffer-hook 'recentf-remove-file-hook)
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
166 (add-hook 'kill-buffer-hook 'recentf-remove-file-hook))
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
167 (custom-set-default sym val)))
25997
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
168
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
169 (defcustom recentf-mode nil
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
170 "Toggle recentf mode.
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
171 When recentf mode is enabled, it maintains a menu for visiting files that
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
172 were operated on recently.
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
173 Setting this variable directly does not take effect;
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
174 use either \\[customize] or the function `recentf-mode'."
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
175 :set (lambda (symbol value)
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
176 (recentf-mode (or value 0)))
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
177 :initialize 'custom-initialize-default
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
178 :type 'boolean
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
179 :group 'recentf
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
180 :require 'recentf)
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
181
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
182 (defcustom recentf-load-hook nil
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
183 "*Normal hook run at end of loading the `recentf' package."
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
184 :group 'recentf
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
185 :type 'hook)
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
186
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
187 ;;;###autoload
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
188 (defun recentf-mode (&optional arg)
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
189 "Toggle recentf mode.
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
190 With prefix ARG, turn recentf mode on if and only if ARG is positive.
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
191 Returns the new status of recentf mode (non-nil means on).
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
192
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
193 When recentf mode is enabled, it maintains a menu for visiting files that
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
194 were operated on recently."
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
195 (interactive "P")
27920
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
196 (let ((on-p (if arg
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
197 (> (prefix-numeric-value arg) 0)
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
198 (not recentf-mode))))
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
199 (if on-p
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
200 (unless recentf-initialized-p
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
201 (setq recentf-initialized-p t)
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
202 (if (file-readable-p recentf-save-file)
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
203 (load-file recentf-save-file))
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
204 (setq recentf-update-menu-p t)
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
205 (add-hook 'find-file-hooks 'recentf-add-file-hook)
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
206 (add-hook 'write-file-hooks 'recentf-add-file-hook)
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
207 ;; (add-hook 'activate-menubar-hook 'recentf-update-menu-hook)
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
208 (add-hook 'menu-bar-update-hook 'recentf-update-menu-hook)
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
209 (add-hook 'kill-emacs-hook 'recentf-save-list))
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
210 (when recentf-initialized-p
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
211 (setq recentf-initialized-p nil)
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
212 (recentf-save-list)
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
213 (easy-menu-remove-item nil recentf-menu-path recentf-menu-title)
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
214 (remove-hook 'find-file-hooks 'recentf-add-file-hook)
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
215 (remove-hook 'write-file-hooks 'recentf-add-file-hook)
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
216 ;; (remove-hook 'activate-menubar-hook 'recentf-update-menu-hook)
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
217 (remove-hook 'menu-bar-update-hook 'recentf-update-menu-hook)
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
218 (remove-hook 'kill-emacs-hook 'recentf-save-list)))
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
219 (setq recentf-mode on-p)))
25997
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
220
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
221 (defun recentf-add-file-hook ()
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
222 "Insert the name of the file just opened or written into `recentf-list'."
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
223 (and buffer-file-name (recentf-add-file buffer-file-name))
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
224 nil)
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
225
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
226 (defun recentf-remove-file-hook ()
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
227 "When a buffer is killed remove a non readable file from `recentf-list'."
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
228 (and buffer-file-name (recentf-remove-if-non-readable buffer-file-name))
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
229 nil)
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
230
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
231 (defun recentf-update-menu-hook ()
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
232 "Update the recentf menu from the current `recentf-list'."
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
233 (when recentf-update-menu-p
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
234 (condition-case nil
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
235 (progn
29492
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
236 (setq recentf-update-menu-p nil)
25997
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
237 (easy-menu-change recentf-menu-path
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
238 recentf-menu-title
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
239 (recentf-make-menu-items)
29492
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
240 recentf-menu-before))
25997
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
241 (error nil))))
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
242
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
243 ;;;###autoload
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
244 (defun recentf-save-list ()
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
245 "Save the current `recentf-list' to the file `recentf-save-file'."
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
246 (interactive)
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
247 (let ((saved-list (recentf-elements recentf-max-saved-items)))
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
248 (with-temp-buffer
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
249 (erase-buffer)
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
250 (insert (format recentf-save-file-header (current-time-string)))
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
251 (insert "(setq recentf-list\n '(\n")
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
252 (mapcar '(lambda (e)
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
253 (insert (format " %S\n" e)))
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
254 saved-list)
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
255 (insert " ))")
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
256 (if (file-writable-p recentf-save-file)
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
257 (write-region (point-min) (point-max) recentf-save-file))
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
258 (kill-buffer (current-buffer))))
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
259 nil)
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
260
27920
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
261 (defvar recentf-edit-selected-items nil
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
262 "Used by `recentf-edit-list' to hold the list of files to be deleted
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
263 from `recentf-list'.")
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
264
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
265 (defun recentf-edit-list-action (widget &rest ignore)
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
266 "Checkbox widget action used by `recentf-edit-list' to select/unselect a file."
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
267 (let ((value (widget-get widget ':tag)))
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
268 ;; if value is already in the selected items
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
269 (if (memq value recentf-edit-selected-items)
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
270 ;; then remove it
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
271 (progn
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
272 (setq recentf-edit-selected-items
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
273 (delq value recentf-edit-selected-items))
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
274 (message "%s removed from selection." value))
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
275 ;; else add it
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
276 (progn
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
277 (setq recentf-edit-selected-items
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
278 (nconc (list value) recentf-edit-selected-items))
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
279 (message "%s added to selection." value)))))
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
280
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
281 ;;;###autoload
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
282 (defun recentf-edit-list ()
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
283 "Allow the user to edit the files that are kept in the recent list."
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
284 (interactive)
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
285 (with-current-buffer (get-buffer-create (concat "*" recentf-menu-title " - Edit list*"))
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
286 (switch-to-buffer (current-buffer))
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
287 (kill-all-local-variables)
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
288 (let ((inhibit-read-only t))
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
289 (erase-buffer))
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
290 (let ((all (overlay-lists)))
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
291 ;; Delete all the overlays.
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
292 (mapcar 'delete-overlay (car all))
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
293 (mapcar 'delete-overlay (cdr all)))
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
294 (setq recentf-edit-selected-items nil)
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
295 ;; Insert the dialog header
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
296 (widget-insert "Select the files to be deleted from the 'recentf-list'.\n\n")
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
297 (widget-insert "Click on Ok to update the list or on Cancel to quit.\n" )
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
298 ;; Insert the list of files as checkboxes
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
299 (mapcar '(lambda (item)
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
300 (widget-create 'checkbox
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
301 :value nil ; unselected checkbox
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
302 :format "\n %[%v%] %t"
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
303 :tag item
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
304 :notify 'recentf-edit-list-action))
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
305 recentf-list)
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
306 (widget-insert "\n\n")
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
307 ;; Insert the Ok button
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
308 (widget-create 'push-button
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
309 :notify (lambda (&rest ignore)
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
310 (if recentf-edit-selected-items
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
311 (progn (kill-buffer (current-buffer))
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
312 (mapcar '(lambda (item)
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
313 (setq recentf-list
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
314 (delq item recentf-list)))
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
315 recentf-edit-selected-items)
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
316 (message "%S file(s) removed from the list"
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
317 (length recentf-edit-selected-items))
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
318 (setq recentf-update-menu-p t))
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
319 (message "No file selected.")))
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
320 "Ok")
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
321 (widget-insert " ")
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
322 ;; Insert the Cancel button
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
323 (widget-create 'push-button
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
324 :notify (lambda (&rest ignore)
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
325 (kill-buffer (current-buffer))
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
326 (message "Command canceled."))
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
327 "Cancel")
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
328 (use-local-map widget-keymap)
29492
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
329 (widget-setup)
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
330 (goto-char (point-min))))
27920
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
331
25997
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
332 ;;;###autoload
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
333 (defun recentf-cleanup ()
27920
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
334 "Remove all non-readable and excluded files from `recentf-list'."
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
335 (interactive)
29492
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
336 (let ((count (length recentf-list)))
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
337 (setq recentf-list
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
338 (delq nil
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
339 (mapcar '(lambda (filename)
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
340 (and (file-readable-p filename)
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
341 (recentf-include-p filename)
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
342 filename))
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
343 recentf-list)))
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
344 (setq count (- count (length recentf-list)))
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
345 (message "%s removed from the list"
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
346 (cond ((= count 0) "No file")
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
347 ((= count 1) "One file")
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
348 (t (format "%d files" count)))))
27920
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
349 (setq recentf-update-menu-p t))
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
350
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
351 (defun recentf-open-more-files-action (widget &rest ignore)
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
352 "Button widget action used by `recentf-open-more-files' to open a file."
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
353 (kill-buffer (current-buffer))
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
354 (funcall recentf-menu-action (widget-value widget)))
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
355
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
356 ;;;###autoload
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
357 (defun recentf-open-more-files ()
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
358 "Allow the user to open files that are not in the menu."
25997
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
359 (interactive)
27920
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
360 (with-current-buffer (get-buffer-create (concat "*" recentf-menu-title " - More*"))
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
361 (switch-to-buffer (current-buffer))
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
362 (kill-all-local-variables)
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
363 (let ((inhibit-read-only t))
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
364 (erase-buffer))
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
365 (let ((all (overlay-lists)))
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
366 ;; Delete all the overlays.
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
367 (mapcar 'delete-overlay (car all))
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
368 (mapcar 'delete-overlay (cdr all)))
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
369 ;; Insert the dialog header
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
370 (widget-insert "Click on a file to open it or on Cancel to quit.\n\n")
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
371 ;; Insert the list of files as buttons
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
372 (mapcar '(lambda (menu-element)
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
373 (let ((menu-item (car menu-element))
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
374 (file-path (cdr menu-element)))
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
375 (widget-create 'push-button
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
376 :button-face 'default
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
377 :tag menu-item
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
378 :help-echo (concat "Open " file-path)
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
379 :format "%[%t%]"
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
380 :notify 'recentf-open-more-files-action
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
381 file-path)
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
382 (widget-insert "\n")))
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
383 (funcall (or recentf-menu-filter 'identity)
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
384 (mapcar '(lambda (item) (cons item item))
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
385 (nthcdr recentf-max-menu-items recentf-list))))
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
386 (widget-insert "\n")
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
387 ;; Insert the Cancel button
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
388 (widget-create 'push-button
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
389 :notify (lambda (&rest ignore)
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
390 (kill-buffer (current-buffer))
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
391 (message "Command canceled."))
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
392 "Cancel")
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
393 (use-local-map widget-keymap)
29492
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
394 (widget-setup)
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
395 (goto-char (point-min))))
25997
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
396
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
397 (defvar recentf-menu-items-for-commands
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
398 (list ["Cleanup list" recentf-cleanup t]
27920
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
399 ["Edit list..." recentf-edit-list t]
25997
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
400 ["Save list now" recentf-save-list t]
27920
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
401 (vector "Recentf Options..." '(customize-group "recentf") t))
25997
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
402 "List of menu items for recentf commands.")
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
403
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
404 (defun recentf-make-menu-items ()
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
405 "Make menu items from `recentf-list'."
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
406 (let ((file-items
29492
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
407 (mapcar 'recentf-make-menu-item
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
408 (funcall (or recentf-menu-filter 'identity)
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
409 (recentf-menu-elements recentf-max-menu-items)))))
25997
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
410 (append (or file-items (list ["No files" t nil]))
27920
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
411 (and (< recentf-max-menu-items (length recentf-list))
8f8b86890eb3 (recentf): Added version tag to the defgroup of
Gerd Moellmann <gerd@gnu.org>
parents: 27580
diff changeset
412 (list ["More..." recentf-open-more-files t]))
25997
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
413 (and recentf-menu-append-commands-p
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
414 (cons ["---" nil nil]
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
415 recentf-menu-items-for-commands)))))
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
416
29492
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
417 (defun recentf-make-menu-item (menu-element)
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
418 "Make a menu item from a menu element (see `recentf-menu-elements')."
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
419 (vector (car menu-element) (list recentf-menu-action (cdr menu-element)) t))
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
420
25997
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
421 (defun recentf-add-file (filename)
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
422 "Add or move FILENAME at the beginning of `recentf-list'.
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
423 Does nothing if FILENAME matches one of the `recentf-exclude' regexps."
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
424 (when (recentf-include-p filename)
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
425 (setq recentf-list (cons filename (delete filename recentf-list)))
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
426 (setq recentf-update-menu-p t)))
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
427
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
428 (defun recentf-remove-if-non-readable (filename)
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
429 "Remove FILENAME from `recentf-list' if not readable."
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
430 (unless (file-readable-p filename)
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
431 (setq recentf-list (delete filename recentf-list))
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
432 (setq recentf-update-menu-p t)))
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
433
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
434 (defun recentf-find-file (filename)
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
435 "Edit file FILENAME using `find-file'.
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
436 If FILENAME is not readable it is removed from `recentf-list'."
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
437 (if (file-readable-p filename)
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
438 (find-file filename)
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
439 (progn
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
440 (message "File `%s' not found." filename)
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
441 (setq recentf-list (delete filename recentf-list))
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
442 (setq recentf-update-menu-p t))))
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
443
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
444 (defun recentf-include-p (filename)
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
445 "Return t if FILENAME matches none of the `recentf-exclude' regexps."
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
446 (let ((rl recentf-exclude))
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
447 (while (and rl (not (string-match (car rl) filename)))
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
448 (setq rl (cdr rl)))
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
449 (null rl)))
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
450
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
451 (defun recentf-elements (n)
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
452 "Return a list of the first N elements of `recentf-list'."
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
453 (let ((lh nil) (l recentf-list))
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
454 (while (and l (> n 0))
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
455 (setq lh (cons (car l) lh))
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
456 (setq n (1- n))
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
457 (setq l (cdr l)))
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
458 (nreverse lh)))
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
459
29492
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
460 (defun recentf-menu-elements (n)
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
461 "Return a list of the first N menu elements from `recentf-list'.
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
462 Each menu element has this form:
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
463
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
464 (MENU-ITEM . FILE-PATH)
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
465
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
466 MENU-ITEM is the menu item string displayed.
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
467
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
468 FILE-PATH is the path used to open the file when the corresponding MENU-ITEM
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
469 is selected.
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
470
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
471 At the start each MENU-ITEM is set to its corresponding FILE-PATH."
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
472 (mapcar '(lambda (item) (cons item item)) (recentf-elements n)))
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
473
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
474
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
475 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
476 ;; Predefined menu filter functions ;;
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
477 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
478
25997
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
479 (defun recentf-sort-ascending (l)
29492
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
480 "Sort the list of menu elements L in ascending order.
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
481 The MENU-ITEM part of each menu element is compared."
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
482 (sort l '(lambda (e1 e2) (string-lessp (car e1) (car e2)))))
25997
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
483
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
484 (defun recentf-sort-descending (l)
29492
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
485 "Sort the list of menu elements L in descending order.
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
486 The MENU-ITEM part of each menu element is compared."
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
487 (sort l '(lambda (e1 e2) (string-lessp (car e2) (car e1)))))
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
488
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
489 (defun recentf-sort-basenames-ascending (l)
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
490 "Sort the list of menu elements L in ascending order.
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
491 Only file names (without directories) are compared."
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
492 (sort l '(lambda (e1 e2) (string-lessp
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
493 (file-name-nondirectory (cdr e1))
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
494 (file-name-nondirectory (cdr e2))))))
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
495
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
496 (defun recentf-sort-basenames-descending (l)
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
497 "Sort the list of menu elements L in descending order.
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
498 Only file names (without directories) are compared."
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
499 (sort l '(lambda (e1 e2) (string-lessp
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
500 (file-name-nondirectory (cdr e2))
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
501 (file-name-nondirectory (cdr e1))))))
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
502
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
503 (defun recentf-show-basenames (l)
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
504 "Filter the list of menu elements L to show only file names (no directories)
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
505 in the menu. When file names are duplicated their directory component is added."
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
506 (let ((names (mapcar '(lambda (item) (file-name-nondirectory (cdr item))) l))
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
507 (dirs (mapcar '(lambda (item) (file-name-directory (cdr item))) l))
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
508 (pathes (mapcar 'cdr l))
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
509 (pos -1)
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
510 item filtered-items filtered-list)
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
511 (while names
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
512 (setq item (car names))
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
513 (setq names (cdr names))
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
514 (setq pos (1+ pos))
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
515 (setq filtered-list
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
516 (cons (cons (if (or (member item names) (member item filtered-items))
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
517 (concat item " (" (nth pos dirs) ")")
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
518 item)
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
519 (nth pos pathes))
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
520 filtered-list))
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
521 (setq filtered-items (cons item filtered-items)))
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
522 (nreverse filtered-list)))
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
523
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
524 (defun recentf-show-basenames-ascending (l)
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
525 "Filter the list of menu elements L to show only file names in the menu,
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
526 sorted in ascending order. This filter combines the `recentf-sort-basenames-ascending'
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
527 and `recentf-show-basenames' filters."
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
528 (recentf-show-basenames (recentf-sort-basenames-ascending l)))
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
529
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
530 (defun recentf-show-basenames-descending (l)
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
531 "Filter the list of menu elements L to show only file names in the menu,
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
532 sorted in descending order. This filter combines the `recentf-sort-basenames-descending'
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
533 and `recentf-show-basenames' filters."
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
534 (recentf-show-basenames (recentf-sort-basenames-descending l)))
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
535
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
536 (defun recentf-relative-filter (l)
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
537 "Filter the list of `recentf-menu-elements' L to show filenames
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
538 relative to `default-directory'."
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
539 (setq recentf-update-menu-p t) ; force menu update
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
540 (mapcar '(lambda (menu-element)
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
541 (let* ((ful-path (cdr menu-element))
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
542 (rel-path (file-relative-name ful-path)))
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
543 (if (string-match "^\\.\\." rel-path)
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
544 menu-element
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
545 (cons rel-path ful-path))))
94fe67994fcb Fixed recentf-edit-list and recentf-open-more-files
Gerd Moellmann <gerd@gnu.org>
parents: 28115
diff changeset
546 l))
25997
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
547
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
548 (provide 'recentf)
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
549
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
550 (run-hooks 'recentf-load-hook)
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
551
40b9e5591aac New file. Setup a menu of recently opened files
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
552 ;;; recentf.el ends here.