[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: mail-recover seems not working

From: Eli Zaretskii
Subject: Re: mail-recover seems not working
Date: Sun, 30 Dec 2001 16:02:52 +0200 (IST)

On Fri, 28 Dec 2001, Richard Stallman wrote:

> mail-recover is not designed to handle the case where you have killed
> the mail buffer.  It is hard to handle that case, because the
> auto save file name has been lost.

Does the following replacement version of mail-recover seem like a good 

(defun mail-recover ()
  "Reread contents of current mail composition buffer from its auto-save file."
  (let ((file-name (make-auto-save-file-name))
        (ls-lisp-support-shell-wildcards t)
        (buf (current-buffer))
    (if (eq system-type 'vax-vms)
        (setq file-name buffer-auto-save-file-name)
      ;; Remove the random part from the auto-save-file-name, and
      ;; create a wildcard which matches possible candidates.
      ;; Note: this knows that make-auto-save-file-name appends
      ;; "#<RANDOM-STUFF>#" to the buffer name, where RANDOM-STUFF
      ;; is the result of (make-temp-name "").
      (setq non-random-len
            (- (length file-name) (length (make-temp-name "")) 1))
      (setq file-name (concat (substring file-name 0 non-random-len) "*")))
    (dired file-name (concat dired-listing-switches "t"))
    (rename-buffer "*Auto-saved Drafts*" t)
      (goto-char (point-min))
      (or (looking-at " Move to the draft file you want to recover,")
          (let ((inhibit-read-only t))
            ;; Each line starts with a space so that Font Lock
            ;; mode won't highlight the first character.
             " Move to the draft file you want to recover, then type C-c C-c\n"
             " to recover text of message whose composition was interrupted.\n"
             " To browse text of a draft, type v on the draft file's line.\n\n"
             " You can also delete some of these files;\n"
             " type d on a line to mark that file for deletion.\n\n"
             " List of possible auto-save files for recovery:\n\n"))))
    (use-local-map (nconc (make-sparse-keymap) (current-local-map)))
    (define-key (current-local-map) "\C-c\C-c"
      (lambda ()
        (let ((fname (dired-get-filename))
              ;; Auto-saved files are written in the internal
              ;; representation, so they should be read accordingly.
              (coding-system-for-read 'emacs-mule-unix))
          (cond ((yes-or-no-p
                  (format "Recover interrupted message from file %s? "
                 (switch-to-buffer "*mail*")
                 (let ((buffer-read-only nil))
                   (insert-file-contents fname nil)))
                 (switch-to-buffer "*mail*")
                 (error "mail-recover cancelled"))))))))

reply via email to

[Prev in Thread] Current Thread [Next in Thread]