annotate lisp/packages/recent-files.el @ 0:376386a54a3c r19-14

Import from CVS: tag r19-14
author cvs
date Mon, 13 Aug 2007 08:45:50 +0200
parents
children 131b0175ea99
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; recent-files.el --- Maintain menu of recently opened files.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 ;;; $Header: /afs/informatik.uni-tuebingen.de/local/web/xemacs/xemacs-cvs/XEmacs/xemacs-19/lisp/packages/recent-files.el,v 1.1.1.1 1996/12/18 03:31:56 steve Exp $
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;;; Copyright (C) 1994, 1995 Juergen Nickelsen <nickel@cs.tu-berlin.de>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; Keywords: menu, file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;; This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;; XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; XEmacs is distributed in the hope that it will be useful, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;; General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;; along with XEmacs; see the file COPYING. If not, write to the Free
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;; Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;;; Synched up with: Not in FSF.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;;; recent-files.el is free software; you can redistribute it and/or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;;; modify it under the terms of the GNU General Public License as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;;; published by the Free Software Foundation; either version 2, or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;;; (at your option) any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;;; It is distributed in the hope that it will be useful, but WITHOUT
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 ;;; License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 ;;; You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 ;;; along with XEmacs; see the file COPYING. If not, write to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 ;;; Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 ;;; ------------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 ;;; Enough of this boring stuff. To install recent-files, put the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 ;;; following statements into your .emacs file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 ;;; (load "recent-files")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 ;;; (recent-files-initialize)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 ;;; and place the file recent-files.el in a directory in your XEmacs's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 ;;; load-path. In order to use recent-files with dired, dired has to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 ;;; be loaded first. recent-files is known to work with Lucid Emacs /
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 ;;; XEmacs 19.8 and higher; it does not work correctly with 19.6 or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 ;;; earlier versions due to a bug in add-menu.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 ;;; recent-files adds the menu "Recent Files" (or whatever name you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 ;;; choose, see "Customization:" below) to Emacs's menubar. Its
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 ;;; entries are the files (and directories) that have recently been
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 ;;; opened by Emacs. You can open one of these files again by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 ;;; selecting its entry in the "Recent Files" menu. The list of file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 ;;; entries in this menu is preserved from one Emacs session to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 ;;; another. You can prevent Emacs from saving this list by selecting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 ;;; "Don't save recent-files list on exit" from the menu. If you have
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 ;;; disabled saving, you can re-enable it by selecting "Save
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 ;;; recent-files list on exit".
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 ;;; The menu has permanent and non-permanent entries. Permanent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 ;;; entries are marked with an asterisk in front of the filename. The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 ;;; non-permanent entries are hidden in a submenu.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 ;;; Each time you open a file in Emacs, it is added as a non-permanent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 ;;; entry to the menu. The value of `recent-files-number-of-entries'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 ;;; determines how many non-permanent entries are held in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 ;;; menu. When the number of non-permanent entries reaches this value,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 ;;; the least recently added non-permanent entry is removed from the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 ;;; menu when another non-permanent entry is added. It is not removed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 ;;; from the list, though; it may reappear when entries are deleted
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 ;;; from the list. The number of entries saved to disk is the value of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 ;;; the variable `recent-files-number-of-saved-entries'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 ;;; Permanent entries are not removed from the menu. You can make a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 ;;; file entry permanent by selecting "Make <buffer> permanent" (where
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 ;;; <buffer> is the name of the current buffer) when the current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 ;;; buffer holds this file. "Make <buffer> non-permanent" makes the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 ;;; file entry of the current buffer non-permanent.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 ;;; The command "Kill buffer <buffer> and delete entry" is handy when
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 ;;; you have accidently opened a file but want to keep neither the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 ;;; buffer nor the entry.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 ;;; You can erase the list of non-permanent entries by selecting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 ;;; "Erase non-permanent entries" from the menu.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 ;;; Customization:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 ;;; There are lots of variables to control the behaviour of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 ;;; recent-files. You do not have to change any of them if you like it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 ;;; as it comes out of the box. However, you may want to look at these
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 ;;; options to make it behave different.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 ;;; `recent-files-number-of-entries'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 ;;; Controls how many non-permanent entries are shown in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 ;;; recent-files list. The default is 15.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 ;;; `recent-files-number-of-saved-entries'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 ;;; Controls how many non-permanent entries are saved to disk when
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 ;;; Emacs exits or recent-files-save-the-list is called. The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 ;;; default is 50.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 ;;; `recent-files-save-file'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 ;;; The name of the file where the recent-files list is saved
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 ;;; between Emacs session. You probably don't need to change this.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 ;;; The default is ".recent-files.el" in your home directory.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 ;;; `recent-files-dont-include'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 ;;; A list of regular expressions for files that should not be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 ;;; included into the recent-files list. This list is empty by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 ;;; default. For instance, a list to exclude all .newsrc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 ;;; files, all auto-save-files, and all files in the /tmp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 ;;; directory (but not the /tmp directory itself) would look
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 ;;; like this:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 ;;; (setq recent-files-dont-include
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 ;;; '("/\\.newsrc" "~$" "^/tmp/."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 ;;; The default is empty.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 ;;; `recent-files-use-full-names'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 ;;; If the value of this variable is non-nil, the full pathnames of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 ;;; the files are shown in the recent-files menu. Otherwise only
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 ;;; the filename part (or the last name component if it is a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 ;;; directory) is shown in the menu. The default it t, i.e. show
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 ;;; full names.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 ;;; `recent-files-filename-replacements'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 ;;; This is a list of pairs of regular expressions and replacement
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 ;;; strings. If a filename matches one of the regular expressions,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 ;;; the matching part is replaced by the replacement string for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 ;;; display in the recent-files menu.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 ;;; Example: My home directory is "/users/mmc/nickel/". I want to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 ;;; replace it with "~/". I also want to replace the directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 ;;; "/imports/teleservices/mmc/avc2/", where I work a lot, with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 ;;; ".../avc2/". The list then looks like
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 ;;; (setq recent-files-filename-replacements
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 ;;; '(("/users/mmc/nickel/" . "~/")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 ;;; ("/imports/teleservices/mmc/avc2/" . ".../avc2/")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 ;;; Only the first match is replaced. So, if you have several
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 ;;; entries in this list that may match a filename simultaneously,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 ;;; put the one you want to match (usually the most special) in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 ;;; front of the others. The default is to replace the home
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 ;;; directory with "~".
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 ;;; `recent-files-sort-function'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 ;;; Contains a function symbol to sort the display of filenames in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 ;;; the recent-files menu. Supplied are two functions,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 ;;; 'recent-files-dont-sort and 'recent-files-sort-alphabetically.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 ;;; The first, which is the default, preserves the order of "most
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 ;;; recent on top".
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 ;;; `recent-files-permanent-submenu'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 ;;; If this variable is non-nil, the permanent entries are put into
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 ;;; a separate submenu of the recent-files menu. The default is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 ;;; nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 ;;; `recent-files-non-permanent-submenu'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 ;;; If this variable is non-nil, the non-permanent entries are put
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 ;;; into a separate submenu of the recent-files menu. The default
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 ;;; is nil. (You can set both `recent-files-permanent-submenu' and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 ;;; `recent-files-non-permanent-submenu' to t to have both lists in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 ;;; separate submenus.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 ;;; `recent-files-commands-submenu'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 ;;; If this variable is non-nil, the commands if recent-files are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 ;;; placed in a submenu of the recent-files menu. The default is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 ;;; nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 ;;; `recent-files-commands-submenu-title'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 ;;; If the commands are placed in a submenu, this string is used as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 ;;; the title of the submenu. The default is "Commands...".
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 ;;; `recent-files-actions-on-top'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 ;;; If this variable is non-nil, the "action" menu entries ("Make
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 ;;; <buffer> permanent" etc.) are put on top of the menu. Otherwise
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 ;;; they appear below the file entries or submenus. The default is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 ;;; nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 ;;; `recent-files-permanent-first'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 ;;; If this variable is t, the permanent entries are put first in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 ;;; the recent-files menu, i.e. above the non-permanent entries. If
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 ;;; the value is nil, non-permanent entries appear first. If the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 ;;; value is neither t nor nil, the entries are sorted according to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 ;;; recent-files-sort-function. The default is 'sort.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 ;;; `recent-files-find-file-command'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 ;;; This variable contains to commandto execute when a file entry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 ;;; is selected from the menu. Usually this will be `find-file',
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 ;;; which is the default.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 ;;; KNOWN BUG:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 ;;; - recent-files overwrites the recent-files-save-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 ;;; unconditionally when Emacs exits. If you have two Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 ;;; processes running, the one exiting later will overwrite the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 ;;; file without merging in the new entries from the other Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 ;;; process. This can be avoided by disabling the save on exit from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 ;;; the menu.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 (if (not (string-match "XEmacs" (emacs-version)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 (error "recent-files works with Lucid Emacs / XEmacs only."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 (provide 'recent-files)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 ;;; User options
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 (defvar recent-files-number-of-entries 15
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 "*Maximum of non-permanent entries in the recent-files menu.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 (defvar recent-files-number-of-saved-entries 50
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 "*Maximum of non-permanent entries saved to `recent-files-save-file'.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (defvar recent-files-save-file (expand-file-name "~/.recent-files.el")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 "*File to save the recent-files list in.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 (defvar recent-files-dont-include nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 "*List of regexps for filenames *not* to keep in recent-files.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 (defvar recent-files-use-full-names t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 "*If non-nil, use the full pathname of a file in the recent-files menu.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 Otherwise use only the filename part. The `recent-files-filename-replacements'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 are not applied in the latter case.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (defvar recent-files-filename-replacements
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 (list (cons (expand-file-name "~") "~"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 "*List of regexp/replacement pairs for filename filenamees.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 If a filename of a filename matches one of the regexps, it is replaced
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 by the corresponding replacement.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (defvar recent-files-sort-function (function recent-files-dont-sort)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 "*Function to sort the recent-files list with.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 The value `recent-files-dont-sort' means to keep the \"most recent on top\"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 order.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (defvar recent-files-permanent-submenu nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 "*If non-nil, put the permanent entries of recent-files into a submenu.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 (defvar recent-files-non-permanent-submenu t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 "*If non-nil, put the non-permanent entries of recent-files into a submenu.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 (defvar recent-files-commands-submenu nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 "*If non-nil, put the commands of recent-files into a submenu.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 (defvar recent-files-commands-submenu-title "Commands..."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 "*Title of the commands submenu of recent-files.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 (defvar recent-files-menu-title "Recent Files"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 "*Name to be displayed as title of the recent-files menu.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 (defvar recent-files-menu-path nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 "*Path where to add the recent-files menu.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 A value of nil means add it as top-level menu.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 For more information look up the documentation of `add-menu'.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 (defvar recent-files-add-menu-before nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 "*Name of the menu before which the recent-files menu shall be added.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 A value of nil means add it as the last menu in recent-files-menu-path.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 For more information look up the documentation of `add-menu'.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 (defvar recent-files-actions-on-top nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 "*If non-nil, put the actions on top of the recent-files menu.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 (defvar recent-files-permanent-first 'sort
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 "*Control the placement of entries in the recent-files menu.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 If the value is t, permanent entries are put first.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 If the value is nil, non-permanent entries are put first.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 If the value is neither, the entries are mixed following
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 recent-files-sort-function if neither appear in a submenu.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 (defvar recent-files-find-file-command (function find-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 "*Command to invoke with an entry of the recent-files list.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 (defvar recent-files-include-save-now nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 "*If non-nil, have a menu entry to save the recent-files list immediately.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 ;;; Internal variables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 (defconst recent-files-save-list-on-exit t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 "If non-nil, save the recent-files list on exit.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 This value is toggled by a menu entry.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 (defvar recent-files-list nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 "List of recently opened files.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 Entries are pairs like (<filename> . <permant-p>).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 If <permanent-p> is non-nil, the file stays permanently in the list.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 (defvar recent-files-commands-menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 '(list (vector (concat "Make " lastpart " permanent")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 (function recent-files-make-permanent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 (and lastpart
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 (not (recent-files-permanent-p filename))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 ;; (not (not ...)) is needed to enforce t for non-nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 (not (not (recent-files-retrieve-entry filename)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 (vector (concat "Make " lastpart " non-permanent")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 (function recent-files-make-non-permanent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 (and lastpart
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 (recent-files-permanent-p filename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 (not (not (recent-files-retrieve-entry filename)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 (vector "Erase non-permanent entries"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 (function recent-files-erase-non-permanent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 (vector (if recent-files-save-list-on-exit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 "Don't save recent-files list on exit"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 "Save recent-files list on exit")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 ;; for some weird reason a (function (lambda ...))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 ;; doesn't work here
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 (function recent-files-toggle-save-list-on-exit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 (vector "Save recent-files list now"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 (function recent-files-save-the-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 (vector (concat "Kill buffer " lastpart
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 " and delete entry")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 (function recent-files-kill-buffer-delete-entry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 lastpart))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 "Command menu definition for recent-files.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 This definition is evaluated in a context where `filename' holds the file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 name of the current buffer and `lastpart' holds the last component of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 `filename'.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 (defconst recent-files-save-file-header
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 ";; This file is generated by recent-files.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 ;; The car of each entry of recent-files-save-list is to appear in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 ;; `recent-files' menu. If the cdr of an entry is t, the file is to stay
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 ;; in the menu permanently.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 ;; Saved at %s.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 " "Header to be written into the `recent-files-save-file'.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 (defconst recent-files-buffer-name " *recent files save list*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 "Name of the buffer to build the save file in.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 (defvar recent-files-list-changed-p t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 "Non-nil if the recent-files-list has changed after last menubar update.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 (defvar recent-files-last-buffer nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 "Buffer at the time of last recent-files menu rebuild.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 If the buffer has changed, the menu must be rebuilt.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 ;;; Module initialization
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 (defun recent-files-initialize ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 "Initialize the recent-files menu."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 (add-hook 'find-file-hooks (function recent-files-find-and-write-file-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 (add-hook 'dired-after-readin-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 (function recent-files-find-and-write-file-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 (add-hook 'kill-emacs-hook (function recent-files-save-the-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 (add-hook 'activate-menubar-hook (function recent-files-update-menu))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 (add-hook 'write-file-hooks (function recent-files-find-and-write-file-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 ;; Initialize recent-files-list only if it is non-nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 (cond (recent-files-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 (message "recent-files is already initialized."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 ((file-readable-p recent-files-save-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 (setq recent-files-list-changed-p t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 (load-file recent-files-save-file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 (recent-files-update-menu))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 (defun recent-files-version ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 "Return a string identifying the current verion of recent-files.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 If called interactively, show it in the echo area."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 (let ((version "$Header: /afs/informatik.uni-tuebingen.de/local/web/xemacs/xemacs-cvs/XEmacs/xemacs-19/lisp/packages/recent-files.el,v 1.1.1.1 1996/12/18 03:31:56 steve Exp $"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 (if (interactive-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 (message version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 version)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 ;;; Hook functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 (defun recent-files-find-and-write-file-hook ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 "Find-file-hook, write-file-hook, and dired-mode-hook for recent-files.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 Inserts the name of the file just opened or written into the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 `recent-files-list' and updates the recent-files menu."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 (recent-files-add-file (recent-files-get-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 (defun recent-files-get-file-name ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 "Return the filename of the current buffer or nil, if there is none.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 This functions is supposed to do \"the right thing\" also for some modes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 with no buffer-file-name. Currently supported: 'dired-mode."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 (cond (buffer-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 buffer-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 ((eq major-mode 'dired-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 (dired-current-directory))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 (defun recent-files-save-the-list ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 "Save the current `recent-files-list' to the file `recent-files-save-file'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 This is done by writing a `setq' statement to `recent-files-list' into
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 the file."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 (if recent-files-save-list-on-exit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 (let ((l (recent-files-enforce-max-length
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 recent-files-number-of-saved-entries
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 recent-files-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 (set-buffer (get-buffer-create recent-files-buffer-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 (insert (format recent-files-save-file-header (current-time-string)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 (insert "(setq recent-files-list \n '(")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 (if l
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 (while l
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 (if (bolp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 (insert " "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 (prin1 (car l) (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 (insert "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 (setq l (cdr l)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 (forward-line -1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 (insert "))")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 (if (file-writable-p recent-files-save-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 (write-region (point-min) (point-max) recent-files-save-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 (kill-buffer (current-buffer))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 ;;; Construct the menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 (defun recent-files-update-menu ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 "Update the recent-files menu from the recent-files-list."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 (if (or recent-files-list-changed-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 (not recent-files-last-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 (not (eq recent-files-last-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 (current-buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 ;; This is an ugly mess...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 (let ((action-menu-entries
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 (let ((entries
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 (let* ((filename (recent-files-get-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 (lastpart (recent-files-last-part-of-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 filename)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 (eval recent-files-commands-menu))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 (if recent-files-commands-submenu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 (list (cons recent-files-commands-submenu-title
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 entries))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 entries)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 permanent non-permanent all)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 ;; ... getting weirder by the minute ...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 (if (or recent-files-permanent-submenu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 recent-files-non-permanent-submenu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 (null recent-files-permanent-first)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 (eq t recent-files-permanent-first))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 (setq permanent (recent-files-make-file-menu-entries
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 recent-files-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 (function recent-files-filter-permanent)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 (setq non-permanent (recent-files-make-file-menu-entries
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 recent-files-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 recent-files-filter-non-permanent))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 (setq all (recent-files-make-file-menu-entries
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 recent-files-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 (function (lambda (l) l)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 (if recent-files-permanent-submenu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 (setq permanent (list (cons "Permanent entries..." permanent))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 (if recent-files-non-permanent-submenu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 (setq non-permanent (list (cons "Non-permanent entries..."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 non-permanent))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 ;;; ... and now even uglier.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 (add-menu recent-files-menu-path recent-files-menu-title
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 (nconc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 (if recent-files-actions-on-top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 (append action-menu-entries (list "-----")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 (if (or recent-files-permanent-submenu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 recent-files-non-permanent-submenu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 (if recent-files-permanent-first
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 (nconc permanent non-permanent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 (nconc non-permanent permanent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 (cond ((eq t recent-files-permanent-first)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 (nconc permanent non-permanent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 ((null recent-files-permanent-first)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 (nconc non-permanent permanent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 (t all)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 (if (not recent-files-actions-on-top)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 (cons "-----"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 action-menu-entries)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 recent-files-add-menu-before)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 (setq recent-files-list-changed-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 (setq recent-files-last-buffer (current-buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 (defun recent-files-retrieve-entry (filename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 "Retrieve an entry from the recent-files list."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 (assoc filename recent-files-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 (defun recent-files-make-file-menu-entries (recent-list filter)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 "Make file menu entries for recent-files from RECENT-LIST using FILTER."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 (mapcar (function recent-files-entry-to-menu-entry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 (funcall filter
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 (funcall recent-files-sort-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 (recent-files-enforce-max-length
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 recent-files-number-of-entries
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 recent-list)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 (defun recent-files-last-part-of-name (filename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 "Return last part of FILENAME."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 (if filename
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 (if (and (file-directory-p filename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 (equal (substring filename -1) "/"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 (concat (file-name-nondirectory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 (substring filename 0 -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 "/")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 (file-name-nondirectory filename))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 (defun recent-files-filter-permanent (recent-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 "Return list of permanent entries in RECENT-LIST."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 (cond ((null recent-list) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 ((recent-files-permanent-p (car (car recent-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 (cons (car recent-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 (recent-files-filter-permanent (cdr recent-list))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 (t (recent-files-filter-permanent (cdr recent-list)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 (defun recent-files-filter-non-permanent (recent-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 "Return list of non-permanent entries in RECENT-LIST."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 (cond ((null recent-list) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 ((recent-files-permanent-p (car (car recent-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 (recent-files-filter-non-permanent (cdr recent-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 (t (cons (car recent-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 (recent-files-filter-non-permanent (cdr recent-list))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 (defun recent-files-permanent-p (filename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 "Return non-nil if FILENAME is a permanent entry in the recent-files menu."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 (cdr (recent-files-retrieve-entry filename)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 (defun recent-files-entry-to-menu-entry (entry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 "Build a menu entry from an entry in `recent-files-list'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 (vector (concat (if (cdr entry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 "* "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 (if recent-files-use-full-names
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 (recent-files-replace-filenames (car entry))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 (recent-files-last-part-of-name (car entry))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 (list recent-files-find-file-command (car entry))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 (defun recent-files-replace-filenames (filename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 "Replace the part of FILENAME that matches a regular expression
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 in recent-files-filename-replacements with the corrensponding replacement.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 If FILENAME does not match any regular expression, return it unchanged.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 Only the first matching regexp/replacement pair is applied."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 (let ((replist recent-files-filename-replacements)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 (retval filename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 (matched nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 (while (and replist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 (not matched))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 (if (string-match (car (car replist)) filename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 (setq matched t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 (setq retval (concat (substring filename 0 (match-beginning 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 (cdr (car replist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 (substring filename (match-end 0))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 (setq replist (cdr replist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 retval))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 ;;; add a new entry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 (defun recent-files-add-file (filename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 "Add file FILENAME to `recent-files-list'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 FILENAME is not really added if it matches one of the regexps in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 `recent-files-dont-include'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 (if (recent-files-no-match filename recent-files-dont-include)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 (setq recent-files-list-changed-p t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 (setq recent-files-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 (cons (or (recent-files-retrieve-entry filename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 (cons filename nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 (recent-files-remove-entry filename
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 recent-files-list))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 (defun recent-files-dont-sort (recent-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 "Return RECENT-LIST.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 This is a dummy sorting function for the recent-files-list."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 recent-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 (defun recent-files-sort-alphabetically (recent-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 "Return RECENT-LIST sorted alphabetically by the cars of the elements."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 (sort recent-list (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 (lambda (e1 e2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 (string-lessp (car e1) (car e2))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 (defun recent-files-enforce-max-length (n l)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 "Return a list of all permanent and the first N non-permanent entries of L.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 Preserve the order of the entries."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 (let ((count 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 (newlist nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 (while l
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 (if (cdr (car l))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 (setq newlist (cons (car l) newlist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 (if (< count n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 (setq newlist (cons (car l) newlist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 (setq count (1+ count)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 (setq l (cdr l)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 (nreverse newlist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 (defun recent-files-remove-entry (fname recent-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 "Delete all elements that have FNAME as a car from RECENT-LIST.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 The constructed list returned, RECENT-LIST is not changed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 Comparison is done with equal."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 (let ((newlist nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 (while recent-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 (if (not (equal (car (car recent-list)) fname))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 (setq newlist (cons (car recent-list) newlist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 (setq recent-list (cdr recent-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 (nreverse newlist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 (defun recent-files-no-match (string re-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 "Return t if STRING matches none of the regexps in RE-LIST."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 (while (and re-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 (not (string-match (car re-list) string)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 (setq re-list (cdr re-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 (null re-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 ;;; Menu commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 (defun recent-files-make-permanent ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 "Make the file in current buffer a permanent entry in recent-files."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 (rplacd (recent-files-retrieve-entry (recent-files-get-file-name)) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 (setq recent-files-list-changed-p t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 (defun recent-files-make-non-permanent ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 "Make the file in current buffer a non-permanent entry in recent-files."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 (rplacd (recent-files-retrieve-entry (recent-files-get-file-name)) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 (setq recent-files-list-changed-p t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 (defun recent-files-kill-buffer-delete-entry ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 "Kill the current buffer and delete its entry in the recent-files menu."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 (setq recent-files-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 (recent-files-remove-entry (recent-files-get-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 recent-files-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 (setq recent-files-list-changed-p t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 (kill-buffer (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 (defun recent-files-erase-non-permanent ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 "Erase all non-permanent entries from the recent-files menu."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 (setq recent-files-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 (recent-files-filter-permanent recent-files-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661 (setq recent-files-list-changed-p t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 (defun recent-files-toggle-save-list-on-exit ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 "Toggle the value of `recent-files-save-list-on-exit'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 (setq recent-files-save-list-on-exit (not recent-files-save-list-on-exit))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 (setq recent-files-list-changed-p t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 ;;; EOF