comparison lisp/packages/auto-save.el @ 134:34a5b81f86ba r20-2b1

Import from CVS: tag r20-2b1
author cvs
date Mon, 13 Aug 2007 09:30:11 +0200
parents cca96a509cfe
children 538048ae2ab8
comparison
equal deleted inserted replaced
133:b27e67717092 134:34a5b81f86ba
1 ;; -*- Emacs-Lisp -*- 1 ;; -*- Emacs-Lisp -*-
2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3 ;; 3 ;;
4 ;; File: auto-save.el 4 ;; File: auto-save.el
5 ;; Version: $Revision: 1.3 $ 5 ;; Version: $Revision: 1.4 $
6 ;; RCS: 6 ;; RCS:
7 ;; Description: Safer autosaving with support for efs and /tmp. 7 ;; Description: Safer autosaving with support for efs and /tmp.
8 ;; This version of auto-save is designed to work with efs, 8 ;; This version of auto-save is designed to work with efs,
9 ;; instead of ange-ftp. 9 ;; instead of ange-ftp.
10 ;; Author: Sebastian Kremer <sk@thp.uni-koeln.de>, 10 ;; Author: Sebastian Kremer <sk@thp.uni-koeln.de>,
11 ;; 11 ;;
12 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 12 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
13 13
14 (defconst auto-save-version (substring "$Revision: 1.3 $" 11 -2) 14 (defconst auto-save-version (substring "$Revision: 1.4 $" 11 -2)
15 "Version number of auto-save.") 15 "Version number of auto-save.")
16 16
17 ;;; Copyright (C) 1992 by Sebastian Kremer <sk@thp.uni-koeln.de> 17 ;;; Copyright (C) 1992 by Sebastian Kremer <sk@thp.uni-koeln.de>
18 18
19 ;;; This program is free software; you can redistribute it and/or modify 19 ;;; This program is free software; you can redistribute it and/or modify
266 ;; avoids autosaving from two Emacses into the same file. 266 ;; avoids autosaving from two Emacses into the same file.
267 ;; It cannot be recovered automatically then because in 267 ;; It cannot be recovered automatically then because in
268 ;; the next Emacs session (the one after the crash) the 268 ;; the next Emacs session (the one after the crash) the
269 ;; pid will be different, but file-less buffers like 269 ;; pid will be different, but file-less buffers like
270 ;; *mail* must be recovered manually anyway. 270 ;; *mail* must be recovered manually anyway.
271 (name-prefix (if file-name nil (make-temp-name "#%"))) 271
272 ;; jwz: putting the emacs PID in the auto-save file name is bad
273 ;; news, because that defeats auto-save-recovery of *mail*
274 ;; buffers -- the (sensible) code in sendmail.el calls
275 ;; (make-auto-save-file-name) to determine whether there is
276 ;; unsent, auto-saved mail to recover. If that mail came from a
277 ;; previous emacs process (far and away the most likely case)
278 ;; then this can never succeed as the pid differs.
279 ;; (name-prefix (if file-name nil (make-temp-name "#%")))
280 (name-prefix (if file-name nil "#%"))
281
272 (save-name (or file-name 282 (save-name (or file-name
273 ;; Prevent autosave errors. Buffername 283 ;; Prevent autosave errors. Buffername
274 ;; (to become non-dir part of filename) will 284 ;; (to become non-dir part of filename) will
275 ;; be unslashified twice. Don't care. 285 ;; be unslashified twice. Don't care.
276 (auto-save-unslashify-name (buffer-name)))) 286 (auto-save-unslashify-name (buffer-name))))
492 (message "autosave file \"%s\" is not current." afile) 502 (message "autosave file \"%s\" is not current." afile)
493 (sit-for 2)) 503 (sit-for 2))
494 (t 504 (t
495 (setq total (1+ total)) 505 (setq total (1+ total))
496 (with-output-to-temp-buffer "*Directory*" 506 (with-output-to-temp-buffer "*Directory*"
497 (call-process "ls" nil standard-output nil 507 (apply 'call-process "ls" nil standard-output nil
498 "-l" afile (if file (list file)))) 508 "-l" afile (if file (list file))))
499 (if (yes-or-no-p (format "Recover %s from auto save file? " 509 (if (yes-or-no-p (format "Recover %s from auto save file? "
500 file)) 510 (or file "non-file buffer")))
501 (let* ((obuf (current-buffer)) 511 (let* ((obuf (current-buffer))
502 (buf (set-buffer 512 (buf (set-buffer
503 (if file 513 (if file
504 (find-file-noselect file t) 514 (find-file-noselect file t)
505 (generate-new-buffer "*recovered*")))) 515 (generate-new-buffer "*recovered*"))))