diff options
| author | Richard M. Stallman | 1995-10-04 18:34:14 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1995-10-04 18:34:14 +0000 |
| commit | 953a03b29cae25ffb135ccca6722d578f0c1f411 (patch) | |
| tree | 0a0be37f63d1481113198d88da8c0cb07e851a34 | |
| parent | ea064aa0d0cc3346ea17c0e4c51f9e8a3f0fedc2 (diff) | |
| download | emacs-953a03b29cae25ffb135ccca6722d578f0c1f411.tar.gz emacs-953a03b29cae25ffb135ccca6722d578f0c1f411.zip | |
(recover-session-finish): Ask only about files that
have auto-save files now. Don't put "temp" into temp file names.
| -rw-r--r-- | lisp/files.el | 87 |
1 files changed, 49 insertions, 38 deletions
diff --git a/lisp/files.el b/lisp/files.el index 529c3d7bd5b..1fe0265431c 100644 --- a/lisp/files.el +++ b/lisp/files.el | |||
| @@ -2171,6 +2171,7 @@ This command is used in the special Dired buffer created by | |||
| 2171 | (interactive) | 2171 | (interactive) |
| 2172 | ;; Get the name of the session file to recover from. | 2172 | ;; Get the name of the session file to recover from. |
| 2173 | (let ((file (dired-get-filename)) | 2173 | (let ((file (dired-get-filename)) |
| 2174 | files | ||
| 2174 | (buffer (get-buffer-create " *recover*"))) | 2175 | (buffer (get-buffer-create " *recover*"))) |
| 2175 | (dired-do-flagged-delete t) | 2176 | (dired-do-flagged-delete t) |
| 2176 | (unwind-protect | 2177 | (unwind-protect |
| @@ -2179,48 +2180,58 @@ This command is used in the special Dired buffer created by | |||
| 2179 | (set-buffer buffer) | 2180 | (set-buffer buffer) |
| 2180 | (erase-buffer) | 2181 | (erase-buffer) |
| 2181 | (insert-file-contents file) | 2182 | (insert-file-contents file) |
| 2183 | ;; Loop thru the text of that file | ||
| 2184 | ;; and get out the names of the files to recover. | ||
| 2185 | (while (not (eobp)) | ||
| 2186 | (let (thisfile autofile) | ||
| 2187 | (if (eolp) | ||
| 2188 | ;; This is a pair of lines for a non-file-visiting buffer. | ||
| 2189 | ;; Get the auto-save file name and manufacture | ||
| 2190 | ;; a "visited file name" from that. | ||
| 2191 | (progn | ||
| 2192 | (forward-line 1) | ||
| 2193 | (setq autofile | ||
| 2194 | (buffer-substring-no-properties | ||
| 2195 | (point) | ||
| 2196 | (save-excursion | ||
| 2197 | (end-of-line) | ||
| 2198 | (point)))) | ||
| 2199 | (setq thisfile | ||
| 2200 | (expand-file-name | ||
| 2201 | (substring | ||
| 2202 | (file-name-nondirectory autofile) | ||
| 2203 | 1 -1) | ||
| 2204 | (file-name-directory autofile))) | ||
| 2205 | (forward-line 1)) | ||
| 2206 | ;; This pair of lines is a file-visiting | ||
| 2207 | ;; buffer. Use the visited file name. | ||
| 2208 | (progn | ||
| 2209 | (setq thisfile | ||
| 2210 | (buffer-substring-no-properties | ||
| 2211 | (point) (progn (end-of-line) (point)))) | ||
| 2212 | (forward-line 1) | ||
| 2213 | (setq autofile | ||
| 2214 | (buffer-substring-no-properties | ||
| 2215 | (point) (progn (end-of-line) (point)))) | ||
| 2216 | (forward-line 1))) | ||
| 2217 | ;; Ignore a file if its auto-save file does not exist now. | ||
| 2218 | (if (file-exists-p autofile) | ||
| 2219 | (setq files (cons thisfile files))))) | ||
| 2220 | (setq files (nreverse files)) | ||
| 2182 | ;; The file contains a pair of line for each auto-saved buffer. | 2221 | ;; The file contains a pair of line for each auto-saved buffer. |
| 2183 | ;; The first line of the pair contains the visited file name | 2222 | ;; The first line of the pair contains the visited file name |
| 2184 | ;; or is empty if the buffer was not visiting a file. | 2223 | ;; or is empty if the buffer was not visiting a file. |
| 2185 | ;; The second line is the auto-save file name. | 2224 | ;; The second line is the auto-save file name. |
| 2186 | (map-y-or-n-p "Recover %s? " | 2225 | (if files |
| 2187 | (lambda (file) | 2226 | (map-y-or-n-p "Recover %s? " |
| 2188 | (condition-case nil | 2227 | (lambda (file) |
| 2189 | (save-excursion (recover-file file)) | 2228 | (condition-case nil |
| 2190 | (error | 2229 | (save-excursion (recover-file file)) |
| 2191 | "Failed to recover `%s'" file))) | 2230 | (error |
| 2192 | (lambda () | 2231 | "Failed to recover `%s'" file))) |
| 2193 | (if (eobp) | 2232 | files |
| 2194 | nil | 2233 | '("file" "files" "recover")) |
| 2195 | (prog1 | 2234 | (message "No files can be recovered from this session now"))) |
| 2196 | (if (eolp) | ||
| 2197 | ;; If the first line of the pair is empty, | ||
| 2198 | ;; it means this was a non-file buffer | ||
| 2199 | ;; that was autosaved. | ||
| 2200 | ;; Make a file name from | ||
| 2201 | ;; the auto-save file name. | ||
| 2202 | (let ((autofile | ||
| 2203 | (buffer-substring-no-properties | ||
| 2204 | (save-excursion | ||
| 2205 | (forward-line 1) | ||
| 2206 | (point)) | ||
| 2207 | (save-excursion | ||
| 2208 | (forward-line 1) | ||
| 2209 | (end-of-line) | ||
| 2210 | (point))))) | ||
| 2211 | (expand-file-name | ||
| 2212 | (concat "temp" | ||
| 2213 | (substring | ||
| 2214 | (file-name-nondirectory autofile) | ||
| 2215 | 1 -1)) | ||
| 2216 | (file-name-directory autofile))) | ||
| 2217 | ;; This pair of lines is a file-visiting | ||
| 2218 | ;; buffer. Use the visited file name. | ||
| 2219 | (buffer-substring-no-properties | ||
| 2220 | (point) (progn (end-of-line) (point)))) | ||
| 2221 | (while (and (eolp) (not (eobp))) | ||
| 2222 | (forward-line 2))))) | ||
| 2223 | '("file" "files" "recover"))) | ||
| 2224 | (kill-buffer buffer)))) | 2235 | (kill-buffer buffer)))) |
| 2225 | 2236 | ||
| 2226 | (defun kill-some-buffers () | 2237 | (defun kill-some-buffers () |