comparison src/fileio.c @ 110:fe104dbd9147 r20-1b7

Import from CVS: tag r20-1b7
author cvs
date Mon, 13 Aug 2007 09:19:45 +0200
parents 4be1180a9e89
children 8619ce7e4c50
comparison
equal deleted inserted replaced
109:e183fc049578 110:fe104dbd9147
4162 auto_save_error (Lisp_Object condition_object, Lisp_Object ignored) 4162 auto_save_error (Lisp_Object condition_object, Lisp_Object ignored)
4163 { 4163 {
4164 /* This function can GC */ 4164 /* This function can GC */
4165 if (gc_in_progress) 4165 if (gc_in_progress)
4166 return Qnil; 4166 return Qnil;
4167 /* Don't try printing an error message after everything is gone! */
4168 if (preparing_for_armageddon)
4169 return Qnil;
4167 clear_echo_area (selected_frame (), Qauto_saving, 1); 4170 clear_echo_area (selected_frame (), Qauto_saving, 1);
4168 Fding (Qt, Qauto_save_error, Qnil); 4171 Fding (Qt, Qauto_save_error, Qnil);
4169 message ("Auto-saving...error for %s", XSTRING_DATA (current_buffer->name)); 4172 message ("Auto-saving...error for %s", XSTRING_DATA (current_buffer->name));
4170 Fsleep_for (make_int (1)); 4173 Fsleep_for (make_int (1));
4171 message ("Auto-saving...error!for %s", XSTRING_DATA (current_buffer->name)); 4174 message ("Auto-saving...error!for %s", XSTRING_DATA (current_buffer->name));
4244 Non-nil second argument means save only current buffer. 4247 Non-nil second argument means save only current buffer.
4245 */ 4248 */
4246 (no_message, current_only)) 4249 (no_message, current_only))
4247 { 4250 {
4248 /* This function can GC */ 4251 /* This function can GC */
4249 struct buffer *old = current_buffer, *b; 4252 struct buffer *b;
4250 Lisp_Object tail, buf; 4253 Lisp_Object tail, buf;
4251 int auto_saved = 0; 4254 int auto_saved = 0;
4252 int do_handled_files; 4255 int do_handled_files;
4253 Lisp_Object oquit = Qnil; 4256 Lisp_Object oquit = Qnil;
4254 Lisp_Object listfile = Qnil; 4257 Lisp_Object listfile = Qnil;
4258 Lisp_Object old;
4255 int listdesc = -1; 4259 int listdesc = -1;
4256 int speccount = specpdl_depth (); 4260 int speccount = specpdl_depth ();
4257 struct gcpro gcpro1, gcpro2; 4261 struct gcpro gcpro1, gcpro2, gcpro3;
4258 4262
4259 GCPRO2 (oquit, listfile); 4263 XSETBUFFER (old, current_buffer);
4264 GCPRO3 (oquit, listfile, old);
4260 check_quit (); /* make Vquit_flag accurate */ 4265 check_quit (); /* make Vquit_flag accurate */
4261 /* Ordinarily don't quit within this function, 4266 /* Ordinarily don't quit within this function,
4262 but don't make it impossible to quit (in case we get hung in I/O). */ 4267 but don't make it impossible to quit (in case we get hung in I/O). */
4263 oquit = Vquit_flag; 4268 oquit = Vquit_flag;
4264 Vquit_flag = Qnil; 4269 Vquit_flag = Qnil;
4406 write (listdesc, auto_save_file_name_ext, 4411 write (listdesc, auto_save_file_name_ext,
4407 auto_save_file_name_ext_len); 4412 auto_save_file_name_ext_len);
4408 write (listdesc, "\n", 1); 4413 write (listdesc, "\n", 1);
4409 } 4414 }
4410 4415
4411 condition_case_1 (Qt, 4416 /* dmoore - In a bad scenario we've set b=XBUFFER(buf)
4412 auto_save_1, Qnil, 4417 based on values in Vbuffer_alist. auto_save_1 may
4413 auto_save_error, Qnil); 4418 cause lisp handlers to run. Those handlers may kill
4419 the buffer and then GC. Since the buffer is killed,
4420 it's no longer in Vbuffer_alist so it might get reaped
4421 by the GC. We also need to protect tail. */
4422 /* #### There is probably a lot of other code which has
4423 pointers into buffers which may get blown away by
4424 handlers. */
4425 {
4426 struct gcpro gcpro1, gcpro2;
4427 GCPRO2 (buf, tail);
4428 condition_case_1 (Qt,
4429 auto_save_1, Qnil,
4430 auto_save_error, Qnil);
4431 UNGCPRO;
4432 }
4433 /* Handler killed our saved current-buffer! Pick any. */
4434 if (!BUFFER_LIVE_P (XBUFFER (old)))
4435 XSETBUFFER (old, current_buffer);
4436
4437 set_buffer_internal (XBUFFER (old));
4414 auto_saved++; 4438 auto_saved++;
4439
4440 /* Handler killed their own buffer! */
4441 if (!BUFFER_LIVE_P(b))
4442 continue;
4443
4415 b->auto_save_modified = BUF_MODIFF (b); 4444 b->auto_save_modified = BUF_MODIFF (b);
4416 b->save_length = make_int (BUF_SIZE (b)); 4445 b->save_length = make_int (BUF_SIZE (b));
4417 set_buffer_internal (old);
4418
4419 EMACS_GET_TIME (after_time); 4446 EMACS_GET_TIME (after_time);
4420 /* If auto-save took more than 60 seconds, 4447 /* If auto-save took more than 60 seconds,
4421 assume it was an NFS failure that got a timeout. */ 4448 assume it was an NFS failure that got a timeout. */
4422 if (EMACS_SECS (after_time) - EMACS_SECS (before_time) > 60) 4449 if (EMACS_SECS (after_time) - EMACS_SECS (before_time) > 60)
4423 b->auto_save_failure_time = EMACS_SECS (after_time); 4450 b->auto_save_failure_time = EMACS_SECS (after_time);