aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1995-04-30 19:46:44 +0000
committerRichard M. Stallman1995-04-30 19:46:44 +0000
commit9aee5392730ff798eff16dd55fbc5180af64df08 (patch)
tree55cf2a6cd366a5b2a6a00cda8b01f9394536453b
parent2725719aef2bd173e7cde691afcb39c9ced1c80e (diff)
downloademacs-9aee5392730ff798eff16dd55fbc5180af64df08.tar.gz
emacs-9aee5392730ff798eff16dd55fbc5180af64df08.zip
(multiple-recover, multiple-recover-finish): New commands.
-rw-r--r--lisp/files.el44
1 files changed, 44 insertions, 0 deletions
diff --git a/lisp/files.el b/lisp/files.el
index 2778fdd6042..6a46ab0b762 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -2041,6 +2041,50 @@ beginning and `after-revert-hook' at the end."
2041 (after-find-file nil nil t)) 2041 (after-find-file nil nil t))
2042 (t (error "Recover-file cancelled."))))) 2042 (t (error "Recover-file cancelled.")))))
2043 2043
2044(defun multiple-recover ()
2045 "Recover auto save files from a previous Emacs session.
2046This command first displays a Dired buffer showing you the
2047previous sessions that you could recover from.
2048To choose one, move point to the proper line and then type C-c C-c.
2049Then you'll be asked about a number of files to recover."
2050 (interactive)
2051 (dired "~/.save*")
2052 (goto-char (point-min))
2053 (or (looking-at "Move to the session you want to recover,")
2054 (let ((inhibit-read-only t))
2055 (insert "Move to the session you want to recover,\n")
2056 (insert "then type C-c C-c to select it.\n\n")))
2057 (use-local-map (nconc (make-sparse-keymap) (current-local-map)))
2058 (define-key (current-local-map) "\C-c\C-c" 'multiple-recover-finish))
2059
2060(defun multiple-recover-finish ()
2061 "Choose one saved session to recover auto-save files from.
2062This command is used in the special Dired buffer created by
2063M-x multiple-recover."
2064 (interactive)
2065 ;; Get the name of the session file to recover from.
2066 (let ((file (dired-get-filename))
2067 (buffer (get-buffer-create " *recover*")))
2068 (unwind-protect
2069 (save-excursion
2070 ;; Read in the auto-save-list file.
2071 (set-buffer buffer)
2072 (erase-buffer)
2073 (insert-file-contents file)
2074 (while (not (eobp))
2075 ;; Look at each file entry.
2076 (and (not (eolp))
2077 (let ((edited-file
2078 (buffer-substring (point)
2079 (save-excursion (end-of-line) (point)))))
2080 ;; Offer to recover it.
2081 (if (y-or-n-p (format "Recover %s? " edited-file))
2082 (save-excursion
2083 (recover-file edited-file)))))
2084 ;; Skip to the next entry.
2085 (forward-line 2)))
2086 (kill-buffer buffer))))
2087
2044(defun kill-some-buffers () 2088(defun kill-some-buffers ()
2045 "For each buffer, ask whether to kill it." 2089 "For each buffer, ask whether to kill it."
2046 (interactive) 2090 (interactive)