comparison lisp/packages/auto-save.el @ 48:56c54cf7c5b6 r19-16b90

Import from CVS: tag r19-16b90
author cvs
date Mon, 13 Aug 2007 08:56:04 +0200
parents 4103f0995bd7
children 131b0175ea99
comparison
equal deleted inserted replaced
47:11c6df210d7f 48:56c54cf7c5b6
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
248 ;; avoids autosaving from two Emacses into the same file. 248 ;; avoids autosaving from two Emacses into the same file.
249 ;; It cannot be recovered automatically then because in 249 ;; It cannot be recovered automatically then because in
250 ;; the next Emacs session (the one after the crash) the 250 ;; the next Emacs session (the one after the crash) the
251 ;; pid will be different, but file-less buffers like 251 ;; pid will be different, but file-less buffers like
252 ;; *mail* must be recovered manually anyway. 252 ;; *mail* must be recovered manually anyway.
253 (name-prefix (if file-name nil (make-temp-name "#%"))) 253
254 ;; jwz: putting the emacs PID in the auto-save file name is bad
255 ;; news, because that defeats auto-save-recovery of *mail*
256 ;; buffers -- the (sensible) code in sendmail.el calls
257 ;; (make-auto-save-file-name) to determine whether there is
258 ;; unsent, auto-saved mail to recover. If that mail came from a
259 ;; previous emacs process (far and away the most likely case)
260 ;; then this can never succeed as the pid differs.
261 ;; (name-prefix (if file-name nil (make-temp-name "#%")))
262 (name-prefix (if file-name nil "#%"))
263
254 (save-name (or file-name 264 (save-name (or file-name
255 ;; Prevent autosave errors. Buffername 265 ;; Prevent autosave errors. Buffername
256 ;; (to become non-dir part of filename) will 266 ;; (to become non-dir part of filename) will
257 ;; be unslashified twice. Don't care. 267 ;; be unslashified twice. Don't care.
258 (auto-save-unslashify-name (buffer-name)))) 268 (auto-save-unslashify-name (buffer-name))))
474 (message "autosave file \"%s\" is not current." afile) 484 (message "autosave file \"%s\" is not current." afile)
475 (sit-for 2)) 485 (sit-for 2))
476 (t 486 (t
477 (setq total (1+ total)) 487 (setq total (1+ total))
478 (with-output-to-temp-buffer "*Directory*" 488 (with-output-to-temp-buffer "*Directory*"
479 (call-process "ls" nil standard-output nil 489 (apply 'call-process "ls" nil standard-output nil
480 "-l" afile (if file (list file)))) 490 "-l" afile (if file (list file))))
481 (if (yes-or-no-p (format "Recover %s from auto save file? " 491 (if (yes-or-no-p (format "Recover %s from auto save file? "
482 file)) 492 (or file "non-file buffer")))
483 (let* ((obuf (current-buffer)) 493 (let* ((obuf (current-buffer))
484 (buf (set-buffer 494 (buf (set-buffer
485 (if file 495 (if file
486 (find-file-noselect file t) 496 (find-file-noselect file t)
487 (generate-new-buffer "*recovered*")))) 497 (generate-new-buffer "*recovered*"))))