70
|
1 ;;; auto-save.el --- safer auto saving with support for ange-ftp and /tmp
|
|
2
|
|
3 (defconst auto-save-version "cvs ate me")
|
|
4
|
|
5 ;;;; Copyright (C) 1992, 1993, 1994 by Sebastian Kremer <sk@thp.uni-koeln.de>
|
|
6 ;;;; Modified by jwz
|
0
|
7
|
70
|
8 ;; This file is part of XEmacs.
|
|
9
|
|
10 ;; XEmacs is free software; you can redistribute it and/or modify it
|
|
11 ;; under the terms of the GNU General Public License as published by
|
|
12 ;; the Free Software Foundation; either version 2, or (at your option)
|
|
13 ;; any later version.
|
0
|
14
|
70
|
15 ;; XEmacs is distributed in the hope that it will be useful, but
|
|
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
18 ;; General Public License for more details.
|
0
|
19
|
70
|
20 ;; You should have received a copy of the GNU General Public License
|
|
21 ;; along with XEmacs; see the file COPYING. If not, write to the
|
|
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
23 ;; Boston, MA 02111-1307, USA.
|
0
|
24
|
70
|
25 ;;; Synched up with: Not in FSF.
|
|
26
|
|
27 ;;;; LISPDIR ENTRY for the Elisp Archive ===============================
|
|
28 ;;;; LCD Archive Entry:
|
|
29 ;;;; auto-save|Sebastian Kremer|sk@thp.uni-koeln.de
|
|
30 ;;;; |safer auto saving with support for ange-ftp and /tmp
|
0
|
31
|
|
32 ;;;; OVERVIEW ==========================================================
|
|
33
|
70
|
34 ;;;; Combines autosaving for ange-ftp (to a local or remote directory)
|
|
35 ;;;; with the ability to do autosaves to a fixed directory on a local
|
|
36 ;;;; disk, in case NFS is slow. The auto-save file used for
|
|
37 ;;;; /usr/foo/bar/baz.txt
|
|
38 ;;;; will be
|
|
39 ;;;; AUTOSAVE/#\!usr\!foo\!bar\!baz.txt#
|
|
40 ;;;; assuming AUTOSAVE is the non-nil value of the variable
|
|
41 ;;;; `auto-save-directory'.
|
0
|
42
|
70
|
43 ;;;; Takes care that autosave files for non-file-buffers (e.g. *mail*)
|
|
44 ;;;; from two simultaneous Emacses don't collide.
|
0
|
45
|
70
|
46 ;;;; Autosaves even if the current directory is not writable.
|
0
|
47
|
70
|
48 ;;;; Can limit autosave names to 14 characters using a hash function,
|
|
49 ;;;; see `auto-save-hash-p'.
|
0
|
50
|
70
|
51 ;;;; See `auto-save-directory' and `make-auto-save-file-name' and
|
|
52 ;;;; references therein for complete documentation.
|
0
|
53
|
70
|
54 ;;;; Meta-x recover-all-files will effectively do recover-file on all
|
|
55 ;;;; files whose autosave file is newer (one of the benefits of having
|
|
56 ;;;; all autosave files in the same place).
|
0
|
57
|
|
58 ;;;; INSTALLATION ======================================================
|
|
59
|
70
|
60 ;;;; Put this file into your load-path and the following in your ~/.emacs:
|
0
|
61
|
70
|
62 ;;;; If you want to autosave in the fixed directory /tmp/USER-autosave/
|
|
63 ;;;; (setq auto-save-directory
|
|
64 ;;;; (concat "/tmp/" (user-login-name) "-autosave/"))
|
0
|
65
|
70
|
66 ;;;; If you don't want to save in /tmp (e.g., because it is swap
|
|
67 ;;;; mounted) but rather in ~/autosave/
|
|
68 ;;;; (setq auto-save-directory (expand-file-name "~/autosave/"))
|
0
|
69
|
70
|
70 ;;;; If you want to save each file in its own directory (the default)
|
|
71 ;;;; (setq auto-save-directory nil)
|
|
72 ;;;; You still can take advantage of autosaving ange-ftp remote files
|
|
73 ;;;; in a fixed local directory, `auto-save-directory-fallback' will
|
|
74 ;;;; be used.
|
0
|
75
|
70
|
76 ;;;; If you want to use 14 character hashed autosave filenames
|
|
77 ;;;; (setq auto-save-hash-p t)
|
0
|
78
|
70
|
79 ;;;; Finally, put this line after the others in your ~/.emacs:
|
|
80 ;;;; (require 'auto-save)
|
0
|
81
|
|
82
|
|
83 ;;;; ACKNOWLEDGEMENT ===================================================
|
|
84
|
70
|
85 ;;;; This code is loosely derived from autosave-in-tmp.el by Jamie
|
|
86 ;;;; Zawinski <jwz@lucid.com> (the version I had was last modified 22
|
|
87 ;;;; dec 90 jwz) and code submitted to ange-ftp-lovers on Sun, 5 Apr
|
|
88 ;;;; 92 23:20:47 EDT by drw@BOURBAKI.MIT.EDU (Dale R. Worley).
|
|
89 ;;;; auto-save.el tries to cover the functionality of those two
|
|
90 ;;;; packages.
|
0
|
91
|
70
|
92 ;;;; Valuable comments and help from Dale Worley, Andy Norman, Jamie
|
|
93 ;;;; Zawinski and Sandy Rutherford are gratefully acknowledged.
|
0
|
94
|
|
95 ;;;; CUSTOMIZATION =====================================================
|
|
96
|
|
97 (defvar auto-save-directory nil
|
|
98
|
|
99 ;;; Don't make this user-variable-p, it should be set in .emacs and
|
|
100 ;;; left at that. In particular, it should remain constant across
|
|
101 ;;; several Emacs session to make recover-all-files work.
|
|
102
|
|
103 "If non-nil, fixed directory for autosaving: all autosave files go
|
|
104 there. If this directory does not yet exist at load time, it is
|
|
105 created and its mode is set to 0700 so that nobody else can read your
|
|
106 autosave files.
|
|
107
|
|
108 If nil, each autosave files goes into the same directory as its
|
|
109 corresponding visited file.
|
|
110
|
|
111 A non-nil `auto-save-directory' could be on a local disk such as in
|
|
112 /tmp, then auto-saves will always be fast, even if NFS or the
|
|
113 automounter is slow. In the usual case of /tmp being locally mounted,
|
|
114 note that if you run emacs on two different machines, they will not
|
|
115 see each other's auto-save files.
|
|
116
|
|
117 The value \(expand-file-name \"~/autosave/\"\) might be better if /tmp
|
|
118 is mounted from swap (possible in SunOS, type `df /tmp' to find out)
|
|
119 and thus vanishes after a reboot, or if your system is particularly
|
|
120 thorough when cleaning up /tmp, clearing even non-empty subdirectories.
|
|
121
|
70
|
122 It should never be an ange-ftp remote filename because that would
|
|
123 defeat `ange-ftp-auto-save-remotely'.
|
0
|
124
|
|
125 Unless you set `auto-save-hash-p', you shouldn't set this to a
|
|
126 directory in a filesystem that does not support long filenames, since
|
|
127 a file named
|
|
128
|
|
129 /home/sk/lib/emacs/lisp/auto-save.el
|
|
130
|
|
131 will have a longish filename like
|
|
132
|
|
133 AUTO-SAVE-DIRECTORY/#\\!home\\!sk\\!lib\\!emacs\\!lisp\\!auto-save.el#
|
|
134
|
|
135 as auto save file.
|
|
136
|
70
|
137 See also variables `auto-save-directory-fallback', `auto-save-hash-p',
|
|
138 `ange-ftp-auto-save' and `ange-ftp-auto-save-remotely'.")
|
0
|
139
|
|
140 (defvar auto-save-hash-p nil
|
|
141 "If non-nil, hashed autosave names of length 14 are used.
|
|
142 This is to avoid autosave filenames longer than 14 characters.
|
|
143 The directory used is `auto-save-hash-directory' regardless of
|
|
144 `auto-save-directory'.
|
|
145 Hashing defeats `recover-all-files', you have to recover files
|
|
146 individually by doing `recover-file'.")
|
|
147
|
70
|
148 ;;; This defvar is in ange-ftp.el now, but for older versions it
|
|
149 ;;; doesn't hurt to give it here as well so that loading auto-save.el
|
|
150 ;;; does not abort.
|
|
151 (defvar ange-ftp-auto-save 0
|
|
152 "If 1, allows ange-ftp files to be auto-saved.
|
|
153 If 0, suppresses auto-saving of ange-ftp files.
|
|
154 Don't use any other value.")
|
0
|
155
|
70
|
156 (defvar ange-ftp-auto-save-remotely nil
|
|
157 "*If non-nil, causes the auto-save file for an ange-ftp file to be written in
|
|
158 the remote directory containing the file, rather than in a local directory.
|
|
159
|
|
160 For remote files, this being true overrides a non-nil
|
|
161 `auto-save-directory'. Local files are unaffected.
|
|
162
|
|
163 If you want to use this feature, you probably only want to set this
|
|
164 true in a few buffers, rather than globally. You might want to give
|
|
165 each buffer its own value using `make-variable-buffer-local'.
|
|
166
|
|
167 See also variable `ange-ftp-auto-save'.")
|
0
|
168
|
|
169 ;;;; end of customization
|
|
170
|
|
171
|
|
172 ;;; Preparations to be done at load time
|
|
173
|
|
174 (defvar auto-save-directory-fallback (expand-file-name "~/autosave/")
|
|
175 ;; not user-variable-p, see above
|
|
176 "Directory used for local autosaving of remote files if
|
70
|
177 both `auto-save-directory' and `ange-ftp-auto-save-remotely' are nil.
|
0
|
178 Also used if a working directory to be used for autosaving is not writable.
|
|
179 This *must* always be the name of directory that exists or can be
|
|
180 created by you, never nil.")
|
|
181
|
|
182 (defvar auto-save-hash-directory
|
|
183 (expand-file-name "hash/" (or auto-save-directory
|
|
184 auto-save-directory-fallback))
|
|
185 "If non-nil, directory used for hashed autosave filenames.")
|
|
186
|
|
187 (defun auto-save-check-directory (var)
|
|
188 (let ((dir (symbol-value var)))
|
|
189 (if (null dir)
|
|
190 nil
|
|
191 ;; Expand and store back into the variable
|
|
192 (set var (setq dir (expand-file-name dir)))
|
|
193 ;; Make sure directory exists
|
|
194 (if (file-directory-p dir)
|
|
195 nil
|
|
196 ;; Else we create and chmod 0700 the directory
|
|
197 (setq dir (directory-file-name dir)) ; some systems need this
|
|
198 (if (fboundp 'make-directory) ; V19 or tree dired
|
|
199 (make-directory dir)
|
|
200 (call-process "mkdir" nil nil nil dir))
|
70
|
201 ;; This is 1300, aka "d-wx-----T"
|
|
202 ;; The sticky bit means that you can only delete your own files,
|
|
203 ;; even if you have write permission in the directory (which is
|
|
204 ;; moot, since the directory is only writable by owner.)
|
0
|
205 (set-file-modes dir (* 7 8 8))))))
|
|
206
|
|
207 (mapcar (function auto-save-check-directory)
|
|
208 '(auto-save-directory auto-save-directory-fallback))
|
|
209
|
|
210 (and auto-save-hash-p
|
|
211 (auto-save-check-directory 'auto-save-hash-directory))
|
|
212
|
|
213
|
|
214 ;;; Computing an autosave name for a file and vice versa
|
|
215
|
|
216 (defun make-auto-save-file-name ();; redefines files.el
|
|
217 ;; auto-save-file-name-p need not be redefined.
|
|
218
|
|
219 "Return file name to use for auto-saves of current buffer.
|
|
220 Does not consider `auto-save-visited-file-name'; that is checked
|
|
221 before calling this function.
|
|
222
|
|
223 Offers to autosave all files in the same `auto-save-directory'. All
|
|
224 autosave files can then be recovered at once with function
|
|
225 `recover-all-files'.
|
|
226
|
70
|
227 Takes care to make autosave files for files accessed through ange-ftp
|
|
228 be local files if variable `ange-ftp-auto-save-remotely' is nil.
|
0
|
229
|
|
230 Takes care of slashes in buffer names to prevent autosave errors.
|
|
231
|
|
232 Uses 14 character autosave names if `auto-save-hash-p' is true.
|
|
233
|
|
234 Autosaves even if the current directory is not writable, using
|
|
235 directory `auto-save-directory-fallback'.
|
|
236
|
|
237 You can redefine this for customization (he he :-).
|
|
238 See also function `auto-save-file-name-p'."
|
|
239
|
|
240 ;; We have to be very careful about not signalling an error in this
|
|
241 ;; function since files.el does not provide for this (e.g. find-file
|
|
242 ;; would fail for each new file).
|
|
243
|
|
244 (condition-case error-data
|
70
|
245 (let* ((file-name (or (and (boundp 'buffer-file-truename) ; From jwz,
|
|
246 buffer-file-truename) ; for Emacs 19?
|
|
247 buffer-file-name))
|
0
|
248 ;; So autosavename looks like #%...#, roughly as with the
|
|
249 ;; old make-auto-save-file-name function. The
|
|
250 ;; make-temp-name inserts the pid of this Emacs: this
|
|
251 ;; avoids autosaving from two Emacses into the same file.
|
|
252 ;; It cannot be recovered automatically then because in
|
|
253 ;; the next Emacs session (the one after the crash) the
|
|
254 ;; pid will be different, but file-less buffers like
|
|
255 ;; *mail* must be recovered manually anyway.
|
48
|
256
|
|
257 ;; jwz: putting the emacs PID in the auto-save file name is bad
|
|
258 ;; news, because that defeats auto-save-recovery of *mail*
|
|
259 ;; buffers -- the (sensible) code in sendmail.el calls
|
|
260 ;; (make-auto-save-file-name) to determine whether there is
|
|
261 ;; unsent, auto-saved mail to recover. If that mail came from a
|
|
262 ;; previous emacs process (far and away the most likely case)
|
|
263 ;; then this can never succeed as the pid differs.
|
|
264 ;; (name-prefix (if file-name nil (make-temp-name "#%")))
|
|
265 (name-prefix (if file-name nil "#%"))
|
|
266
|
0
|
267 (save-name (or file-name
|
|
268 ;; Prevent autosave errors. Buffername
|
|
269 ;; (to become non-dir part of filename) will
|
|
270 ;; be unslashified twice. Don't care.
|
|
271 (auto-save-unslashify-name (buffer-name))))
|
|
272 (remote-p (and (stringp file-name)
|
70
|
273 (fboundp 'ange-ftp-ftp-path)
|
|
274 (ange-ftp-ftp-path file-name))))
|
0
|
275 ;; Return the appropriate auto save file name:
|
|
276 (expand-file-name;; a buffername needs this, a filename not
|
|
277 (if remote-p
|
70
|
278 (if ange-ftp-auto-save-remotely
|
0
|
279 (auto-save-name-in-same-directory save-name)
|
|
280 ;; We have to use the `fixed-directory' now since the
|
|
281 ;; `same-directory' would be remote.
|
|
282 ;; It will use the fallback if needed.
|
|
283 (auto-save-name-in-fixed-directory save-name))
|
|
284 ;; Else it is a local file (or a buffer without a file, hence
|
70
|
285 ;; the name-prefix).
|
0
|
286 ;; Hashed files always go into the special hash dir, never
|
|
287 ;; in the same directory, to make recognizing reliable.
|
|
288 (if (or auto-save-directory auto-save-hash-p)
|
|
289 (auto-save-name-in-fixed-directory save-name name-prefix)
|
|
290 (auto-save-name-in-same-directory save-name name-prefix)))))
|
70
|
291
|
0
|
292 ;; If any error occurs in the above code, return what the old
|
|
293 ;; version of this function would have done. It is not ok to
|
|
294 ;; return nil, e.g., when after-find-file tests
|
|
295 ;; file-newer-than-file-p, nil would bomb.
|
|
296
|
|
297 (error (progn
|
|
298 (message "make-auto-save-file-name %s" error-data)
|
|
299 (sit-for 2)
|
|
300 (if buffer-file-name
|
|
301 (concat (file-name-directory buffer-file-name)
|
|
302 "#"
|
|
303 (file-name-nondirectory buffer-file-name)
|
|
304 "#")
|
|
305 (expand-file-name (concat "#%" (buffer-name) "#")))))))
|
|
306
|
|
307 (defun auto-save-original-name (savename)
|
|
308 "Reverse of `make-auto-save-file-name'.
|
|
309 Returns nil if SAVENAME was not associated with a file (e.g., it came
|
|
310 from an autosaved `*mail*' buffer) or does not appear to be an
|
|
311 autosave file at all.
|
|
312 Hashed files are not understood, see `auto-save-hash-p'."
|
|
313 (let ((basename (file-name-nondirectory savename))
|
|
314 (savedir (file-name-directory savename)))
|
|
315 (cond ((or (not (auto-save-file-name-p basename))
|
|
316 (string-match "^#%" basename))
|
|
317 nil)
|
|
318 ;; now we know it looks like #...# thus substring is safe to use
|
|
319 ((or (equal savedir auto-save-directory) ; 2nd arg may be nil
|
|
320 (equal savedir auto-save-directory-fallback))
|
|
321 ;; it is of the `-fixed-directory' type
|
|
322 (auto-save-slashify-name (substring basename 1 -1)))
|
|
323 (t
|
|
324 ;; else it is of `-same-directory' type
|
|
325 (concat savedir (substring basename 1 -1))))))
|
|
326
|
|
327 (defun auto-save-name-in-fixed-directory (filename &optional prefix)
|
|
328 ;; Unslashify and enclose the whole FILENAME in `#' to make an auto
|
|
329 ;; save file in the auto-save-directory, or if that is nil, in
|
|
330 ;; auto-save-directory-fallback (which must be the name of an
|
|
331 ;; existing directory). If the results would be too long for 14
|
|
332 ;; character filenames, and `auto-save-hash-p' is set, hash FILENAME
|
|
333 ;; into a shorter name.
|
|
334 ;; Optional PREFIX is string to use instead of "#" to prefix name.
|
|
335 (let ((base-name (concat (or prefix "#")
|
|
336 (auto-save-unslashify-name filename)
|
|
337 "#")))
|
|
338 (if (and auto-save-hash-p
|
|
339 auto-save-hash-directory
|
|
340 (> (length base-name) 14))
|
|
341 (expand-file-name (auto-save-cyclic-hash-14 filename)
|
|
342 auto-save-hash-directory)
|
|
343 (expand-file-name base-name
|
|
344 (or auto-save-directory
|
|
345 auto-save-directory-fallback)))))
|
|
346
|
|
347 (defun auto-save-name-in-same-directory (filename &optional prefix)
|
|
348 ;; Enclose the non-directory part of FILENAME in `#' to make an auto
|
|
349 ;; save file in the same directory as FILENAME. But if this
|
|
350 ;; directory is not writable, use auto-save-directory-fallback.
|
|
351 ;; FILENAME is assumed to be in non-directory form (no trailing slash).
|
|
352 ;; It may be a name without a directory part (pesumably it really
|
|
353 ;; comes from a buffer name then), the fallback is used then.
|
|
354 ;; Optional PREFIX is string to use instead of "#" to prefix name.
|
|
355 (let ((directory (file-name-directory filename)))
|
|
356 (or (null directory)
|
|
357 (file-writable-p directory)
|
|
358 (setq directory auto-save-directory-fallback))
|
|
359 (concat directory ; (concat nil) is ""
|
|
360 (or prefix "#")
|
|
361 (file-name-nondirectory filename)
|
|
362 "#")))
|
|
363
|
|
364 (defun auto-save-unslashify-name (s)
|
|
365 ;; "Quote any slashes in string S by replacing them with the two
|
|
366 ;;characters `\\!'.
|
|
367 ;;Also, replace any backslash by double backslash, to make it one-to-one."
|
|
368 (let ((limit 0))
|
|
369 (while (string-match "[/\\]" s limit)
|
|
370 (setq s (concat (substring s 0 (match-beginning 0))
|
|
371 (if (string= (substring s
|
|
372 (match-beginning 0)
|
|
373 (match-end 0))
|
|
374 "/")
|
|
375 "\\!"
|
|
376 "\\\\")
|
|
377 (substring s (match-end 0))))
|
|
378 (setq limit (1+ (match-end 0)))))
|
|
379 s)
|
|
380
|
|
381 (defun auto-save-slashify-name (s)
|
|
382 ;;"Reverse of `auto-save-unslashify-name'."
|
|
383 (let (pos)
|
|
384 (while (setq pos (string-match "\\\\[\\!]" s pos))
|
|
385 (setq s (concat (substring s 0 pos)
|
|
386 (if (eq ?! (aref s (1+ pos))) "/" "\\")
|
|
387 (substring s (+ pos 2)))
|
|
388 pos (1+ pos))))
|
|
389 s)
|
|
390
|
|
391
|
|
392 ;;; Hashing for autosave names
|
|
393
|
|
394 ;;; Hashing function contributed by Andy Norman <ange@hplb.hpl.hp.com>
|
|
395 ;;; based upon C code from pot@fly.cnuce.cnr.IT (Francesco Potorti`).
|
|
396
|
|
397 (defun auto-save-cyclic-hash-14 (s)
|
|
398 ;; "Hash string S into a string of length 14.
|
|
399 ;; The resulting string consists of hexadecimal digits [0-9a-f].
|
|
400 ;; In particular, it contains no slash, so it can be used as autosave name."
|
70
|
401 (let ((crc (make-string 8 0))
|
0
|
402 result)
|
|
403 (mapcar
|
|
404 (function
|
|
405 (lambda (new)
|
70
|
406 (setq new (+ new (aref crc 7)))
|
|
407 (aset crc 7 (aref crc 6))
|
0
|
408 (aset crc 6 (+ (aref crc 5) new))
|
|
409 (aset crc 5 (aref crc 4))
|
|
410 (aset crc 4 (aref crc 3))
|
|
411 (aset crc 3 (+ (aref crc 2) new))
|
|
412 (aset crc 2 (aref crc 1))
|
|
413 (aset crc 1 (aref crc 0))
|
|
414 (aset crc 0 new)))
|
|
415 s)
|
|
416 (setq result (format "%02x%02x%02x%02x%02x%02x%02x"
|
|
417 (aref crc 0)
|
|
418 (aref crc 1)
|
|
419 (aref crc 2)
|
|
420 (aref crc 3)
|
|
421 (aref crc 4)
|
|
422 (aref crc 5)
|
70
|
423 (aref crc 6)
|
|
424 (aref crc 7)))
|
0
|
425 result))
|
|
426
|
|
427
|
|
428
|
|
429 ;;; Recovering files
|
|
430
|
70
|
431 ;; jwz: changed this to also offer to recover auto-saved buffers which
|
|
432 ;; had no associated file name (such as sendmail buffers.)
|
|
433 (defun recover-all-files ()
|
0
|
434 "Do recover-file for all autosave files which are current.
|
|
435 Only works if you have a non-nil `auto-save-directory'.
|
|
436 Hashed files (see `auto-save-hash-p') are not understood, use
|
|
437 `recover-file' to recover them individually."
|
70
|
438 (interactive)
|
0
|
439 (let ((savefiles (directory-files auto-save-directory t "^#"))
|
|
440 afile ; the auto save file
|
|
441 file ; its original file
|
|
442 (total 0) ; # of files offered to recover
|
|
443 (count 0)) ; # of files actually recovered
|
|
444 (or (equal auto-save-directory auto-save-directory-fallback)
|
|
445 (setq savefiles
|
|
446 (append savefiles
|
|
447 (directory-files auto-save-directory-fallback t "^#"))))
|
|
448 (while savefiles
|
|
449 (setq afile (car savefiles)
|
|
450 file (auto-save-original-name afile)
|
|
451 savefiles (cdr savefiles))
|
|
452 (cond ((and file (not (file-newer-than-file-p afile file)))
|
|
453 (message "autosave file \"%s\" is not current." afile)
|
|
454 (sit-for 2))
|
|
455 (t
|
|
456 (setq total (1+ total))
|
|
457 (with-output-to-temp-buffer "*Directory*"
|
48
|
458 (apply 'call-process "ls" nil standard-output nil
|
|
459 "-l" afile (if file (list file))))
|
0
|
460 (if (yes-or-no-p (format "Recover %s from auto save file? "
|
48
|
461 (or file "non-file buffer")))
|
0
|
462 (let* ((obuf (current-buffer))
|
|
463 (buf (set-buffer
|
|
464 (if file
|
|
465 (find-file-noselect file t)
|
|
466 (generate-new-buffer "*recovered*"))))
|
|
467 (buffer-read-only nil))
|
|
468 (erase-buffer)
|
|
469 (insert-file-contents afile nil)
|
|
470 (condition-case ()
|
|
471 (after-find-file nil)
|
|
472 (error nil))
|
|
473 (setq buffer-auto-save-file-name nil)
|
|
474 (setq count (1+ count))
|
|
475 (message "\
|
|
476 Auto-save off in buffer \"%s\" till you do M-x auto-save-mode."
|
|
477 (buffer-name))
|
|
478 (set-buffer obuf)
|
70
|
479 (sit-for 1))))))
|
0
|
480 (if (zerop total)
|
70
|
481 (message "Nothing to recover.")
|
0
|
482 (message "%d/%d file%s recovered." count total (if (= count 1) "" "s"))))
|
|
483 (if (get-buffer "*Directory*") (kill-buffer "*Directory*")))
|
|
484
|
70
|
485 (provide 'auto-save)
|