comparison src/fileio.c @ 1679:cd48b2c1a7a4

Give subprocess creation a way to find a valid current directory for subprocesses when the buffer's default-directory is a handled name. * fileio.c (Funhandled_file_name_directory): New function. (Qunhandled_file_name_directory): New file-name-handler operation. (syms_of_fileio): Defsubr Sunhandled_file_name_directory, and initialize and staticpro Qunhandled_file_name_directory. * callproc.c (Fcall_process): Call Funhandled_file_name_directory on the buffer's default directory. Do it earlier in the function so there's less to GCPRO. * process.c (create_process): Don't check the validity of the buffer's default directory here... (Fstart_process): Instead, do it here; if we call Funhandled_file_name_directory here, there's less GCPROing to do. * fileio.c (find_file_handler): Rename this to Ffind_file_name_handler, and make it visible to lisp. Add a QUIT to the loop which scans file-name-handler-alist. All uses changed. (syms_of_fileio): Mention this new function in the docstring for Vfile_name_handler_alist. defsubr Sfind_file_name_handler. * lisp.h (Ffind_file_name_handler): Added extern declaration. * dired.c: All uses of find_file_handler changed here too. * fileio.c (syms_of_fileio): Add staticpros for Qexpand_file_name, Qdirectory_file_name, Qfile_name_directory, Qfile_name_nondirectory, Qfile_name_as_directory.
author Jim Blandy <jimb@redhat.com>
date Sat, 12 Dec 1992 15:32:51 +0000
parents 6168f42d716c
children b9ef55b0df4a
comparison
equal deleted inserted replaced
1678:62ecf0c5b54c 1679:cd48b2c1a7a4
131 131
132 Lisp_Object Qexpand_file_name; 132 Lisp_Object Qexpand_file_name;
133 Lisp_Object Qdirectory_file_name; 133 Lisp_Object Qdirectory_file_name;
134 Lisp_Object Qfile_name_directory; 134 Lisp_Object Qfile_name_directory;
135 Lisp_Object Qfile_name_nondirectory; 135 Lisp_Object Qfile_name_nondirectory;
136 Lisp_Object Qunhandled_file_name_directory;
136 Lisp_Object Qfile_name_as_directory; 137 Lisp_Object Qfile_name_as_directory;
137 Lisp_Object Qcopy_file; 138 Lisp_Object Qcopy_file;
138 Lisp_Object Qmake_directory; 139 Lisp_Object Qmake_directory;
139 Lisp_Object Qdelete_directory; 140 Lisp_Object Qdelete_directory;
140 Lisp_Object Qdelete_file; 141 Lisp_Object Qdelete_file;
153 Lisp_Object Qfile_newer_than_file_p; 154 Lisp_Object Qfile_newer_than_file_p;
154 Lisp_Object Qinsert_file_contents; 155 Lisp_Object Qinsert_file_contents;
155 Lisp_Object Qwrite_region; 156 Lisp_Object Qwrite_region;
156 Lisp_Object Qverify_visited_file_modtime; 157 Lisp_Object Qverify_visited_file_modtime;
157 158
158 /* If FILENAME is handled specially on account of its syntax, 159 DEFUN ("find-file-name-handler", Ffind_file_name_handler, Sfind_file_name_handler, 1, 1, 0,
159 return its handler function. Otherwise, return nil. */ 160 "Return FILENAME's handler function, if its syntax is handled specially.\n\
160 161 Otherwise, return nil.\n\
161 Lisp_Object 162 A file name is handled if one of the regular expressions in\n\
162 find_file_handler (filename) 163 `file-name-handler-alist' matches it.")
163 Lisp_Object filename; 164 (filename)
164 { 165 Lisp_Object filename;
166 {
167 /* This function must not munge the match data. */
168
165 Lisp_Object chain; 169 Lisp_Object chain;
166 for (chain = Vfile_name_handler_alist; XTYPE (chain) == Lisp_Cons; 170 for (chain = Vfile_name_handler_alist; XTYPE (chain) == Lisp_Cons;
167 chain = XCONS (chain)->cdr) 171 chain = XCONS (chain)->cdr)
168 { 172 {
169 Lisp_Object elt; 173 Lisp_Object elt;
174 string = XCONS (elt)->car; 178 string = XCONS (elt)->car;
175 if (XTYPE (string) == Lisp_String 179 if (XTYPE (string) == Lisp_String
176 && fast_string_match (string, filename) >= 0) 180 && fast_string_match (string, filename) >= 0)
177 return XCONS (elt)->cdr; 181 return XCONS (elt)->cdr;
178 } 182 }
183
184 QUIT;
179 } 185 }
180 return Qnil; 186 return Qnil;
181 } 187 }
182 188
183 DEFUN ("file-name-directory", Ffile_name_directory, Sfile_name_directory, 189 DEFUN ("file-name-directory", Ffile_name_directory, Sfile_name_directory,
196 202
197 CHECK_STRING (file, 0); 203 CHECK_STRING (file, 0);
198 204
199 /* If the file name has special constructs in it, 205 /* If the file name has special constructs in it,
200 call the corresponding file handler. */ 206 call the corresponding file handler. */
201 handler = find_file_handler (file); 207 handler = Ffind_file_name_handler (file);
202 if (!NILP (handler)) 208 if (!NILP (handler))
203 return call2 (handler, Qfile_name_directory, file); 209 return call2 (handler, Qfile_name_directory, file);
204 210
205 beg = XSTRING (file)->data; 211 beg = XSTRING (file)->data;
206 p = beg + XSTRING (file)->size; 212 p = beg + XSTRING (file)->size;
230 236
231 CHECK_STRING (file, 0); 237 CHECK_STRING (file, 0);
232 238
233 /* If the file name has special constructs in it, 239 /* If the file name has special constructs in it,
234 call the corresponding file handler. */ 240 call the corresponding file handler. */
235 handler = find_file_handler (file); 241 handler = Ffind_file_name_handler (file);
236 if (!NILP (handler)) 242 if (!NILP (handler))
237 return call2 (handler, Qfile_name_nondirectory, file); 243 return call2 (handler, Qfile_name_nondirectory, file);
238 244
239 beg = XSTRING (file)->data; 245 beg = XSTRING (file)->data;
240 end = p = beg + XSTRING (file)->size; 246 end = p = beg + XSTRING (file)->size;
245 #endif /* VMS */ 251 #endif /* VMS */
246 ) p--; 252 ) p--;
247 253
248 return make_string (p, end - p); 254 return make_string (p, end - p);
249 } 255 }
256
257 DEFUN ("unhandled-file-name-directory", Funhandled_file_name_directory, Sunhandled_file_name_directory, 1, 1, 0,
258 "Return a directly usable directory name somehow associated with FILENAME.\n\
259 A `directly usable' directory name is one that may be used without the\n\
260 intervention of any file handler.\n\
261 If FILENAME is a directly usable file itself, return\n\
262 (file-name-directory FILENAME).\n\
263 The `call-process' and `start-process' functions use this function to\n\
264 get a current directory to run processes in.")
265 (filename)
266 Lisp_Object filename;
267 {
268 Lisp_Object handler;
269
270 /* If the file name has special constructs in it,
271 call the corresponding file handler. */
272 handler = Ffind_file_name_handler (filename);
273 if (!NILP (handler))
274 return call2 (handler, Qunhandled_file_name_directory, filename);
275
276 return Ffile_name_directory (filename);
277 }
278
250 279
251 char * 280 char *
252 file_name_as_directory (out, in) 281 file_name_as_directory (out, in)
253 char *out, *in; 282 char *out, *in;
254 { 283 {
340 if (NILP (file)) 369 if (NILP (file))
341 return Qnil; 370 return Qnil;
342 371
343 /* If the file name has special constructs in it, 372 /* If the file name has special constructs in it,
344 call the corresponding file handler. */ 373 call the corresponding file handler. */
345 handler = find_file_handler (file); 374 handler = Ffind_file_name_handler (file);
346 if (!NILP (handler)) 375 if (!NILP (handler))
347 return call2 (handler, Qfile_name_as_directory, file); 376 return call2 (handler, Qfile_name_as_directory, file);
348 377
349 buf = (char *) alloca (XSTRING (file)->size + 10); 378 buf = (char *) alloca (XSTRING (file)->size + 10);
350 return build_string (file_name_as_directory (buf, XSTRING (file)->data)); 379 return build_string (file_name_as_directory (buf, XSTRING (file)->data));
516 if (NILP (directory)) 545 if (NILP (directory))
517 return Qnil; 546 return Qnil;
518 547
519 /* If the file name has special constructs in it, 548 /* If the file name has special constructs in it,
520 call the corresponding file handler. */ 549 call the corresponding file handler. */
521 handler = find_file_handler (directory); 550 handler = Ffind_file_name_handler (directory);
522 if (!NILP (handler)) 551 if (!NILP (handler))
523 return call2 (handler, Qdirectory_file_name, directory); 552 return call2 (handler, Qdirectory_file_name, directory);
524 553
525 #ifdef VMS 554 #ifdef VMS
526 /* 20 extra chars is insufficient for VMS, since we might perform a 555 /* 20 extra chars is insufficient for VMS, since we might perform a
581 610
582 CHECK_STRING (name, 0); 611 CHECK_STRING (name, 0);
583 612
584 /* If the file name has special constructs in it, 613 /* If the file name has special constructs in it,
585 call the corresponding file handler. */ 614 call the corresponding file handler. */
586 handler = find_file_handler (name); 615 handler = Ffind_file_name_handler (name);
587 if (!NILP (handler)) 616 if (!NILP (handler))
588 return call3 (handler, Qexpand_file_name, name, defalt); 617 return call3 (handler, Qexpand_file_name, name, defalt);
589 618
590 #ifdef VMS 619 #ifdef VMS
591 /* Filenames on VMS are always upper case. */ 620 /* Filenames on VMS are always upper case. */
1517 filename = Fexpand_file_name (filename, Qnil); 1546 filename = Fexpand_file_name (filename, Qnil);
1518 newname = Fexpand_file_name (newname, Qnil); 1547 newname = Fexpand_file_name (newname, Qnil);
1519 1548
1520 /* If the input file name has special constructs in it, 1549 /* If the input file name has special constructs in it,
1521 call the corresponding file handler. */ 1550 call the corresponding file handler. */
1522 handler = find_file_handler (filename); 1551 handler = Ffind_file_name_handler (filename);
1523 if (!NILP (handler)) 1552 if (!NILP (handler))
1524 return call3 (handler, Qcopy_file, filename, newname); 1553 return call3 (handler, Qcopy_file, filename, newname);
1525 /* Likewise for output file name. */ 1554 /* Likewise for output file name. */
1526 handler = find_file_handler (newname); 1555 handler = Ffind_file_name_handler (newname);
1527 if (!NILP (handler)) 1556 if (!NILP (handler))
1528 return call3 (handler, Qcopy_file, filename, newname); 1557 return call3 (handler, Qcopy_file, filename, newname);
1529 1558
1530 if (NILP (ok_if_already_exists) 1559 if (NILP (ok_if_already_exists)
1531 || XTYPE (ok_if_already_exists) == Lisp_Int) 1560 || XTYPE (ok_if_already_exists) == Lisp_Int)
1592 Lisp_Object handler; 1621 Lisp_Object handler;
1593 1622
1594 CHECK_STRING (dirname, 0); 1623 CHECK_STRING (dirname, 0);
1595 dirname = Fexpand_file_name (dirname, Qnil); 1624 dirname = Fexpand_file_name (dirname, Qnil);
1596 1625
1597 handler = find_file_handler (dirname); 1626 handler = Ffind_file_name_handler (dirname);
1598 if (!NILP (handler)) 1627 if (!NILP (handler))
1599 return call3 (handler, Qmake_directory, dirname, Qnil); 1628 return call3 (handler, Qmake_directory, dirname, Qnil);
1600 1629
1601 dir = XSTRING (dirname)->data; 1630 dir = XSTRING (dirname)->data;
1602 1631
1616 1645
1617 CHECK_STRING (dirname, 0); 1646 CHECK_STRING (dirname, 0);
1618 dirname = Fexpand_file_name (dirname, Qnil); 1647 dirname = Fexpand_file_name (dirname, Qnil);
1619 dir = XSTRING (dirname)->data; 1648 dir = XSTRING (dirname)->data;
1620 1649
1621 handler = find_file_handler (dirname); 1650 handler = Ffind_file_name_handler (dirname);
1622 if (!NILP (handler)) 1651 if (!NILP (handler))
1623 return call2 (handler, Qdelete_directory, dirname); 1652 return call2 (handler, Qdelete_directory, dirname);
1624 1653
1625 if (rmdir (dir) != 0) 1654 if (rmdir (dir) != 0)
1626 report_file_error ("Removing directory", Flist (1, &dirname)); 1655 report_file_error ("Removing directory", Flist (1, &dirname));
1636 { 1665 {
1637 Lisp_Object handler; 1666 Lisp_Object handler;
1638 CHECK_STRING (filename, 0); 1667 CHECK_STRING (filename, 0);
1639 filename = Fexpand_file_name (filename, Qnil); 1668 filename = Fexpand_file_name (filename, Qnil);
1640 1669
1641 handler = find_file_handler (filename); 1670 handler = Ffind_file_name_handler (filename);
1642 if (!NILP (handler)) 1671 if (!NILP (handler))
1643 return call2 (handler, Qdelete_file, filename); 1672 return call2 (handler, Qdelete_file, filename);
1644 1673
1645 if (0 > unlink (XSTRING (filename)->data)) 1674 if (0 > unlink (XSTRING (filename)->data))
1646 report_file_error ("Removing old name", Flist (1, &filename)); 1675 report_file_error ("Removing old name", Flist (1, &filename));
1670 filename = Fexpand_file_name (filename, Qnil); 1699 filename = Fexpand_file_name (filename, Qnil);
1671 newname = Fexpand_file_name (newname, Qnil); 1700 newname = Fexpand_file_name (newname, Qnil);
1672 1701
1673 /* If the file name has special constructs in it, 1702 /* If the file name has special constructs in it,
1674 call the corresponding file handler. */ 1703 call the corresponding file handler. */
1675 handler = find_file_handler (filename); 1704 handler = Ffind_file_name_handler (filename);
1676 if (!NILP (handler)) 1705 if (!NILP (handler))
1677 return call3 (handler, Qrename_file, filename, newname); 1706 return call3 (handler, Qrename_file, filename, newname);
1678 1707
1679 if (NILP (ok_if_already_exists) 1708 if (NILP (ok_if_already_exists)
1680 || XTYPE (ok_if_already_exists) == Lisp_Int) 1709 || XTYPE (ok_if_already_exists) == Lisp_Int)
1729 filename = Fexpand_file_name (filename, Qnil); 1758 filename = Fexpand_file_name (filename, Qnil);
1730 newname = Fexpand_file_name (newname, Qnil); 1759 newname = Fexpand_file_name (newname, Qnil);
1731 1760
1732 /* If the file name has special constructs in it, 1761 /* If the file name has special constructs in it,
1733 call the corresponding file handler. */ 1762 call the corresponding file handler. */
1734 handler = find_file_handler (filename); 1763 handler = Ffind_file_name_handler (filename);
1735 if (!NILP (handler)) 1764 if (!NILP (handler))
1736 return call3 (handler, Qadd_name_to_file, filename, newname); 1765 return call3 (handler, Qadd_name_to_file, filename, newname);
1737 1766
1738 if (NILP (ok_if_already_exists) 1767 if (NILP (ok_if_already_exists)
1739 || XTYPE (ok_if_already_exists) == Lisp_Int) 1768 || XTYPE (ok_if_already_exists) == Lisp_Int)
1780 #endif 1809 #endif
1781 linkname = Fexpand_file_name (linkname, Qnil); 1810 linkname = Fexpand_file_name (linkname, Qnil);
1782 1811
1783 /* If the file name has special constructs in it, 1812 /* If the file name has special constructs in it,
1784 call the corresponding file handler. */ 1813 call the corresponding file handler. */
1785 handler = find_file_handler (filename); 1814 handler = Ffind_file_name_handler (filename);
1786 if (!NILP (handler)) 1815 if (!NILP (handler))
1787 return call3 (handler, Qmake_symbolic_link, filename, linkname); 1816 return call3 (handler, Qmake_symbolic_link, filename, linkname);
1788 1817
1789 if (NILP (ok_if_already_exists) 1818 if (NILP (ok_if_already_exists)
1790 || XTYPE (ok_if_already_exists) == Lisp_Int) 1819 || XTYPE (ok_if_already_exists) == Lisp_Int)
1897 CHECK_STRING (filename, 0); 1926 CHECK_STRING (filename, 0);
1898 abspath = Fexpand_file_name (filename, Qnil); 1927 abspath = Fexpand_file_name (filename, Qnil);
1899 1928
1900 /* If the file name has special constructs in it, 1929 /* If the file name has special constructs in it,
1901 call the corresponding file handler. */ 1930 call the corresponding file handler. */
1902 handler = find_file_handler (abspath); 1931 handler = Ffind_file_name_handler (abspath);
1903 if (!NILP (handler)) 1932 if (!NILP (handler))
1904 return call2 (handler, Qfile_exists_p, abspath); 1933 return call2 (handler, Qfile_exists_p, abspath);
1905 1934
1906 return (access (XSTRING (abspath)->data, 0) >= 0) ? Qt : Qnil; 1935 return (access (XSTRING (abspath)->data, 0) >= 0) ? Qt : Qnil;
1907 } 1936 }
1919 CHECK_STRING (filename, 0); 1948 CHECK_STRING (filename, 0);
1920 abspath = Fexpand_file_name (filename, Qnil); 1949 abspath = Fexpand_file_name (filename, Qnil);
1921 1950
1922 /* If the file name has special constructs in it, 1951 /* If the file name has special constructs in it,
1923 call the corresponding file handler. */ 1952 call the corresponding file handler. */
1924 handler = find_file_handler (abspath); 1953 handler = Ffind_file_name_handler (abspath);
1925 if (!NILP (handler)) 1954 if (!NILP (handler))
1926 return call2 (handler, Qfile_executable_p, abspath); 1955 return call2 (handler, Qfile_executable_p, abspath);
1927 1956
1928 return (access (XSTRING (abspath)->data, 1) >= 0) ? Qt : Qnil; 1957 return (access (XSTRING (abspath)->data, 1) >= 0) ? Qt : Qnil;
1929 } 1958 }
1940 CHECK_STRING (filename, 0); 1969 CHECK_STRING (filename, 0);
1941 abspath = Fexpand_file_name (filename, Qnil); 1970 abspath = Fexpand_file_name (filename, Qnil);
1942 1971
1943 /* If the file name has special constructs in it, 1972 /* If the file name has special constructs in it,
1944 call the corresponding file handler. */ 1973 call the corresponding file handler. */
1945 handler = find_file_handler (abspath); 1974 handler = Ffind_file_name_handler (abspath);
1946 if (!NILP (handler)) 1975 if (!NILP (handler))
1947 return call2 (handler, Qfile_readable_p, abspath); 1976 return call2 (handler, Qfile_readable_p, abspath);
1948 1977
1949 return (access (XSTRING (abspath)->data, 4) >= 0) ? Qt : Qnil; 1978 return (access (XSTRING (abspath)->data, 4) >= 0) ? Qt : Qnil;
1950 } 1979 }
1966 CHECK_STRING (filename, 0); 1995 CHECK_STRING (filename, 0);
1967 filename = Fexpand_file_name (filename, Qnil); 1996 filename = Fexpand_file_name (filename, Qnil);
1968 1997
1969 /* If the file name has special constructs in it, 1998 /* If the file name has special constructs in it,
1970 call the corresponding file handler. */ 1999 call the corresponding file handler. */
1971 handler = find_file_handler (filename); 2000 handler = Ffind_file_name_handler (filename);
1972 if (!NILP (handler)) 2001 if (!NILP (handler))
1973 return call2 (handler, Qfile_symlink_p, filename); 2002 return call2 (handler, Qfile_symlink_p, filename);
1974 2003
1975 bufsize = 100; 2004 bufsize = 100;
1976 while (1) 2005 while (1)
2009 CHECK_STRING (filename, 0); 2038 CHECK_STRING (filename, 0);
2010 abspath = Fexpand_file_name (filename, Qnil); 2039 abspath = Fexpand_file_name (filename, Qnil);
2011 2040
2012 /* If the file name has special constructs in it, 2041 /* If the file name has special constructs in it,
2013 call the corresponding file handler. */ 2042 call the corresponding file handler. */
2014 handler = find_file_handler (abspath); 2043 handler = Ffind_file_name_handler (abspath);
2015 if (!NILP (handler)) 2044 if (!NILP (handler))
2016 return call2 (handler, Qfile_writable_p, abspath); 2045 return call2 (handler, Qfile_writable_p, abspath);
2017 2046
2018 if (access (XSTRING (abspath)->data, 0) >= 0) 2047 if (access (XSTRING (abspath)->data, 0) >= 0)
2019 return (access (XSTRING (abspath)->data, 2) >= 0) ? Qt : Qnil; 2048 return (access (XSTRING (abspath)->data, 2) >= 0) ? Qt : Qnil;
2039 2068
2040 abspath = expand_and_dir_to_file (filename, current_buffer->directory); 2069 abspath = expand_and_dir_to_file (filename, current_buffer->directory);
2041 2070
2042 /* If the file name has special constructs in it, 2071 /* If the file name has special constructs in it,
2043 call the corresponding file handler. */ 2072 call the corresponding file handler. */
2044 handler = find_file_handler (abspath); 2073 handler = Ffind_file_name_handler (abspath);
2045 if (!NILP (handler)) 2074 if (!NILP (handler))
2046 return call2 (handler, Qfile_directory_p, abspath); 2075 return call2 (handler, Qfile_directory_p, abspath);
2047 2076
2048 if (stat (XSTRING (abspath)->data, &st) < 0) 2077 if (stat (XSTRING (abspath)->data, &st) < 0)
2049 return Qnil; 2078 return Qnil;
2062 { 2091 {
2063 Lisp_Object handler; 2092 Lisp_Object handler;
2064 2093
2065 /* If the file name has special constructs in it, 2094 /* If the file name has special constructs in it,
2066 call the corresponding file handler. */ 2095 call the corresponding file handler. */
2067 handler = find_file_handler (filename); 2096 handler = Ffind_file_name_handler (filename);
2068 if (!NILP (handler)) 2097 if (!NILP (handler))
2069 return call2 (handler, Qfile_accessible_directory_p, filename); 2098 return call2 (handler, Qfile_accessible_directory_p, filename);
2070 2099
2071 if (NILP (Ffile_directory_p (filename)) 2100 if (NILP (Ffile_directory_p (filename))
2072 || NILP (Ffile_executable_p (filename))) 2101 || NILP (Ffile_executable_p (filename)))
2086 2115
2087 abspath = expand_and_dir_to_file (filename, current_buffer->directory); 2116 abspath = expand_and_dir_to_file (filename, current_buffer->directory);
2088 2117
2089 /* If the file name has special constructs in it, 2118 /* If the file name has special constructs in it,
2090 call the corresponding file handler. */ 2119 call the corresponding file handler. */
2091 handler = find_file_handler (abspath); 2120 handler = Ffind_file_name_handler (abspath);
2092 if (!NILP (handler)) 2121 if (!NILP (handler))
2093 return call2 (handler, Qfile_modes, abspath); 2122 return call2 (handler, Qfile_modes, abspath);
2094 2123
2095 if (stat (XSTRING (abspath)->data, &st) < 0) 2124 if (stat (XSTRING (abspath)->data, &st) < 0)
2096 return Qnil; 2125 return Qnil;
2109 abspath = Fexpand_file_name (filename, current_buffer->directory); 2138 abspath = Fexpand_file_name (filename, current_buffer->directory);
2110 CHECK_NUMBER (mode, 1); 2139 CHECK_NUMBER (mode, 1);
2111 2140
2112 /* If the file name has special constructs in it, 2141 /* If the file name has special constructs in it,
2113 call the corresponding file handler. */ 2142 call the corresponding file handler. */
2114 handler = find_file_handler (abspath); 2143 handler = Ffind_file_name_handler (abspath);
2115 if (!NILP (handler)) 2144 if (!NILP (handler))
2116 return call3 (handler, Qset_file_modes, abspath, mode); 2145 return call3 (handler, Qset_file_modes, abspath, mode);
2117 2146
2118 #ifndef APOLLO 2147 #ifndef APOLLO
2119 if (chmod (XSTRING (abspath)->data, XINT (mode)) < 0) 2148 if (chmod (XSTRING (abspath)->data, XINT (mode)) < 0)
2214 abspath2 = expand_and_dir_to_file (file2, current_buffer->directory); 2243 abspath2 = expand_and_dir_to_file (file2, current_buffer->directory);
2215 UNGCPRO; 2244 UNGCPRO;
2216 2245
2217 /* If the file name has special constructs in it, 2246 /* If the file name has special constructs in it,
2218 call the corresponding file handler. */ 2247 call the corresponding file handler. */
2219 handler = find_file_handler (abspath1); 2248 handler = Ffind_file_name_handler (abspath1);
2220 if (!NILP (handler)) 2249 if (!NILP (handler))
2221 return call3 (handler, Qfile_newer_than_file_p, abspath1, abspath2); 2250 return call3 (handler, Qfile_newer_than_file_p, abspath1, abspath2);
2222 2251
2223 if (stat (XSTRING (abspath1)->data, &st) < 0) 2252 if (stat (XSTRING (abspath1)->data, &st) < 0)
2224 return Qnil; 2253 return Qnil;
2259 CHECK_STRING (filename, 0); 2288 CHECK_STRING (filename, 0);
2260 filename = Fexpand_file_name (filename, Qnil); 2289 filename = Fexpand_file_name (filename, Qnil);
2261 2290
2262 /* If the file name has special constructs in it, 2291 /* If the file name has special constructs in it,
2263 call the corresponding file handler. */ 2292 call the corresponding file handler. */
2264 handler = find_file_handler (filename); 2293 handler = Ffind_file_name_handler (filename);
2265 if (!NILP (handler)) 2294 if (!NILP (handler))
2266 { 2295 {
2267 val = call3 (handler, Qinsert_file_contents, filename, visit); 2296 val = call3 (handler, Qinsert_file_contents, filename, visit);
2268 st.st_mtime = 0; 2297 st.st_mtime = 0;
2269 goto handled; 2298 goto handled;
2443 GCPRO4 (start, filename, visit, visit_file); 2472 GCPRO4 (start, filename, visit, visit_file);
2444 filename = Fexpand_file_name (filename, Qnil); 2473 filename = Fexpand_file_name (filename, Qnil);
2445 2474
2446 /* If the file name has special constructs in it, 2475 /* If the file name has special constructs in it,
2447 call the corresponding file handler. */ 2476 call the corresponding file handler. */
2448 handler = find_file_handler (filename); 2477 handler = Ffind_file_name_handler (filename);
2449 2478
2450 if (!NILP (handler)) 2479 if (!NILP (handler))
2451 { 2480 {
2452 Lisp_Object args[7]; 2481 Lisp_Object args[7];
2453 Lisp_Object val; 2482 Lisp_Object val;
2738 if (XTYPE (b->filename) != Lisp_String) return Qt; 2767 if (XTYPE (b->filename) != Lisp_String) return Qt;
2739 if (b->modtime == 0) return Qt; 2768 if (b->modtime == 0) return Qt;
2740 2769
2741 /* If the file name has special constructs in it, 2770 /* If the file name has special constructs in it,
2742 call the corresponding file handler. */ 2771 call the corresponding file handler. */
2743 handler = find_file_handler (b->filename); 2772 handler = Ffind_file_name_handler (b->filename);
2744 if (!NILP (handler)) 2773 if (!NILP (handler))
2745 return call2 (handler, Qverify_visited_file_modtime, buf); 2774 return call2 (handler, Qverify_visited_file_modtime, buf);
2746 2775
2747 if (stat (XSTRING (b->filename)->data, &st) < 0) 2776 if (stat (XSTRING (b->filename)->data, &st) < 0)
2748 { 2777 {
2785 2814
2786 filename = Fexpand_file_name (current_buffer->filename, Qnil); 2815 filename = Fexpand_file_name (current_buffer->filename, Qnil);
2787 2816
2788 /* If the file name has special constructs in it, 2817 /* If the file name has special constructs in it,
2789 call the corresponding file handler. */ 2818 call the corresponding file handler. */
2790 handler = find_file_handler (filename); 2819 handler = Ffind_file_name_handler (filename);
2791 if (!NILP (handler)) 2820 if (!NILP (handler))
2792 current_buffer->modtime = 0; 2821 current_buffer->modtime = 0;
2793 2822
2794 else if (stat (XSTRING (filename)->data, &st) >= 0) 2823 else if (stat (XSTRING (filename)->data, &st) >= 0)
2795 current_buffer->modtime = st.st_mtime; 2824 current_buffer->modtime = st.st_mtime;
3176 { 3205 {
3177 Qexpand_file_name = intern ("expand-file-name"); 3206 Qexpand_file_name = intern ("expand-file-name");
3178 Qdirectory_file_name = intern ("directory-file-name"); 3207 Qdirectory_file_name = intern ("directory-file-name");
3179 Qfile_name_directory = intern ("file-name-directory"); 3208 Qfile_name_directory = intern ("file-name-directory");
3180 Qfile_name_nondirectory = intern ("file-name-nondirectory"); 3209 Qfile_name_nondirectory = intern ("file-name-nondirectory");
3210 Qunhandled_file_name_directory = intern ("unhandled-file-name-directory");
3181 Qfile_name_as_directory = intern ("file-name-as-directory"); 3211 Qfile_name_as_directory = intern ("file-name-as-directory");
3182 Qcopy_file = intern ("copy-file"); 3212 Qcopy_file = intern ("copy-file");
3183 Qmake_directory = intern ("make-directory"); 3213 Qmake_directory = intern ("make-directory");
3184 Qdelete_directory = intern ("delete-directory"); 3214 Qdelete_directory = intern ("delete-directory");
3185 Qdelete_file = intern ("delete-file"); 3215 Qdelete_file = intern ("delete-file");
3198 Qfile_newer_than_file_p = intern ("file-newer-than-file-p"); 3228 Qfile_newer_than_file_p = intern ("file-newer-than-file-p");
3199 Qinsert_file_contents = intern ("insert-file-contents"); 3229 Qinsert_file_contents = intern ("insert-file-contents");
3200 Qwrite_region = intern ("write-region"); 3230 Qwrite_region = intern ("write-region");
3201 Qverify_visited_file_modtime = intern ("verify-visited-file-modtime"); 3231 Qverify_visited_file_modtime = intern ("verify-visited-file-modtime");
3202 3232
3203 Qfile_name_history = intern ("file-name-history"); 3233 staticpro (&Qexpand_file_name);
3204 Fset (Qfile_name_history, Qnil); 3234 staticpro (&Qdirectory_file_name);
3205 3235 staticpro (&Qfile_name_directory);
3236 staticpro (&Qfile_name_nondirectory);
3237 staticpro (&Qunhandled_file_name_directory);
3238 staticpro (&Qfile_name_as_directory);
3206 staticpro (&Qcopy_file); 3239 staticpro (&Qcopy_file);
3207 staticpro (&Qmake_directory); 3240 staticpro (&Qmake_directory);
3208 staticpro (&Qdelete_directory); 3241 staticpro (&Qdelete_directory);
3209 staticpro (&Qdelete_file); 3242 staticpro (&Qdelete_file);
3210 staticpro (&Qrename_file); 3243 staticpro (&Qrename_file);
3221 staticpro (&Qset_file_modes); 3254 staticpro (&Qset_file_modes);
3222 staticpro (&Qfile_newer_than_file_p); 3255 staticpro (&Qfile_newer_than_file_p);
3223 staticpro (&Qinsert_file_contents); 3256 staticpro (&Qinsert_file_contents);
3224 staticpro (&Qwrite_region); 3257 staticpro (&Qwrite_region);
3225 staticpro (&Qverify_visited_file_modtime); 3258 staticpro (&Qverify_visited_file_modtime);
3259
3260 Qfile_name_history = intern ("file-name-history");
3261 Fset (Qfile_name_history, Qnil);
3226 staticpro (&Qfile_name_history); 3262 staticpro (&Qfile_name_history);
3227 3263
3228 Qfile_error = intern ("file-error"); 3264 Qfile_error = intern ("file-error");
3229 staticpro (&Qfile_error); 3265 staticpro (&Qfile_error);
3230 Qfile_already_exists = intern("file-already-exists"); 3266 Qfile_already_exists = intern("file-already-exists");
3258 The first argument given to HANDLER is the name of the I/O primitive\n\ 3294 The first argument given to HANDLER is the name of the I/O primitive\n\
3259 to be handled; the remaining arguments are the arguments that were\n\ 3295 to be handled; the remaining arguments are the arguments that were\n\
3260 passed to that primitive. For example, if you do\n\ 3296 passed to that primitive. For example, if you do\n\
3261 (file-exists-p FILENAME)\n\ 3297 (file-exists-p FILENAME)\n\
3262 and FILENAME is handled by HANDLER, then HANDLER is called like this:\n\ 3298 and FILENAME is handled by HANDLER, then HANDLER is called like this:\n\
3263 (funcall HANDLER 'file-exists-p FILENAME)"); 3299 (funcall HANDLER 'file-exists-p FILENAME)\n\
3300 The function `find-file-name-handler' checks this list for a handler\n\
3301 for its argument.");
3264 Vfile_name_handler_alist = Qnil; 3302 Vfile_name_handler_alist = Qnil;
3265 3303
3304 defsubr (&Sfind_file_name_handler);
3266 defsubr (&Sfile_name_directory); 3305 defsubr (&Sfile_name_directory);
3267 defsubr (&Sfile_name_nondirectory); 3306 defsubr (&Sfile_name_nondirectory);
3307 defsubr (&Sunhandled_file_name_directory);
3268 defsubr (&Sfile_name_as_directory); 3308 defsubr (&Sfile_name_as_directory);
3269 defsubr (&Sdirectory_file_name); 3309 defsubr (&Sdirectory_file_name);
3270 defsubr (&Smake_temp_name); 3310 defsubr (&Smake_temp_name);
3271 defsubr (&Sexpand_file_name); 3311 defsubr (&Sexpand_file_name);
3272 defsubr (&Ssubstitute_in_file_name); 3312 defsubr (&Ssubstitute_in_file_name);