annotate lisp/packages/recent-files.el @ 118:7d55a9ba150c r20-1b11

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