DEFVAR_PER_BUFFER ("buffer-saved-size", ¤t_buffer->save_length,
make_number (Lisp_Int),
doc: /* Length of current buffer when last read in, saved or auto-saved.
-0 initially. */);
+0 initially.
+-1 means auto-saving turned off until next real save.
+
+If you set this to -2, that means don't turn off auto-saving in this buffer
+if its text size shrinks. If you use `buffer-swap-text' on a buffer,
+you probably should set this to -2 in that buffer. */);
DEFVAR_PER_BUFFER ("selective-display", ¤t_buffer->selective_display,
Qnil,
/* This isn't really used by the C code, so could be deleted. */
Lisp_Object backed_up;
/* Length of file when last read or saved.
+ -1 means auto saving turned off because buffer shrank a lot.
+ -2 means don't turn off auto saving if buffer shrinks.
+ (That value is used with buffer-swap-text.)
This is not in the struct buffer_text
because it's not used in indirect buffers at all. */
Lisp_Object save_length;
if (visiting)
{
SAVE_MODIFF = MODIFF;
- XSETFASTINT (current_buffer->save_length, Z - BEG);
+ if (XINT (current_buffer->save_length) != -2)
+ XSETFASTINT (current_buffer->save_length, Z - BEG);
current_buffer->filename = visit_file;
}
UNGCPRO;
if (visiting)
{
SAVE_MODIFF = MODIFF;
- XSETFASTINT (current_buffer->save_length, Z - BEG);
+ if (XINT (current_buffer->save_length) != -2)
+ XSETFASTINT (current_buffer->save_length, Z - BEG);
current_buffer->filename = visit_file;
update_mode_lines++;
}
&& BUF_SAVE_MODIFF (b) < BUF_MODIFF (b)
&& b->auto_save_modified < BUF_MODIFF (b)
/* -1 means we've turned off autosaving for a while--see below. */
- && XINT (b->save_length) >= 0
+ && XINT (b->save_length) != -1
&& (do_handled_files
|| NILP (Ffind_file_name_handler (b->auto_save_file_name,
Qwrite_region))))
&& EMACS_SECS (before_time) - b->auto_save_failure_time < 1200)
continue;
- if ((XFASTINT (b->save_length) * 10
- > (BUF_Z (b) - BUF_BEG (b)) * 13)
+ if (XINT (b->save_length) != -2
+ /* -2 is a magic flag turning off this feature in a buffer. */
+ && (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
internal_condition_case (auto_save_1, Qt, auto_save_error);
auto_saved++;
b->auto_save_modified = BUF_MODIFF (b);
- XSETFASTINT (current_buffer->save_length, Z - BEG);
+ if (XINT (current_buffer->save_length) != -2)
+ XSETFASTINT (current_buffer->save_length, Z - BEG);
set_buffer_internal (old);
EMACS_GET_TIME (after_time);
()
{
current_buffer->auto_save_modified = MODIFF;
- XSETFASTINT (current_buffer->save_length, Z - BEG);
+ if (XINT (current_buffer->save_length) != -2)
+ XSETFASTINT (current_buffer->save_length, Z - BEG);
current_buffer->auto_save_failure_time = -1;
return Qnil;
}