199 |
/* File name in which we write a list of all our auto save files. */ |
/* File name in which we write a list of all our auto save files. */ |
200 |
Lisp_Object Vauto_save_list_file_name; |
Lisp_Object Vauto_save_list_file_name; |
201 |
|
|
202 |
|
/* Function to call to read a file name. */ |
203 |
|
Lisp_Object Vread_file_name_function; |
204 |
|
|
205 |
|
/* Current predicate used by read_file_name_internal. */ |
206 |
|
Lisp_Object Vread_file_name_predicate; |
207 |
|
|
208 |
/* Nonzero means, when reading a filename in the minibuffer, |
/* Nonzero means, when reading a filename in the minibuffer, |
209 |
start out by inserting the default directory into the minibuffer. */ |
start out by inserting the default directory into the minibuffer. */ |
210 |
int insert_default_directory; |
int insert_default_directory; |
5832 |
return val; |
return val; |
5833 |
} |
} |
5834 |
|
|
5835 |
|
static Lisp_Object |
5836 |
|
read_file_name_cleanup (arg) |
5837 |
|
Lisp_Object arg; |
5838 |
|
{ |
5839 |
|
current_buffer->directory = arg; |
5840 |
|
} |
5841 |
|
|
5842 |
DEFUN ("read-file-name-internal", Fread_file_name_internal, Sread_file_name_internal, |
DEFUN ("read-file-name-internal", Fread_file_name_internal, Sread_file_name_internal, |
5843 |
3, 3, 0, |
3, 3, 0, |
5844 |
doc: /* Internal subroutine for read-file-name. Do not call this. */) |
doc: /* Internal subroutine for read-file-name. Do not call this. */) |
5903 |
UNGCPRO; |
UNGCPRO; |
5904 |
|
|
5905 |
if (EQ (action, Qt)) |
if (EQ (action, Qt)) |
5906 |
return Ffile_name_all_completions (name, realdir); |
{ |
5907 |
|
Lisp_Object all = Ffile_name_all_completions (name, realdir); |
5908 |
|
Lisp_Object comp; |
5909 |
|
int count; |
5910 |
|
|
5911 |
|
if (NILP (Vread_file_name_predicate) |
5912 |
|
|| EQ (Vread_file_name_predicate, Qfile_exists_p)) |
5913 |
|
return all; |
5914 |
|
GCPRO3 (all, comp, specdir); |
5915 |
|
count = specpdl_ptr - specpdl; |
5916 |
|
record_unwind_protect (read_file_name_cleanup, current_buffer->directory); |
5917 |
|
current_buffer->directory = realdir; |
5918 |
|
for (comp = Qnil; CONSP (all); all = XCDR (all)) |
5919 |
|
if (!NILP (call1 (Vread_file_name_predicate, XCAR (all)))) |
5920 |
|
comp = Fcons (XCAR (all), comp); |
5921 |
|
unbind_to (count, Qnil); |
5922 |
|
UNGCPRO; |
5923 |
|
return Fnreverse (comp); |
5924 |
|
} |
5925 |
|
|
5926 |
/* Only other case actually used is ACTION = lambda */ |
/* Only other case actually used is ACTION = lambda */ |
5927 |
#ifdef VMS |
#ifdef VMS |
5928 |
/* Supposedly this helps commands such as `cd' that read directory names, |
/* Supposedly this helps commands such as `cd' that read directory names, |
5930 |
if (XSTRING (name)->size == 0) |
if (XSTRING (name)->size == 0) |
5931 |
return Qt; |
return Qt; |
5932 |
#endif /* VMS */ |
#endif /* VMS */ |
5933 |
|
if (!NILP (Vread_file_name_predicate)) |
5934 |
|
return call1 (Vread_file_name_predicate, string); |
5935 |
return Ffile_exists_p (string); |
return Ffile_exists_p (string); |
5936 |
} |
} |
5937 |
|
|
5938 |
DEFUN ("read-file-name", Fread_file_name, Sread_file_name, 1, 5, 0, |
DEFUN ("read-file-name", Fread_file_name, Sread_file_name, 1, 6, 0, |
5939 |
doc: /* Read file name, prompting with PROMPT and completing in directory DIR. |
doc: /* Read file name, prompting with PROMPT and completing in directory DIR. |
5940 |
Value is not expanded---you must call `expand-file-name' yourself. |
Value is not expanded---you must call `expand-file-name' yourself. |
5941 |
Default name to DEFAULT-FILENAME if user enters a null string. |
Default name to DEFAULT-FILENAME if user enters a null string. |
5944 |
Fourth arg MUSTMATCH non-nil means require existing file's name. |
Fourth arg MUSTMATCH non-nil means require existing file's name. |
5945 |
Non-nil and non-t means also require confirmation after completion. |
Non-nil and non-t means also require confirmation after completion. |
5946 |
Fifth arg INITIAL specifies text to start with. |
Fifth arg INITIAL specifies text to start with. |
5947 |
|
If optional sixth arg PREDICATE is non-nil, possible completions and the |
5948 |
|
resulting file name must satisfy (funcall PREDICATE NAME). |
5949 |
DIR defaults to current buffer's directory default. |
DIR defaults to current buffer's directory default. |
5950 |
|
|
5951 |
If this command was invoked with the mouse, use a file dialog box if |
If this command was invoked with the mouse, use a file dialog box if |
5952 |
`use-dialog-box' is non-nil, and the window system or X toolkit in use |
`use-dialog-box' is non-nil, and the window system or X toolkit in use |
5953 |
provides a file dialog box. */) |
provides a file dialog box. */) |
5954 |
(prompt, dir, default_filename, mustmatch, initial) |
(prompt, dir, default_filename, mustmatch, initial, predicate) |
5955 |
Lisp_Object prompt, dir, default_filename, mustmatch, initial; |
Lisp_Object prompt, dir, default_filename, mustmatch, initial, predicate; |
5956 |
{ |
{ |
5957 |
Lisp_Object val, insdef, tem; |
Lisp_Object val, insdef, tem; |
5958 |
struct gcpro gcpro1, gcpro2; |
struct gcpro gcpro1, gcpro2; |
6029 |
else |
else |
6030 |
insdef = Qnil; |
insdef = Qnil; |
6031 |
|
|
6032 |
|
if (!NILP (Vread_file_name_function)) |
6033 |
|
{ |
6034 |
|
Lisp_Object args[7]; |
6035 |
|
|
6036 |
|
GCPRO2 (insdef, default_filename); |
6037 |
|
args[0] = Vread_file_name_function; |
6038 |
|
args[1] = prompt; |
6039 |
|
args[2] = dir; |
6040 |
|
args[3] = default_filename; |
6041 |
|
args[4] = mustmatch; |
6042 |
|
args[5] = initial; |
6043 |
|
args[6] = predicate; |
6044 |
|
RETURN_UNGCPRO (Ffuncall (7, args)); |
6045 |
|
} |
6046 |
|
|
6047 |
count = specpdl_ptr - specpdl; |
count = specpdl_ptr - specpdl; |
6048 |
#ifdef VMS |
#ifdef VMS |
6049 |
specbind (intern ("completion-ignore-case"), Qt); |
specbind (intern ("completion-ignore-case"), Qt); |
6050 |
#endif |
#endif |
6051 |
|
|
6052 |
specbind (intern ("minibuffer-completing-file-name"), Qt); |
specbind (intern ("minibuffer-completing-file-name"), Qt); |
6053 |
|
specbind (intern ("read-file-name-predicate"), |
6054 |
|
(NILP (predicate) ? Qfile_exists_p : predicate)); |
6055 |
|
|
6056 |
GCPRO2 (insdef, default_filename); |
GCPRO2 (insdef, default_filename); |
6057 |
|
|
6276 |
Fput (Qfile_date_error, Qerror_message, |
Fput (Qfile_date_error, Qerror_message, |
6277 |
build_string ("Cannot set file date")); |
build_string ("Cannot set file date")); |
6278 |
|
|
6279 |
|
DEFVAR_LISP ("read-file-name-function", &Vread_file_name_function, |
6280 |
|
doc: /* If this is non-nil, `read-file-name' does its work by calling this function. */); |
6281 |
|
Vread_file_name_function = Qnil; |
6282 |
|
|
6283 |
|
DEFVAR_LISP ("read-file-name-predicate", &Vread_file_name_predicate, |
6284 |
|
doc: /* Current predicate used by `read-file-name-internal'. */); |
6285 |
|
Vread_file_name_predicate = Qnil; |
6286 |
|
|
6287 |
DEFVAR_BOOL ("insert-default-directory", &insert_default_directory, |
DEFVAR_BOOL ("insert-default-directory", &insert_default_directory, |
6288 |
doc: /* *Non-nil means when reading a filename start with default dir in minibuffer. */); |
doc: /* *Non-nil means when reading a filename start with default dir in minibuffer. */); |
6289 |
insert_default_directory = 1; |
insert_default_directory = 1; |