aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/fileio.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/fileio.c b/src/fileio.c
index c462c27b97d..702d09f41b8 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -3367,6 +3367,15 @@ Non-nil second argument means save only current buffer.")
3367 && (do_handled_files 3367 && (do_handled_files
3368 || NILP (Ffind_file_name_handler (b->auto_save_file_name)))) 3368 || NILP (Ffind_file_name_handler (b->auto_save_file_name))))
3369 { 3369 {
3370 EMACS_TIME before_time, after_time;
3371
3372 EMACS_GET_TIME (before_time);
3373
3374 /* If we had a failure, don't try again for 20 minutes. */
3375 if (b->auto_save_failure_time >= 0
3376 && EMACS_SECS (before_time) - b->auto_save_failure_time < 1200)
3377 continue;
3378
3370 if ((XFASTINT (b->save_length) * 10 3379 if ((XFASTINT (b->save_length) * 10
3371 > (BUF_Z (b) - BUF_BEG (b)) * 13) 3380 > (BUF_Z (b) - BUF_BEG (b)) * 13)
3372 /* A short file is likely to change a large fraction; 3381 /* A short file is likely to change a large fraction;
@@ -3394,6 +3403,13 @@ Non-nil second argument means save only current buffer.")
3394 b->auto_save_modified = BUF_MODIFF (b); 3403 b->auto_save_modified = BUF_MODIFF (b);
3395 XFASTINT (current_buffer->save_length) = Z - BEG; 3404 XFASTINT (current_buffer->save_length) = Z - BEG;
3396 set_buffer_internal (old); 3405 set_buffer_internal (old);
3406
3407 EMACS_GET_TIME (after_time);
3408
3409 /* If auto-save took more than 60 seconds,
3410 assume it was an NFS failure that got a timeout. */
3411 if (EMACS_SECS (after_time) - EMACS_SECS (before_time) > 60)
3412 b->auto_save_failure_time = EMACS_SECS (after_time);
3397 } 3413 }
3398 } 3414 }
3399 3415
@@ -3417,6 +3433,16 @@ No auto-save file will be written until the buffer changes again.")
3417{ 3433{
3418 current_buffer->auto_save_modified = MODIFF; 3434 current_buffer->auto_save_modified = MODIFF;
3419 XFASTINT (current_buffer->save_length) = Z - BEG; 3435 XFASTINT (current_buffer->save_length) = Z - BEG;
3436 current_buffer->auto_save_failure_time = -1;
3437 return Qnil;
3438}
3439
3440DEFUN ("clear-buffer-auto-save-failure", Fclear_buffer_auto_save_failure,
3441 Sclear_buffer_auto_save_failure, 0, 0, 0,
3442 "Clear any record of a recent auto-save failure in the current buffer.")
3443 ()
3444{
3445 current_buffer->auto_save_failure_time = -1;
3420 return Qnil; 3446 return Qnil;
3421} 3447}
3422 3448
@@ -3849,6 +3875,7 @@ lists are merged destructively.");
3849 defsubr (&Sset_visited_file_modtime); 3875 defsubr (&Sset_visited_file_modtime);
3850 defsubr (&Sdo_auto_save); 3876 defsubr (&Sdo_auto_save);
3851 defsubr (&Sset_buffer_auto_saved); 3877 defsubr (&Sset_buffer_auto_saved);
3878 defsubr (&Sclear_buffer_auto_save_failure);
3852 defsubr (&Srecent_auto_save_p); 3879 defsubr (&Srecent_auto_save_p);
3853 3880
3854 defsubr (&Sread_file_name_internal); 3881 defsubr (&Sread_file_name_internal);