comparison src/fileio.c @ 223:2c611d1463a6 r20-4b10

Import from CVS: tag r20-4b10
author cvs
date Mon, 13 Aug 2007 10:10:54 +0200
parents 1f0dabaa0855
children 12579d965149
comparison
equal deleted inserted replaced
222:aae4c8b01452 223:2c611d1463a6
353 Lisp_Object Qfile_newer_than_file_p; 353 Lisp_Object Qfile_newer_than_file_p;
354 Lisp_Object Qinsert_file_contents; 354 Lisp_Object Qinsert_file_contents;
355 Lisp_Object Qwrite_region; 355 Lisp_Object Qwrite_region;
356 Lisp_Object Qverify_visited_file_modtime; 356 Lisp_Object Qverify_visited_file_modtime;
357 Lisp_Object Qset_visited_file_modtime; 357 Lisp_Object Qset_visited_file_modtime;
358 Lisp_Object Qset_buffer_modtime;
359 358
360 /* If FILENAME is handled specially on account of its syntax, 359 /* If FILENAME is handled specially on account of its syntax,
361 return its handler function. Otherwise, return nil. */ 360 return its handler function. Otherwise, return nil. */
362 361
363 DEFUN ("find-file-name-handler", Ffind_file_name_handler, 1, 2, 0, /* 362 DEFUN ("find-file-name-handler", Ffind_file_name_handler, 1, 2, 0, /*
4124 current_buffer->modtime = st.st_mtime; 4123 current_buffer->modtime = st.st_mtime;
4125 } 4124 }
4126 4125
4127 return Qnil; 4126 return Qnil;
4128 } 4127 }
4129
4130 DEFUN ("set-buffer-modtime", Fset_buffer_modtime, 1, 2, 0, /*
4131 Update BUFFER's recorded modification time from the associated
4132 file's modtime, if there is an associated file. If not, use the
4133 current time. In either case, if the optional arg TIME is supplied,
4134 it will be used if it is either an integer or a cons of two integers.
4135 */
4136 (buf, in_time))
4137 {
4138 /* This function can call lisp */
4139 unsigned long time_to_use = 0;
4140 int set_time_to_use = 0;
4141 struct stat st;
4142
4143 CHECK_BUFFER (buf);
4144
4145 if (!NILP (in_time))
4146 {
4147 if (INTP (in_time))
4148 {
4149 time_to_use = XINT (in_time);
4150 set_time_to_use = 1;
4151 }
4152 else if ((CONSP (in_time)) &&
4153 (INTP (Fcar (in_time))) &&
4154 (INTP (Fcdr (in_time))))
4155 {
4156 time_t the_time;
4157 lisp_to_time (in_time, &the_time);
4158 time_to_use = (unsigned long) the_time;
4159 set_time_to_use = 1;
4160 }
4161 }
4162
4163 if (!set_time_to_use)
4164 {
4165 Lisp_Object filename = Qnil;
4166 struct gcpro gcpro1;
4167 GCPRO1 (filename);
4168 /* #### dmoore - do we need to protect XBUFFER (buf)->filename?
4169 What if a ^(*&^&*^*& handler renames a buffer? I think I'm
4170 getting a headache now. */
4171
4172 if (STRINGP (XBUFFER (buf)->filename))
4173 filename = Fexpand_file_name (XBUFFER (buf)->filename, Qnil);
4174 else
4175 filename = Qnil;
4176
4177 if (!NILP (filename) && !NILP (Ffile_exists_p (filename)))
4178 {
4179 Lisp_Object handler;
4180
4181 /* If the file name has special constructs in it,
4182 call the corresponding file handler. */
4183 handler = Ffind_file_name_handler (filename, Qset_buffer_modtime);
4184 UNGCPRO;
4185 if (!NILP (handler))
4186 /* The handler can find the file name the same way we did. */
4187 return (call2 (handler, Qset_buffer_modtime, Qnil));
4188 else
4189 {
4190 if (stat ((char *) XSTRING_DATA (filename), &st) >= 0)
4191 time_to_use = st.st_mtime;
4192 else
4193 time_to_use = time ((time_t *) 0);
4194 }
4195 }
4196 else
4197 {
4198 UNGCPRO;
4199 time_to_use = time ((time_t *) 0);
4200 }
4201 }
4202
4203 XBUFFER (buf)->modtime = time_to_use;
4204
4205 return Qnil;
4206 }
4207
4208 4128
4209 static Lisp_Object 4129 static Lisp_Object
4210 auto_save_error (Lisp_Object condition_object, Lisp_Object ignored) 4130 auto_save_error (Lisp_Object condition_object, Lisp_Object ignored)
4211 { 4131 {
4212 /* This function can call lisp */ 4132 /* This function can call lisp */
4616 defsymbol (&Qfile_newer_than_file_p, "file-newer-than-file-p"); 4536 defsymbol (&Qfile_newer_than_file_p, "file-newer-than-file-p");
4617 defsymbol (&Qinsert_file_contents, "insert-file-contents"); 4537 defsymbol (&Qinsert_file_contents, "insert-file-contents");
4618 defsymbol (&Qwrite_region, "write-region"); 4538 defsymbol (&Qwrite_region, "write-region");
4619 defsymbol (&Qverify_visited_file_modtime, "verify-visited-file-modtime"); 4539 defsymbol (&Qverify_visited_file_modtime, "verify-visited-file-modtime");
4620 defsymbol (&Qset_visited_file_modtime, "set-visited-file-modtime"); 4540 defsymbol (&Qset_visited_file_modtime, "set-visited-file-modtime");
4621 defsymbol (&Qset_buffer_modtime, "set-buffer-modtime");
4622 #ifdef DOS_NT 4541 #ifdef DOS_NT
4623 defsymbol (&Qfind_buffer_file_type, "find-buffer-file-type"); 4542 defsymbol (&Qfind_buffer_file_type, "find-buffer-file-type");
4624 #endif /* DOS_NT */ 4543 #endif /* DOS_NT */
4625 defsymbol (&Qcar_less_than_car, "car-less-than-car"); /* Vomitous! */ 4544 defsymbol (&Qcar_less_than_car, "car-less-than-car"); /* Vomitous! */
4626 4545
4685 #endif 4604 #endif
4686 DEFSUBR (Fverify_visited_file_modtime); 4605 DEFSUBR (Fverify_visited_file_modtime);
4687 DEFSUBR (Fclear_visited_file_modtime); 4606 DEFSUBR (Fclear_visited_file_modtime);
4688 DEFSUBR (Fvisited_file_modtime); 4607 DEFSUBR (Fvisited_file_modtime);
4689 DEFSUBR (Fset_visited_file_modtime); 4608 DEFSUBR (Fset_visited_file_modtime);
4690 DEFSUBR (Fset_buffer_modtime);
4691 4609
4692 DEFSUBR (Fdo_auto_save); 4610 DEFSUBR (Fdo_auto_save);
4693 DEFSUBR (Fset_buffer_auto_saved); 4611 DEFSUBR (Fset_buffer_auto_saved);
4694 DEFSUBR (Fclear_buffer_auto_save_failure); 4612 DEFSUBR (Fclear_buffer_auto_save_failure);
4695 DEFSUBR (Frecent_auto_save_p); 4613 DEFSUBR (Frecent_auto_save_p);