diff lisp/files.el @ 851:e7ee5f8bde58

[xemacs-hg @ 2002-05-23 11:46:08 by ben] fix for raymond toy's crash, alloca crashes, some recover-session improvements files.el: Recover-session improvements: Only show session files where some files can actually be recovered, and show in chronological order. subr.el, menubar-items.el: As promised to rms, the functionality in truncate-string-with-continuation-dots has been merged into truncate-string-to-width. Change callers in menubar-items.el. select.el: Document some of these funs better. Fix problem where we were doing own-clipboard twice. Makefile.in.in: Add alloca.o. Ensure that alloca.s doesn't compile into alloca.o, but allocax.o (not that it's currently used or anything.) EmacsFrame.c, abbrev.c, alloc.c, alloca.c, callint.c, callproc.c, config.h.in, device-msw.c, device-x.c, dired.c, doc.c, editfns.c, emacs.c, emodules.c, eval.c, event-Xt.c, event-msw.c, event-stream.c, file-coding.c, fileio.c, filelock.c, fns.c, glyphs-gtk.c, glyphs-msw.c, glyphs-x.c, gui-x.c, input-method-xlib.c, intl-win32.c, lisp.h, lread.c, menubar-gtk.c, menubar-msw.c, menubar.c, mule-wnnfns.c, nt.c, objects-msw.c, process-nt.c, realpath.c, redisplay-gtk.c, redisplay-output.c, redisplay-x.c, redisplay.c, search.c, select-msw.c, sysdep.c, syswindows.h, text.c, text.h, ui-byhand.c: Fix Raymond Toy's crash. Repeat to self: 2^21 - 1 is NOT the same as (2 << 21) - 1. Fix crashes due to excessive alloca(). replace alloca() with ALLOCA(), which calls the C alloca() [which uses xmalloc()] when the size is too big. Insert in various places calls to try to flush the C alloca() stored info if there is any. Add MALLOC_OR_ALLOCA(), for places that expect to be alloca()ing large blocks. This xmalloc()s when too large and records an unwind-protect to free -- relying on the caller to unbind_to() elsewhere in the function. Use it in concat(). Use MALLOC instead of ALLOCA in select-msw.c. xemacs.mak: Add alloca.o.
author ben
date Thu, 23 May 2002 11:46:46 +0000
parents 503b6a57cf47
children 42375619fa45
line wrap: on
line diff
--- a/lisp/files.el	Tue May 21 23:47:40 2002 +0000
+++ b/lisp/files.el	Thu May 23 11:46:46 2002 +0000
@@ -3131,33 +3131,35 @@
   (if (null auto-save-list-file-prefix)
       (error
        "You set `auto-save-list-file-prefix' to disable making session files"))
-  (declare-fboundp (dired (concat auto-save-list-file-prefix "*")))
-  (goto-char (point-min))
-  (or (looking-at "Move to the session you want to recover,")
-      (let ((inhibit-read-only t))
-	(insert "Move to the session you want to recover,\n"
-		"then type C-c C-c to select it.\n\n"
-		"You can also delete some of these files;\n"
-		"type d on a line to mark that file for deletion.\n\n")))
-  (use-local-map (let ((map (make-sparse-keymap)))
-		   (set-keymap-parents map (list (current-local-map)))
-		   map))
-  (define-key (current-local-map) "\C-c\C-c" 'recover-session-finish))
+  (let* ((auto-save-list-dir
+	  (file-name-directory auto-save-list-file-prefix))
+	 (files (directory-files
+		 auto-save-list-dir
+		 t
+		 (concat "^" (regexp-quote (file-name-nondirectory
+					    auto-save-list-file-prefix)))))
+	 (files (sort (delete-if-not #'Recover-session-files-from-auto-save-list-file
+			       files) #'file-newer-than-file-p)))
+    (unless files
+      (error "No sessions can be recovered now"))
+    (declare-fboundp (dired (cons auto-save-list-dir files)))
+    (goto-char (point-min))
+    (or (looking-at "Move to the session you want to recover,")
+	(let ((inhibit-read-only t))
+	  (delete-matching-lines "^[ \t]*total.*$")
+	  (insert "Move to the session you want to recover,\n"
+		  "then type C-c C-c to select it.\n\n"
+		  "You can also delete some of these files;\n"
+		  "type d on a line to mark that file for deletion.\n\n")))
+    (use-local-map (let ((map (make-sparse-keymap)))
+		     (set-keymap-parents map (list (current-local-map)))
+		     map))
+    (define-key (current-local-map) "\C-c\C-c" 'recover-session-finish)))
 
-(defun recover-session-finish ()
-  "Choose one saved session to recover auto-save files from.
-This command is used in the special Dired buffer created by
-\\[recover-session]."
-  (interactive)
-  ;; Get the name of the session file to recover from.
-  (let ((file (declare-fboundp (dired-get-filename)))
-	files
+(defun Recover-session-files-from-auto-save-list-file (file)
+  "Return the auto save files in list file FILE that are current."
+  (let (files
 	(buffer (get-buffer-create " *recover*")))
-    ;; #### dired-do-flagged-delete in FSF.
-    ;; This version is for ange-ftp
-    ;;(dired-do-deletions t)
-    ;; This version is for efs
-    (declare-fboundp (dired-expunge-deletions))
     (unwind-protect
 	(save-excursion
 	  ;; Read in the auto-save-list file.
@@ -3202,23 +3204,38 @@
 	      ;; Ignore a file if its auto-save file does not exist now.
 	      (if (file-exists-p autofile)
 		  (setq files (cons thisfile files)))))
-	  (setq files (nreverse files))
-	  ;; 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.
-	  (if files
-	      (map-y-or-n-p  "Recover %s? "
-			     (lambda (file)
-			       (condition-case nil
-				   (save-excursion (recover-file file))
-				 (error
-				  (lwarn 'recover 'alert "Failed to recover `%s'" file))))
-			     files
-			     '("file" "files" "recover"))
-	    (message "No files can be recovered from this session now")))
+	  (setq files (nreverse files)))
       (kill-buffer buffer))))
 
+(defun recover-session-finish ()
+  "Choose one saved session to recover auto-save files from.
+This command is used in the special Dired buffer created by
+\\[recover-session]."
+  (interactive)
+  ;; Get the name of the session file to recover from.
+  (let ((file (declare-fboundp (dired-get-filename))))
+    ;; #### dired-do-flagged-delete in FSF.
+    ;; This version is for ange-ftp
+    ;;(dired-do-deletions t)
+    ;; This version is for efs
+    (declare-fboundp (dired-expunge-deletions))
+    (let ((files (Recover-session-files-from-auto-save-list-file 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.
+      (if files
+	  (map-y-or-n-p  "Recover %s? "
+			 (lambda (file)
+			   (condition-case nil
+			       (save-excursion (recover-file file))
+			     (error
+			      (lwarn 'recover 'alert
+				"Failed to recover `%s'" file))))
+			 files
+			 '("file" "files" "recover"))
+	(message "No files can be recovered from this session now")))))
+
 (defun kill-some-buffers (&optional list)
   "For each buffer in LIST, ask whether to kill it.
 LIST defaults to all existing live buffers."