diff options
| author | Stefan Monnier | 2010-01-12 23:33:42 -0500 |
|---|---|---|
| committer | Stefan Monnier | 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.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 @@ | |||
| 1 | /* Buffer manipulation primitives for GNU Emacs. | 1 | /* Buffer manipulation primitives for GNU Emacs. |
| 2 | Copyright (C) 1985, 1986, 1987, 1988, 1989, 1993, 1994, | 2 | Copyright (C) 1985, 1986, 1987, 1988, 1989, 1993, 1994, |
| 3 | 1995, 1997, 1998, 1999, 2000, 2001, 2002, | 3 | 1995, 1997, 1998, 1999, 2000, 2001, 2002, |
| 4 | 2003, 2004, 2005, 2006, 2007, 2008, 2009 | 4 | 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 |
| 5 | Free Software Foundation, Inc. | 5 | Free Software Foundation, Inc. |
| 6 | 6 | ||
| 7 | This file is part of GNU Emacs. | 7 | This file is part of GNU Emacs. |
| @@ -704,7 +704,7 @@ reset_buffer (b) | |||
| 704 | b->clip_changed = 0; | 704 | b->clip_changed = 0; |
| 705 | b->prevent_redisplay_optimizations_p = 1; | 705 | b->prevent_redisplay_optimizations_p = 1; |
| 706 | b->backed_up = Qnil; | 706 | b->backed_up = Qnil; |
| 707 | b->auto_save_modified = 0; | 707 | BUF_AUTOSAVE_MODIFF (b) = 0; |
| 708 | b->auto_save_failure_time = -1; | 708 | b->auto_save_failure_time = -1; |
| 709 | b->auto_save_file_name = Qnil; | 709 | b->auto_save_file_name = Qnil; |
| 710 | b->read_only = Qnil; | 710 | b->read_only = Qnil; |
| @@ -1132,7 +1132,25 @@ A non-nil FLAG means mark the buffer modified. */) | |||
| 1132 | } | 1132 | } |
| 1133 | #endif /* CLASH_DETECTION */ | 1133 | #endif /* CLASH_DETECTION */ |
| 1134 | 1134 | ||
| 1135 | SAVE_MODIFF = NILP (flag) ? MODIFF : 0; | 1135 | /* Here we have a problem. SAVE_MODIFF is used here to encode |
| 1136 | buffer-modified-p (as SAVE_MODIFF<MODIFF) as well as | ||
| 1137 | recent-auto-save-p (as SAVE_MODIFF<auto_save_modified). So if we | ||
| 1138 | modify SAVE_MODIFF to affect one, we may affect the other | ||
| 1139 | as well. | ||
| 1140 | E.g. if FLAG is nil we need to set SAVE_MODIFF to MODIFF, but | ||
| 1141 | if SAVE_MODIFF<auto_save_modified that means we risk changing | ||
| 1142 | recent-auto-save-p from t to nil. | ||
| 1143 | Vice versa, if FLAG is non-nil and SAVE_MODIFF>=auto_save_modified | ||
| 1144 | we risk changing recent-auto-save-p from nil to t. */ | ||
| 1145 | SAVE_MODIFF = (NILP (flag) | ||
| 1146 | /* FIXME: This unavoidably sets recent-auto-save-p to nil. */ | ||
| 1147 | ? MODIFF | ||
| 1148 | /* Let's try to preserve recent-auto-save-p. */ | ||
| 1149 | : SAVE_MODIFF < MODIFF ? SAVE_MODIFF | ||
| 1150 | /* If SAVE_MODIFF == auto_save_modified == MODIFF, | ||
| 1151 | we can either decrease SAVE_MODIFF and auto_save_modified | ||
| 1152 | or increase MODIFF. */ | ||
| 1153 | : MODIFF++); | ||
| 1136 | 1154 | ||
| 1137 | /* Set update_mode_lines only if buffer is displayed in some window. | 1155 | /* Set update_mode_lines only if buffer is displayed in some window. |
| 1138 | Packages like jit-lock or lazy-lock preserve a buffer's modified | 1156 | Packages like jit-lock or lazy-lock preserve a buffer's modified |
| @@ -1541,8 +1559,8 @@ with SIGHUP. */) | |||
| 1541 | /* Delete any auto-save file, if we saved it in this session. | 1559 | /* Delete any auto-save file, if we saved it in this session. |
| 1542 | But not if the buffer is modified. */ | 1560 | But not if the buffer is modified. */ |
| 1543 | if (STRINGP (b->auto_save_file_name) | 1561 | if (STRINGP (b->auto_save_file_name) |
| 1544 | && b->auto_save_modified != 0 | 1562 | && BUF_AUTOSAVE_MODIFF (b) != 0 |
| 1545 | && BUF_SAVE_MODIFF (b) < b->auto_save_modified | 1563 | && BUF_SAVE_MODIFF (b) < BUF_AUTOSAVE_MODIFF (b) |
| 1546 | && BUF_SAVE_MODIFF (b) < BUF_MODIFF (b) | 1564 | && BUF_SAVE_MODIFF (b) < BUF_MODIFF (b) |
| 1547 | && NILP (Fsymbol_value (intern ("auto-save-visited-file-name")))) | 1565 | && NILP (Fsymbol_value (intern ("auto-save-visited-file-name")))) |
| 1548 | { | 1566 | { |