Mercurial > emacs
changeset 2257:668491072928
(Fvisited_file_modtime): New function.
(Fset_visited_file_modtime): Accept an argument specifying time value.
If arg is nil, really use the filename handler.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Fri, 19 Mar 1993 05:30:19 +0000 |
parents | 9de581d9bb83 |
children | 9e79f0a666e6 |
files | src/fileio.c |
diffstat | 1 files changed, 38 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/src/fileio.c Fri Mar 19 05:27:03 1993 +0000 +++ b/src/fileio.c Fri Mar 19 05:30:19 1993 +0000 @@ -2822,27 +2822,45 @@ return Qnil; } -DEFUN ("set-visited-file-modtime", Fset_visited_file_modtime, - Sset_visited_file_modtime, 0, 0, 0, - "Update buffer's recorded modification time from the visited file's time.\n\ -Useful if the buffer was not read from the file normally\n\ -or if the file itself has been changed for some known benign reason.") +DEFUN ("visited-file-modtime", Fvisited_file_modtime, + Svisited_file_modtime, 0, 0, 0, + "Return the current buffer's recorded visited file modification time.\n\ +The value is a list of the form (HIGH . LOW), like the time values\n\ +that `file-attributes' returns.") () { - register Lisp_Object filename; - struct stat st; - Lisp_Object handler; - - filename = Fexpand_file_name (current_buffer->filename, Qnil); - - /* If the file name has special constructs in it, - call the corresponding file handler. */ - handler = Ffind_file_name_handler (filename); - if (!NILP (handler)) - current_buffer->modtime = 0; - - else if (stat (XSTRING (filename)->data, &st) >= 0) - current_buffer->modtime = st.st_mtime; + return long_to_cons (current_buffer->modtime); +} + +DEFUN ("set-visited-file-modtime", Fset_visited_file_modtime, + Sset_visited_file_modtime, 0, 1, 0, + "Update buffer's recorded modification time from the visited file's time.\n\ +Useful if the buffer was not read from the file normally\n\ +or if the file itself has been changed for some known benign reason.\n\ +An argument specifies the modification time value to use\n\ +\(instead of that of the visited file), in the form of a list\n\ +\(HIGH . LOW) or (HIGH LOW).") + (time_list) + Lisp_Object time_list; +{ + if (!NILP (time_list)) + current_buffer->modtime = cons_to_long (time_list); + else + { + register Lisp_Object filename; + struct stat st; + Lisp_Object handler; + + filename = Fexpand_file_name (current_buffer->filename, Qnil); + + /* If the file name has special constructs in it, + call the corresponding file handler. */ + handler = Ffind_file_name_handler (filename); + if (!NILP (handler)) + return call3 (handler, Qfile_name_directory, filename, Qnil); + else if (stat (XSTRING (filename)->data, &st) >= 0) + current_buffer->modtime = st.st_mtime; + } return Qnil; } @@ -3378,6 +3396,7 @@ defsubr (&Swrite_region); defsubr (&Sverify_visited_file_modtime); defsubr (&Sclear_visited_file_modtime); + defsubr (&Svisited_file_modtime); defsubr (&Sset_visited_file_modtime); defsubr (&Sdo_auto_save); defsubr (&Sset_buffer_auto_saved);