comparison src/fileio.c @ 7041:7b8c405c910a

(syms_of_fileio): New Lisp var inhibit-file-name-operation. (Ffind_file_name_handler): Obey that variable. Use new meaning for inhibit-file-name-handlers.
author Richard M. Stallman <rms@gnu.org>
date Sat, 23 Apr 1994 04:55:38 +0000
parents f67c02c50e2a
children b3e9a76134d2
comparison
equal deleted inserted replaced
7040:cd4dd38925f9 7041:7b8c405c910a
127 127
128 /* On VMS, nonzero means write new files with record format stmlf. 128 /* On VMS, nonzero means write new files with record format stmlf.
129 Zero means use var format. */ 129 Zero means use var format. */
130 int vms_stmlf_recfm; 130 int vms_stmlf_recfm;
131 131
132 /* These variables describe handlers that have "already" had a chance
133 to handle the current operation.
134
135 Vinhibit_file_name_handlers is a list of file name handlers.
136 Vinhibit_file_name_operation is the operation being handled.
137 If we try to handle that operation, we ignore those handlers. */
138
132 static Lisp_Object Vinhibit_file_name_handlers; 139 static Lisp_Object Vinhibit_file_name_handlers;
140 static Lisp_Object Vinhibit_file_name_operation;
133 141
134 Lisp_Object Qfile_error, Qfile_already_exists; 142 Lisp_Object Qfile_error, Qfile_already_exists;
135 143
136 Lisp_Object Qfile_name_history; 144 Lisp_Object Qfile_name_history;
137 145
201 DEFUN ("find-file-name-handler", Ffind_file_name_handler, Sfind_file_name_handler, 2, 2, 0, 209 DEFUN ("find-file-name-handler", Ffind_file_name_handler, Sfind_file_name_handler, 2, 2, 0,
202 "Return FILENAME's handler function for OPERATION, if it has one.\n\ 210 "Return FILENAME's handler function for OPERATION, if it has one.\n\
203 Otherwise, return nil.\n\ 211 Otherwise, return nil.\n\
204 A file name is handled if one of the regular expressions in\n\ 212 A file name is handled if one of the regular expressions in\n\
205 `file-name-handler-alist' matches it.\n\n\ 213 `file-name-handler-alist' matches it.\n\n\
206 If FILENAME is a member of `inhibit-file-name-handlers',\n\ 214 If OPERATION equals `inhibit-file-name-operation', then we ignore\n\
207 then its handler is not run. This lets handlers\n\ 215 any handlers that are members of `inhibit-file-name-handlers',\n\
216 but we still do run any other handlers. This lets handlers\n\
208 use the standard functions without calling themselves recursively.") 217 use the standard functions without calling themselves recursively.")
209 (filename, operation) 218 (filename, operation)
210 Lisp_Object filename, operation; 219 Lisp_Object filename, operation;
211 { 220 {
212 /* This function must not munge the match data. */ 221 /* This function must not munge the match data. */
213 Lisp_Object chain; 222 Lisp_Object chain, inhibited_handlers;
214 223
215 CHECK_STRING (filename, 0); 224 CHECK_STRING (filename, 0);
216 225
217 if (! NILP (Vinhibit_file_name_handlers)) 226 if (EQ (operation, Vinhibit_file_name_operation))
218 { 227 inhibited_handlers = Vinhibit_file_name_handlers;
219 Lisp_Object tail; 228 else
220 for (tail = Vinhibit_file_name_handlers; CONSP (tail); 229 inhibited_handlers = Qnil;
221 tail = XCONS (tail)->cdr)
222 {
223 Lisp_Object tem;
224 tem = Fstring_equal (tail, filename);
225 if (!NILP (tem))
226 return Qnil;
227 }
228 }
229 230
230 for (chain = Vfile_name_handler_alist; XTYPE (chain) == Lisp_Cons; 231 for (chain = Vfile_name_handler_alist; XTYPE (chain) == Lisp_Cons;
231 chain = XCONS (chain)->cdr) 232 chain = XCONS (chain)->cdr)
232 { 233 {
233 Lisp_Object elt; 234 Lisp_Object elt;
236 { 237 {
237 Lisp_Object string; 238 Lisp_Object string;
238 string = XCONS (elt)->car; 239 string = XCONS (elt)->car;
239 if (XTYPE (string) == Lisp_String 240 if (XTYPE (string) == Lisp_String
240 && fast_string_match (string, filename) >= 0) 241 && fast_string_match (string, filename) >= 0)
241 return XCONS (elt)->cdr; 242 {
243 Lisp_Object handler, tem;
244
245 handler = XCONS (elt)->cdr;
246 tem = Fmemq (handler, inhibited_handlers);
247 if (NILP (tem))
248 return handler;
249 }
242 } 250 }
243 251
244 QUIT; 252 QUIT;
245 } 253 }
246 return Qnil; 254 return Qnil;
3990 increasing order. If there are several functions in the list, the several\n\ 3998 increasing order. If there are several functions in the list, the several\n\
3991 lists are merged destructively."); 3999 lists are merged destructively.");
3992 Vwrite_region_annotate_functions = Qnil; 4000 Vwrite_region_annotate_functions = Qnil;
3993 4001
3994 DEFVAR_LISP ("inhibit-file-name-handlers", &Vinhibit_file_name_handlers, 4002 DEFVAR_LISP ("inhibit-file-name-handlers", &Vinhibit_file_name_handlers,
3995 "A list of file names for which handlers should not be used."); 4003 "A list of file names for which handlers should not be used.\n\
4004 This applies only to the operation `inhibit-file-name-handlers'.");
3996 Vinhibit_file_name_handlers = Qnil; 4005 Vinhibit_file_name_handlers = Qnil;
4006
4007 DEFVAR_LISP ("inhibit-file-name-operation", &Vinhibit_file_name_operation,
4008 "The operation for which `inhibit-file-name-handlers' is applicable.");
4009 Vinhibit_file_name_operation = Qnil;
3997 4010
3998 defsubr (&Sfind_file_name_handler); 4011 defsubr (&Sfind_file_name_handler);
3999 defsubr (&Sfile_name_directory); 4012 defsubr (&Sfile_name_directory);
4000 defsubr (&Sfile_name_nondirectory); 4013 defsubr (&Sfile_name_nondirectory);
4001 defsubr (&Sunhandled_file_name_directory); 4014 defsubr (&Sunhandled_file_name_directory);