comparison src/fileio.c @ 32:e04119814345 r19-15b99

Import from CVS: tag r19-15b99
author cvs
date Mon, 13 Aug 2007 08:52:56 +0200
parents 859a2309aef8
children 7e54bd776075
comparison
equal deleted inserted replaced
31:b9328a10c56c 32:e04119814345
4119 auto_save_error (Lisp_Object condition_object, Lisp_Object ignored) 4119 auto_save_error (Lisp_Object condition_object, Lisp_Object ignored)
4120 { 4120 {
4121 /* This function can GC */ 4121 /* This function can GC */
4122 if (gc_in_progress) 4122 if (gc_in_progress)
4123 return Qnil; 4123 return Qnil;
4124 /* Don't try printing an error message after everything is gone! */
4125 if (preparing_for_armageddon)
4126 return Qnil;
4124 clear_echo_area (selected_frame (), Qauto_saving, 1); 4127 clear_echo_area (selected_frame (), Qauto_saving, 1);
4125 Fding (Qt, Qauto_save_error, Qnil); 4128 Fding (Qt, Qauto_save_error, Qnil);
4126 message ("Auto-saving...error for %s", XSTRING_DATA (current_buffer->name)); 4129 message ("Auto-saving...error for %s", XSTRING_DATA (current_buffer->name));
4127 Fsleep_for (make_int (1)); 4130 Fsleep_for (make_int (1));
4128 message ("Auto-saving...error!for %s", XSTRING_DATA (current_buffer->name)); 4131 message ("Auto-saving...error!for %s", XSTRING_DATA (current_buffer->name));
4194 Non-nil second argument means save only current buffer. 4197 Non-nil second argument means save only current buffer.
4195 */ 4198 */
4196 (no_message, current_only)) 4199 (no_message, current_only))
4197 { 4200 {
4198 /* This function can GC */ 4201 /* This function can GC */
4199 struct buffer *old = current_buffer, *b; 4202 struct buffer *b;
4200 Lisp_Object tail, buf; 4203 Lisp_Object tail, buf;
4201 int auto_saved = 0; 4204 int auto_saved = 0;
4202 int do_handled_files; 4205 int do_handled_files;
4203 Lisp_Object oquit = Qnil; 4206 Lisp_Object oquit = Qnil;
4204 Lisp_Object listfile = Qnil; 4207 Lisp_Object listfile = Qnil;
4208 Lisp_Object old;
4205 int listdesc = -1; 4209 int listdesc = -1;
4206 int speccount = specpdl_depth (); 4210 int speccount = specpdl_depth ();
4207 struct gcpro gcpro1, gcpro2; 4211 struct gcpro gcpro1, gcpro2, gcpro3;
4208 4212
4209 GCPRO2 (oquit, listfile); 4213 XSETBUFFER (old, current_buffer);
4214 GCPRO3 (oquit, listfile, old);
4210 check_quit (); /* make Vquit_flag accurate */ 4215 check_quit (); /* make Vquit_flag accurate */
4211 /* Ordinarily don't quit within this function, 4216 /* Ordinarily don't quit within this function,
4212 but don't make it impossible to quit (in case we get hung in I/O). */ 4217 but don't make it impossible to quit (in case we get hung in I/O). */
4213 oquit = Vquit_flag; 4218 oquit = Vquit_flag;
4214 Vquit_flag = Qnil; 4219 Vquit_flag = Qnil;
4356 write (listdesc, auto_save_file_name_ext, 4361 write (listdesc, auto_save_file_name_ext,
4357 auto_save_file_name_ext_len); 4362 auto_save_file_name_ext_len);
4358 write (listdesc, "\n", 1); 4363 write (listdesc, "\n", 1);
4359 } 4364 }
4360 4365
4361 condition_case_1 (Qt, 4366 /* dmoore - In a bad scenario we've set b=XBUFFER(buf)
4362 auto_save_1, Qnil, 4367 based on values in Vbuffer_alist. auto_save_1 may
4363 auto_save_error, Qnil); 4368 cause lisp handlers to run. Those handlers may kill
4369 the buffer and then GC. Since the buffer is killed,
4370 it's no longer in Vbuffer_alist so it might get reaped
4371 by the GC. We also need to protect tail. */
4372 /* #### There is probably a lot of other code which has
4373 pointers into buffers which may get blown away by
4374 handlers. */
4375 {
4376 struct gcpro gcpro1, gcpro2;
4377 GCPRO2 (buf, tail);
4378 condition_case_1 (Qt,
4379 auto_save_1, Qnil,
4380 auto_save_error, Qnil);
4381 UNGCPRO;
4382 }
4383 /* Handler killed our saved current-buffer! Pick any. */
4384 if (!BUFFER_LIVE_P (XBUFFER (old)))
4385 XSETBUFFER (old, current_buffer);
4386
4387 set_buffer_internal (XBUFFER (old));
4364 auto_saved++; 4388 auto_saved++;
4389
4390 /* Handler killed their own buffer! */
4391 if (!BUFFER_LIVE_P(b))
4392 continue;
4393
4365 b->auto_save_modified = BUF_MODIFF (b); 4394 b->auto_save_modified = BUF_MODIFF (b);
4366 b->save_length = make_int (BUF_SIZE (b)); 4395 b->save_length = make_int (BUF_SIZE (b));
4367 set_buffer_internal (old);
4368
4369 EMACS_GET_TIME (after_time); 4396 EMACS_GET_TIME (after_time);
4370 /* If auto-save took more than 60 seconds, 4397 /* If auto-save took more than 60 seconds,
4371 assume it was an NFS failure that got a timeout. */ 4398 assume it was an NFS failure that got a timeout. */
4372 if (EMACS_SECS (after_time) - EMACS_SECS (before_time) > 60) 4399 if (EMACS_SECS (after_time) - EMACS_SECS (before_time) > 60)
4373 b->auto_save_failure_time = EMACS_SECS (after_time); 4400 b->auto_save_failure_time = EMACS_SECS (after_time);