summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorRichard M. Stallman <rms@gnu.org>1995-08-13 16:48:13 +0000
committerRichard M. Stallman <rms@gnu.org>1995-08-13 16:48:13 +0000
commit1ed8a21d9f40543ec43a5b414fe783b5051834ba (patch)
tree01bfd3dc292f42d1a93bcc8f8118ae565f3d5299 /lisp
parent6c8bf589ba5feb667aa8c6804d8bba9f616529c5 (diff)
downloademacs-1ed8a21d9f40543ec43a5b414fe783b5051834ba.tar.gz
(recover-file): It's ok if the visited file doesn't exist.
(recover-session-finish): Compute "file name" from autosave file if no visited file.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/files.el35
1 files changed, 32 insertions, 3 deletions
diff --git a/lisp/files.el b/lisp/files.el
index ad4aab933ff..7c2b5b64e97 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -2079,7 +2079,9 @@ beginning and `after-revert-hook' at the end."
(error "%s is an auto-save file" file))
(let ((file-name (let ((buffer-file-name file))
(make-auto-save-file-name))))
- (cond ((not (file-newer-than-file-p file-name file))
+ (cond ((if (file-exists-p file)
+ (not (file-newer-than-file-p file-name file))
+ (not (file-exists-p file-name)))
(error "Auto-save file %s not current" file-name))
((save-window-excursion
(if (not (eq system-type 'vax-vms))
@@ -2129,14 +2131,41 @@ This command is used in the special Dired buffer created by
(set-buffer buffer)
(erase-buffer)
(insert-file-contents file)
+ ;; The file contains a pair of line for each auto-saved buffer.
+ ;; The first line of the pair contains the visited file name
+ ;; or is empty if the buffer was not visiting a file.
+ ;; The second line is the auto-save file name.
(map-y-or-n-p "Recover %s? "
(lambda (file) (save-excursion (recover-file file)))
(lambda ()
(if (eobp)
nil
(prog1
- (buffer-substring-no-properties
- (point) (progn (end-of-line) (point)))
+ (if (eolp)
+ ;; If the first line of the pair is empty,
+ ;; it means this was a non-file buffer
+ ;; that was autosaved.
+ ;; Make a file name from
+ ;; the auto-save file name.
+ (let ((autofile
+ (buffer-substring-no-properties
+ (save-excursion
+ (forward-line 1)
+ (point))
+ (save-excursion
+ (forward-line 1)
+ (end-of-line)
+ (point)))))
+ (expand-file-name
+ (concat "temp"
+ (substring
+ (file-name-nondirectory autofile)
+ 1 -1))
+ (file-name-directory autofile)))
+ ;; This pair of lines is a file-visiting
+ ;; buffer. Use the visited file name.
+ (buffer-substring-no-properties
+ (point) (progn (end-of-line) (point))))
(while (and (eolp) (not (eobp)))
(forward-line 2)))))
'("file" "files" "recover")))