summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2010-01-12 23:33:42 -0500
committerStefan Monnier <monnier@iro.umontreal.ca>2010-01-12 23:33:42 -0500
commit0b5397c27163729ca48af4d0c569e574638be2d1 (patch)
tree626dd46c422a029de0664b2be4a625460663f463
parentd1bf28dc12ef1a0f3cecbf78f38795db27b38574 (diff)
downloademacs-0b5397c27163729ca48af4d0c569e574638be2d1.tar.gz
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.
-rw-r--r--src/ChangeLog33
-rw-r--r--src/buffer.c28
-rw-r--r--src/buffer.h6
-rw-r--r--src/editfns.c6
-rw-r--r--src/fileio.c16
5 files changed, 63 insertions, 26 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 6e3fc4ff1c5..1ad107b566c 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,17 +1,28 @@
+2010-01-13 Stefan Monnier <monnier@iro.umontreal.ca>
+
+ 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.
+
2010-01-13 Kenichi Handa <handa@m17n.org>
Display buffer name, etc. in mode line by composing correctly.
* xdisp.c (reseat_to_string): Call composition_compute_stop_pos if
STRING is not nil.
- (display_mode_element): Adjusted for the change of
+ (display_mode_element): Adjust for the change of
decode_mode_spec and display_line.
(decode_mode_spec): Change arg MULTIBYTE to STRING.
(display_string): Handle the case that STRING is non-null and
LISP_STRING is not nil.
- * xterm.c (x_draw_composite_glyph_string_foreground): Pay
- attention to s->face->overstrike.
+ * xterm.c (x_draw_composite_glyph_string_foreground):
+ Pay attention to s->face->overstrike.
* composite.c (composition_reseat_it): Don't check PT if STRING is
non nil.
@@ -125,8 +136,8 @@
(x_set_window_size): ... to here. bug #2568.
* gtkutil.c (xg_clear_under_internal_border): New function.
- (xg_frame_resized, xg_frame_set_char_size): Call
- xg_clear_under_internal_border.
+ (xg_frame_resized, xg_frame_set_char_size):
+ Call xg_clear_under_internal_border.
(xg_update_scrollbar_pos): Clear under old scroll bar position.
2010-01-05 Chong Yidong <cyd@stupidchicken.com>
@@ -250,8 +261,8 @@
and atimer.h.
(minibuf.o): Depend on systime.h and coding.h. Don't depend on
dispextern.h explicitly.
- (print.o): Depend on termhooks.h, coding.h, and ccl.h. Don't
- depend explicitly on dispextern.h and composite.h.
+ (print.o): Depend on termhooks.h, coding.h, and ccl.h.
+ Don't depend explicitly on dispextern.h and composite.h.
(process.o): Depend on character.h, xgselect.h, and sysselect.h.
(regex.o): Don't depend on charset.h.
(scroll.o): Depend on systime.h, coding.h, composite.h, and window.h.
@@ -430,8 +441,8 @@
2009-12-04 Eli Zaretskii <eliz@gnu.org>
- * dispextern.h (enum prop_idx) <AUTO_COMPOSED_PROP_IDX>: Delete
- unused enumeration value.
+ * dispextern.h (enum prop_idx) <AUTO_COMPOSED_PROP_IDX>:
+ Delete unused enumeration value.
2009-12-03 Eli Zaretskii <eliz@gnu.org>
@@ -562,8 +573,8 @@
2009-11-21 Andreas Schwab <schwab@linux-m68k.org>
- * character.h (STRING_CHAR, STRING_CHAR_AND_LENGTH): Remove
- ignored second argument. All callers changed.
+ * character.h (STRING_CHAR, STRING_CHAR_AND_LENGTH):
+ Remove ignored second argument. All callers changed.
* regex.c (STRING_CHAR, STRING_CHAR_AND_LENGTH, RE_STRING_CHAR)
(RE_STRING_CHAR_AND_LENGTH): Likewise.
* xdisp.c (string_char_and_length): Likewise.
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"))))
{
diff --git a/src/buffer.h b/src/buffer.h
index 9f57a292053..5217c6d7298 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -1,6 +1,6 @@
/* Header file for the buffer manipulation primitives.
Copyright (C) 1985, 1986, 1993, 1994, 1995, 1997, 1998, 1999, 2000, 2001,
- 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
+ 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
Free Software Foundation, Inc.
This file is part of GNU Emacs.
@@ -158,6 +158,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
/* Overlay modification count. */
#define BUF_OVERLAY_MODIFF(buf) ((buf)->text->overlay_modiff)
+/* Modification count as of last auto-save. */
+/* FIXME: should we move this into ->text->auto_save_modiff? */
+#define BUF_AUTOSAVE_MODIFF(buf) ((buf)->auto_save_modified)
+
/* Interval tree of buffer. */
#define BUF_INTERVALS(buf) ((buf)->text->intervals)
diff --git a/src/editfns.c b/src/editfns.c
index 58e13b1ed7c..00ac0ca0fa9 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -1,7 +1,7 @@
/* Lisp functions pertaining to editing.
Copyright (C) 1985, 1986, 1987, 1989, 1993, 1994, 1995, 1996,
1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
- 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
+ 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
This file is part of GNU Emacs.
@@ -2870,8 +2870,8 @@ Both characters must have the same length of multi-byte form. */)
{
if (MODIFF - 1 == SAVE_MODIFF)
SAVE_MODIFF++;
- if (MODIFF - 1 == current_buffer->auto_save_modified)
- current_buffer->auto_save_modified++;
+ if (MODIFF - 1 == BUF_AUTOSAVE_MODIFF (current_buffer))
+ BUF_AUTOSAVE_MODIFF (current_buffer)++;
}
/* The before-change-function may have moved the gap
diff --git a/src/fileio.c b/src/fileio.c
index b815c38956e..d6cb814641b 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -1,7 +1,7 @@
/* File IO for GNU Emacs.
Copyright (C) 1985, 1986, 1987, 1988, 1993, 1994, 1995, 1996,
1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
- 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
+ 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
This file is part of GNU Emacs.
@@ -4097,7 +4097,7 @@ variable `last-coding-system-used' to the coding system actually used. */)
}
SAVE_MODIFF = MODIFF;
- current_buffer->auto_save_modified = MODIFF;
+ BUF_AUTOSAVE_MODIFF (current_buffer) = MODIFF;
XSETFASTINT (current_buffer->save_length, Z - BEG);
#ifdef CLASH_DETECTION
if (NILP (handler))
@@ -5307,7 +5307,7 @@ A non-nil CURRENT-ONLY argument means save only current buffer. */)
and file changed since last real save. */
if (STRINGP (b->auto_save_file_name)
&& BUF_SAVE_MODIFF (b) < BUF_MODIFF (b)
- && b->auto_save_modified < BUF_MODIFF (b)
+ && BUF_AUTOSAVE_MODIFF (b) < BUF_MODIFF (b)
/* -1 means we've turned off autosaving for a while--see below. */
&& XINT (b->save_length) >= 0
&& (do_handled_files
@@ -5349,7 +5349,7 @@ A non-nil CURRENT-ONLY argument means save only current buffer. */)
message1 ("Auto-saving...");
internal_condition_case (auto_save_1, Qt, auto_save_error);
auto_saved++;
- b->auto_save_modified = BUF_MODIFF (b);
+ BUF_AUTOSAVE_MODIFF (b) = BUF_MODIFF (b);
XSETFASTINT (current_buffer->save_length, Z - BEG);
set_buffer_internal (old);
@@ -5394,7 +5394,9 @@ DEFUN ("set-buffer-auto-saved", Fset_buffer_auto_saved,
No auto-save file will be written until the buffer changes again. */)
()
{
- current_buffer->auto_save_modified = MODIFF;
+ /* FIXME: This should not be called in indirect buffers, since
+ they're not autosaved. */
+ BUF_AUTOSAVE_MODIFF (current_buffer) = MODIFF;
XSETFASTINT (current_buffer->save_length, Z - BEG);
current_buffer->auto_save_failure_time = -1;
return Qnil;
@@ -5417,7 +5419,9 @@ in the visited file. If the buffer has no visited file,
then any auto-save counts as "recent". */)
()
{
- return (SAVE_MODIFF < current_buffer->auto_save_modified) ? Qt : Qnil;
+ /* FIXME: maybe we should return nil for indirect buffers since
+ they're never autosaved. */
+ return (SAVE_MODIFF < BUF_AUTOSAVE_MODIFF (current_buffer) ? Qt : Qnil);
}
/* Reading and completing file names */