diff options
author | Stefan Monnier <monnier@iro.umontreal.ca> | 2010-01-12 23:33:42 -0500 |
---|---|---|
committer | Stefan Monnier <monnier@iro.umontreal.ca> | 2010-01-12 23:33:42 -0500 |
commit | 0b5397c27163729ca48af4d0c569e574638be2d1 (patch) | |
tree | 626dd46c422a029de0664b2be4a625460663f463 /src/buffer.c | |
parent | d1bf28dc12ef1a0f3cecbf78f38795db27b38574 (diff) | |
download | emacs-0b5397c27163729ca48af4d0c569e574638be2d1.tar.gz emacs-0b5397c27163729ca48af4d0c569e574638be2d1.tar.bz2 emacs-0b5397c27163729ca48af4d0c569e574638be2d1.zip |
Try to fix bug#5314. This is probably not the final word, tho.
* buffer.c (Fset_buffer_modified_p): Try and be careful not to modify
recent-auto-save-p as a side-effect.
* buffer.h (BUF_AUTOSAVE_MODIFF): New macro.
* buffer.c (Fkill_buffer, reset_buffer):
* editfns.c (Fsubst_char_in_region):
* fileio.c (Finsert_file_contents, Fdo_auto_save)
(Fset_buffer_auto_saved, Frecent_auto_save_p): Use it.
Diffstat (limited to 'src/buffer.c')
-rw-r--r-- | src/buffer.c | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/src/buffer.c b/src/buffer.c index 8657fd8cdff..1880581c0a1 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -1,7 +1,7 @@ /* Buffer manipulation primitives for GNU Emacs. Copyright (C) 1985, 1986, 1987, 1988, 1989, 1993, 1994, 1995, 1997, 1998, 1999, 2000, 2001, 2002, - 2003, 2004, 2005, 2006, 2007, 2008, 2009 + 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -704,7 +704,7 @@ reset_buffer (b) b->clip_changed = 0; b->prevent_redisplay_optimizations_p = 1; b->backed_up = Qnil; - b->auto_save_modified = 0; + BUF_AUTOSAVE_MODIFF (b) = 0; b->auto_save_failure_time = -1; b->auto_save_file_name = Qnil; b->read_only = Qnil; @@ -1132,7 +1132,25 @@ A non-nil FLAG means mark the buffer modified. */) } #endif /* CLASH_DETECTION */ - SAVE_MODIFF = NILP (flag) ? MODIFF : 0; + /* Here we have a problem. SAVE_MODIFF is used here to encode + buffer-modified-p (as SAVE_MODIFF<MODIFF) as well as + recent-auto-save-p (as SAVE_MODIFF<auto_save_modified). So if we + modify SAVE_MODIFF to affect one, we may affect the other + as well. + E.g. if FLAG is nil we need to set SAVE_MODIFF to MODIFF, but + if SAVE_MODIFF<auto_save_modified that means we risk changing + recent-auto-save-p from t to nil. + Vice versa, if FLAG is non-nil and SAVE_MODIFF>=auto_save_modified + we risk changing recent-auto-save-p from nil to t. */ + SAVE_MODIFF = (NILP (flag) + /* FIXME: This unavoidably sets recent-auto-save-p to nil. */ + ? MODIFF + /* Let's try to preserve recent-auto-save-p. */ + : SAVE_MODIFF < MODIFF ? SAVE_MODIFF + /* If SAVE_MODIFF == auto_save_modified == MODIFF, + we can either decrease SAVE_MODIFF and auto_save_modified + or increase MODIFF. */ + : MODIFF++); /* Set update_mode_lines only if buffer is displayed in some window. Packages like jit-lock or lazy-lock preserve a buffer's modified @@ -1541,8 +1559,8 @@ with SIGHUP. */) /* Delete any auto-save file, if we saved it in this session. But not if the buffer is modified. */ if (STRINGP (b->auto_save_file_name) - && b->auto_save_modified != 0 - && BUF_SAVE_MODIFF (b) < b->auto_save_modified + && BUF_AUTOSAVE_MODIFF (b) != 0 + && BUF_SAVE_MODIFF (b) < BUF_AUTOSAVE_MODIFF (b) && BUF_SAVE_MODIFF (b) < BUF_MODIFF (b) && NILP (Fsymbol_value (intern ("auto-save-visited-file-name")))) { |