Function: set-visited-file-modtime
set-visited-file-modtime is a function defined in fileio.c.
Signature
(set-visited-file-modtime &optional TIME-FLAG)
Documentation
Update buffer's recorded modification time from the visited file's time.
Useful if the buffer was not read from the file normally
or if the file itself has been changed for some known benign reason.
An argument specifies the modification time value to use
(instead of that of the visited file), in the form of a time value as
in current-time or an integer flag as returned by visited-file-modtime.
Probably introduced at or before Emacs version 24.4.
Source Code
// Defined in /usr/src/emacs/src/fileio.c
{
if (!NILP (time_flag))
{
struct timespec mtime;
if (FIXNUMP (time_flag))
{
int flag = check_integer_range (time_flag, -1, 0);
mtime = make_timespec (0, UNKNOWN_MODTIME_NSECS - flag);
}
else
mtime = lisp_time_argument (time_flag);
current_buffer->modtime = mtime;
current_buffer->modtime_size = -1;
}
else if (current_buffer->base_buffer)
error ("An indirect buffer does not have a visited file");
else
{
register Lisp_Object filename, encoded;
struct stat st;
Lisp_Object handler;
filename = Fexpand_file_name (BVAR (current_buffer, filename), Qnil);
/* If the file name has special constructs in it,
call the corresponding file name handler. */
handler = Ffind_file_name_handler (filename, Qset_visited_file_modtime);
if (!NILP (handler))
/* The handler can find the file name the same way we did. */
return calln (handler, Qset_visited_file_modtime, Qnil);
encoded = ENCODE_FILE (filename);
if (emacs_fstatat (AT_FDCWD, SSDATA (encoded), &st, 0)
== 0)
{
current_buffer->modtime = get_stat_mtime (&st);
current_buffer->modtime_size = st.st_size;
}
else
file_attribute_errno (filename, errno);
}
return Qnil;
}