Mercurial > emacs
diff src/fileio.c @ 107845:688679bd79f5
Try to detect file modification within the same second.
* buffer.h (struct buffer): New field modtime_size.
* buffer.c (reset_buffer): Initialize it.
* fileio.c (Finsert_file_contents, Fwrite_region): Set it.
(Fverify_visited_file_modtime): Check it.
(Fclear_visited_file_modtime, Fset_visited_file_modtime): Clear it.
(Fset_visited_file_modtime): Set (or clear) it.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Mon, 12 Apr 2010 21:47:40 -0400 |
parents | 912a8c0c9a8a |
children | 12062a99ca8d |
line wrap: on
line diff
--- a/src/fileio.c Mon Apr 12 21:24:10 2010 -0400 +++ b/src/fileio.c Mon Apr 12 21:47:40 2010 -0400 @@ -4092,6 +4092,7 @@ if (NILP (handler)) { current_buffer->modtime = st.st_mtime; + current_buffer->modtime_size = st.st_size; current_buffer->filename = orig_filename; } @@ -4695,7 +4696,10 @@ to avoid a "file has changed on disk" warning on next attempt to save. */ if (visiting) - current_buffer->modtime = st.st_mtime; + { + current_buffer->modtime = st.st_mtime; + current_buffer->modtime_size = st.st_size; + } if (failure) error ("IO error writing %s: %s", SDATA (filename), @@ -5004,11 +5008,13 @@ else st.st_mtime = 0; } - if (st.st_mtime == b->modtime - /* If both are positive, accept them if they are off by one second. */ - || (st.st_mtime > 0 && b->modtime > 0 - && (st.st_mtime == b->modtime + 1 - || st.st_mtime == b->modtime - 1))) + if ((st.st_mtime == b->modtime + /* If both are positive, accept them if they are off by one second. */ + || (st.st_mtime > 0 && b->modtime > 0 + && (st.st_mtime == b->modtime + 1 + || st.st_mtime == b->modtime - 1))) + && (st.st_size == b->modtime_size + || b->modtime_size < 0)) return Qt; return Qnil; } @@ -5020,6 +5026,7 @@ () { current_buffer->modtime = 0; + current_buffer->modtime_size = -1; return Qnil; } @@ -5049,7 +5056,10 @@ Lisp_Object time_list; { if (!NILP (time_list)) - current_buffer->modtime = cons_to_long (time_list); + { + current_buffer->modtime = cons_to_long (time_list); + current_buffer->modtime_size = -1; + } else { register Lisp_Object filename; @@ -5068,7 +5078,10 @@ filename = ENCODE_FILE (filename); if (stat (SDATA (filename), &st) >= 0) - current_buffer->modtime = st.st_mtime; + { + current_buffer->modtime = st.st_mtime; + current_buffer->modtime_size = st.st_size; + } } return Qnil;