From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Edward Welbourne Newsgroups: gmane.emacs.bugs Subject: Re: recover-session doesn't Date: Fri, 16 Aug 2002 16:26:59 +0200 Sender: bug-gnu-emacs-admin@gnu.org Message-ID: References: <200207111201.g6BC1og16997@aztec.santafe.edu> <200207310555.g6V5tDO16550@aztec.santafe.edu> Reply-To: eddy@opera.no NNTP-Posting-Host: localhost.gmane.org X-Trace: main.gmane.org 1029508211 31327 127.0.0.1 (16 Aug 2002 14:30:11 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Fri, 16 Aug 2002 14:30:11 +0000 (UTC) Cc: bug-gnu-emacs@gnu.org Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 17fi76-00089A-00 for ; Fri, 16 Aug 2002 16:30:08 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10) id 17fi85-0005uk-00; Fri, 16 Aug 2002 10:31:09 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10) id 17fi7X-0005nK-00 for bug-gnu-emacs@gnu.org; Fri, 16 Aug 2002 10:30:35 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10) id 17fi5c-0005iK-00 for bug-gnu-emacs@gnu.org; Fri, 16 Aug 2002 10:30:34 -0400 Original-Received: from pat.opera.com ([193.69.113.22] helo=whorl.intern.opera.no) by monty-python.gnu.org with esmtp (Exim 4.10) id 17fi46-0005Pq-00; Fri, 16 Aug 2002 10:27:02 -0400 Original-Received: from eddy by whorl.intern.opera.no with local (Exim 3.35 #1 (Debian)) id 17fi43-0000sg-00; Fri, 16 Aug 2002 16:26:59 +0200 Original-To: rms@gnu.org In-Reply-To: <200207310555.g6V5tDO16550@aztec.santafe.edu> (message from Richard Stallman on Tue, 30 Jul 2002 23:55:13 -0600 (MDT)) Errors-To: bug-gnu-emacs-admin@gnu.org X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.0.11 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Bug reports for GNU Emacs, the Swiss army knife of text editors List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.emacs.bugs:3229 X-Report-Spam: http://spam.gmane.org/gmane.emacs.bugs:3229 > Could you try stepping through the command recover-session-finish > and see why it did not ask you about the files? OK, finally did that (got caught out by C-M-delete not being backwards-delete-sexp ... or, at least, not getting through to emacs even if it is, because M is spelt Alt) and all is clear. The problem is that * I nearly always have nearly all files saved (extensive use of M-x compile, plus neurotic tendencies in any case) * I was expecting recover-session to recover my session state, not just the files I had edited without saving - i.e. I expected it to visit the files I was visiting (and ideally restore the buffer names I'd given them, though that's perhaps asking a bit much). So scratch the bug report and substitute a feature request; [at your option, only when given a prefix argument] I'd like recover-session to visit the files for which auto-file is missing, as well as (as at present) doing recover-file on the ones whose auto-file is present. then it would deserve the name recover-session, as opposed to recover-edited-files-from-session, which would better describe its present effect. The desired feature [without support for the prefix aspect] may be implemented by the following: diff -c /home/eddy/.sys/elisp/files.orig.el /home/eddy/.sys/elisp/files.el *** /home/eddy/.sys/elisp/files.orig.el Fri Aug 2 15:49:36 2002 --- /home/eddy/.sys/elisp/files.el Fri Aug 16 16:15:32 2002 *************** *** 3415,3420 **** --- 3415,3421 ---- ;; Get the name of the session file to recover from. (let ((file (dired-get-filename)) files + visits (buffer (get-buffer-create " *recover*"))) (dired-unmark 1) (dired-do-flagged-delete t) *************** *** 3424,3432 **** (set-buffer buffer) (erase-buffer) (insert-file-contents file) ! ;; Loop thru the text of that file ! ;; and get out the names of the files to recover. (while (not (eobp)) (let (thisfile autofile) (if (eolp) ;; This is a pair of lines for a non-file-visiting buffer. --- 3425,3437 ---- (set-buffer buffer) (erase-buffer) (insert-file-contents file) ! ;; The file contains a pair of line for each auto-saved buffer. ! ;; Loop thru the text of that file and get out the names of ! ;; the files to recover. (while (not (eobp)) + ;; 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. (let (thisfile autofile) (if (eolp) ;; This is a pair of lines for a non-file-visiting buffer. *************** *** 3458,3471 **** (buffer-substring-no-properties (point) (progn (end-of-line) (point)))) (forward-line 1))) ! ;; 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) --- 3463,3474 ---- (buffer-substring-no-properties (point) (progn (end-of-line) (point)))) (forward-line 1))) ! ;; If its auto-save file exists now, recover it; else reload. (if (file-exists-p autofile) ! (setq files (cons thisfile files)) ! (setq visits (cons thisfile visits))))) ! (setq visits (nreverse visits)) (setq files (nreverse files)) (if files (map-y-or-n-p "Recover %s? " (lambda (file) *************** *** 3475,3481 **** "Failed to recover `%s'" file))) files '("file" "files" "recover")) ! (message "No files can be recovered from this session now"))) (kill-buffer buffer)))) (defun kill-some-buffers (&optional list) --- 3478,3493 ---- "Failed to recover `%s'" file))) files '("file" "files" "recover")) ! (message "No files can be recovered from this session now")) ! (if visits ! (map-y-or-n-p "Reload %s? " ! (lambda (file) ! (condition-case nil ! (save-excursion (find-file file)) ! (error ! "Failed to reload `%s'" file))) ! visits ! '("file" "files" "reload")))) (kill-buffer buffer)))) (defun kill-some-buffers (&optional list) Note that I've repositioned some comment lines - explaining the file format seemed more sensible at the start of parsing rather than just after the end. I note that byte-compiling files.el also produces some grumbles: Compiling file /home/eddy/.sys/elisp/files.el at Fri Aug 16 16:09:23 2002 While compiling read-directory-name: ** read-file-name called with 6 arguments, but accepts only 1-5 While compiling make-auto-save-file-name: ** make-temp-file called with 3 arguments, but accepts only 1-2 While compiling save-buffers-kill-emacs: ** list-processes called with 1 argument, but accepts only 0 While compiling the end of the data: ** The following functions are not known to be defined: msdos-long-file-names, defvaralias, locate-file-internal, test-completion, w32-long-file-name, dos-8+3-filename, file-system-info, vms-read-directory, process-query-on-exit-flag Eddy.