- for (tail = Vbuffer_alist; XGCTYPE (tail) == Lisp_Cons;
- tail = XCONS (tail)->cdr)
- {
- buf = XCONS (XCONS (tail)->car)->cdr;
- b = XBUFFER (buf);
- /* Check for auto save enabled
- and file changed since last auto save
- and file changed since last real save. */
- if (XTYPE (b->auto_save_file_name) == Lisp_String
- && b->save_modified < BUF_MODIFF (b)
- && b->auto_save_modified < BUF_MODIFF (b))
- {
- if ((XFASTINT (b->save_length) * 10
- > (BUF_Z (b) - BUF_BEG (b)) * 13)
- /* A short file is likely to change a large fraction;
- spare the user annoying messages. */
- && XFASTINT (b->save_length) > 5000
- /* These messages are frequent and annoying for `*mail*'. */
- && !EQ (b->filename, Qnil))
- {
- /* It has shrunk too much; turn off auto-saving here. */
- message ("Buffer %s has shrunk a lot; auto save turned off there",
- XSTRING (b->name)->data);
- /* User can reenable saving with M-x auto-save. */
- b->auto_save_file_name = Qnil;
- /* Prevent warning from repeating if user does so. */
- XFASTINT (b->save_length) = 0;
- Fsleep_for (make_number (1), Qnil);
- continue;
- }
- set_buffer_internal (b);
- if (!auto_saved && NILP (nomsg))
- message1 ("Auto-saving...");
- internal_condition_case (auto_save_1, Qt, auto_save_error);
- auto_saved++;
- b->auto_save_modified = BUF_MODIFF (b);
- XFASTINT (current_buffer->save_length) = Z - BEG;
- set_buffer_internal (old);
- }
- }
+ /* First, save all files which don't have handlers. If Emacs is
+ crashing, the handlers may tweak what is causing Emacs to crash
+ in the first place, and it would be a shame if Emacs failed to
+ autosave perfectly ordinary files because it couldn't handle some
+ ange-ftp'd file. */
+ for (do_handled_files = 0; do_handled_files < 2; do_handled_files++)
+ for (tail = Vbuffer_alist; XGCTYPE (tail) == Lisp_Cons;
+ tail = XCONS (tail)->cdr)
+ {
+ buf = XCONS (XCONS (tail)->car)->cdr;
+ b = XBUFFER (buf);
+
+ if (!NILP (current_only)
+ && b != current_buffer)
+ continue;
+
+ /* Check for auto save enabled
+ and file changed since last auto save
+ and file changed since last real save. */
+ if (XTYPE (b->auto_save_file_name) == Lisp_String
+ && b->save_modified < BUF_MODIFF (b)
+ && b->auto_save_modified < BUF_MODIFF (b)
+ && (do_handled_files
+ || NILP (Ffind_file_name_handler (b->auto_save_file_name))))
+ {
+ if ((XFASTINT (b->save_length) * 10
+ > (BUF_Z (b) - BUF_BEG (b)) * 13)
+ /* A short file is likely to change a large fraction;
+ spare the user annoying messages. */
+ && XFASTINT (b->save_length) > 5000
+ /* These messages are frequent and annoying for `*mail*'. */
+ && !EQ (b->filename, Qnil)
+ && NILP (no_message))
+ {
+ /* It has shrunk too much; turn off auto-saving here. */
+ message ("Buffer %s has shrunk a lot; auto save turned off there",
+ XSTRING (b->name)->data);
+ /* User can reenable saving with M-x auto-save. */
+ b->auto_save_file_name = Qnil;
+ /* Prevent warning from repeating if user does so. */
+ XFASTINT (b->save_length) = 0;
+ Fsleep_for (make_number (1), Qnil);
+ continue;
+ }
+ set_buffer_internal (b);
+ if (!auto_saved && NILP (no_message))
+ message1 ("Auto-saving...");
+ internal_condition_case (auto_save_1, Qt, auto_save_error);
+ auto_saved++;
+ b->auto_save_modified = BUF_MODIFF (b);
+ XFASTINT (current_buffer->save_length) = Z - BEG;
+ set_buffer_internal (old);
+ }
+ }