diff options
| author | Richard M. Stallman | 1995-08-13 16:48:13 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1995-08-13 16:48:13 +0000 |
| commit | 945e196506572ea4a248b9b4751af9ee4e34e3a4 (patch) | |
| tree | 9b6bb96c421d848e79c8711e5e1cffe1984adb9b | |
| parent | 199afd290f579ae1fc9ac332f6e1df627be14404 (diff) | |
| download | emacs-945e196506572ea4a248b9b4751af9ee4e34e3a4.tar.gz emacs-945e196506572ea4a248b9b4751af9ee4e34e3a4.zip | |
(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.
| -rw-r--r-- | lisp/files.el | 35 |
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." | |||
| 2079 | (error "%s is an auto-save file" file)) | 2079 | (error "%s is an auto-save file" file)) |
| 2080 | (let ((file-name (let ((buffer-file-name file)) | 2080 | (let ((file-name (let ((buffer-file-name file)) |
| 2081 | (make-auto-save-file-name)))) | 2081 | (make-auto-save-file-name)))) |
| 2082 | (cond ((not (file-newer-than-file-p file-name file)) | 2082 | (cond ((if (file-exists-p file) |
| 2083 | (not (file-newer-than-file-p file-name file)) | ||
| 2084 | (not (file-exists-p file-name))) | ||
| 2083 | (error "Auto-save file %s not current" file-name)) | 2085 | (error "Auto-save file %s not current" file-name)) |
| 2084 | ((save-window-excursion | 2086 | ((save-window-excursion |
| 2085 | (if (not (eq system-type 'vax-vms)) | 2087 | (if (not (eq system-type 'vax-vms)) |
| @@ -2129,14 +2131,41 @@ This command is used in the special Dired buffer created by | |||
| 2129 | (set-buffer buffer) | 2131 | (set-buffer buffer) |
| 2130 | (erase-buffer) | 2132 | (erase-buffer) |
| 2131 | (insert-file-contents file) | 2133 | (insert-file-contents file) |
| 2134 | ;; The file contains a pair of line for each auto-saved buffer. | ||
| 2135 | ;; The first line of the pair contains the visited file name | ||
| 2136 | ;; or is empty if the buffer was not visiting a file. | ||
| 2137 | ;; The second line is the auto-save file name. | ||
| 2132 | (map-y-or-n-p "Recover %s? " | 2138 | (map-y-or-n-p "Recover %s? " |
| 2133 | (lambda (file) (save-excursion (recover-file file))) | 2139 | (lambda (file) (save-excursion (recover-file file))) |
| 2134 | (lambda () | 2140 | (lambda () |
| 2135 | (if (eobp) | 2141 | (if (eobp) |
| 2136 | nil | 2142 | nil |
| 2137 | (prog1 | 2143 | (prog1 |
| 2138 | (buffer-substring-no-properties | 2144 | (if (eolp) |
| 2139 | (point) (progn (end-of-line) (point))) | 2145 | ;; If the first line of the pair is empty, |
| 2146 | ;; it means this was a non-file buffer | ||
| 2147 | ;; that was autosaved. | ||
| 2148 | ;; Make a file name from | ||
| 2149 | ;; the auto-save file name. | ||
| 2150 | (let ((autofile | ||
| 2151 | (buffer-substring-no-properties | ||
| 2152 | (save-excursion | ||
| 2153 | (forward-line 1) | ||
| 2154 | (point)) | ||
| 2155 | (save-excursion | ||
| 2156 | (forward-line 1) | ||
| 2157 | (end-of-line) | ||
| 2158 | (point))))) | ||
| 2159 | (expand-file-name | ||
| 2160 | (concat "temp" | ||
| 2161 | (substring | ||
| 2162 | (file-name-nondirectory autofile) | ||
| 2163 | 1 -1)) | ||
| 2164 | (file-name-directory autofile))) | ||
| 2165 | ;; This pair of lines is a file-visiting | ||
| 2166 | ;; buffer. Use the visited file name. | ||
| 2167 | (buffer-substring-no-properties | ||
| 2168 | (point) (progn (end-of-line) (point)))) | ||
| 2140 | (while (and (eolp) (not (eobp))) | 2169 | (while (and (eolp) (not (eobp))) |
| 2141 | (forward-line 2))))) | 2170 | (forward-line 2))))) |
| 2142 | '("file" "files" "recover"))) | 2171 | '("file" "files" "recover"))) |