comparison src/fileio.c @ 53764:0505a2aecd0a

(Fread_file_name_internal): Correctly handle the case where insert-default-directory is nil. (Fread_file_name): Always return an empty string if the user exits with an empty minibuffer. Adapt the docstring accordingly. (syms_of_fileio): Adapt the docstring of insert-default-directory to the change in Fread_file_name.
author Luc Teirlinck <teirllm@auburn.edu>
date Sat, 31 Jan 2004 04:24:23 +0000
parents d6ab4f5d0c6f
children 6c059bf40adc
comparison
equal deleted inserted replaced
53763:ea798c20065b 53764:0505a2aecd0a
6093 /* Supposedly this helps commands such as `cd' that read directory names, 6093 /* Supposedly this helps commands such as `cd' that read directory names,
6094 but can someone explain how it helps them? -- RMS */ 6094 but can someone explain how it helps them? -- RMS */
6095 if (SCHARS (name) == 0) 6095 if (SCHARS (name) == 0)
6096 return Qt; 6096 return Qt;
6097 #endif /* VMS */ 6097 #endif /* VMS */
6098 string = Fexpand_file_name (string, dir);
6098 if (!NILP (Vread_file_name_predicate)) 6099 if (!NILP (Vread_file_name_predicate))
6099 return call1 (Vread_file_name_predicate, string); 6100 return call1 (Vread_file_name_predicate, string);
6100 return Ffile_exists_p (string); 6101 return Ffile_exists_p (string);
6101 } 6102 }
6102 6103
6103 DEFUN ("read-file-name", Fread_file_name, Sread_file_name, 1, 6, 0, 6104 DEFUN ("read-file-name", Fread_file_name, Sread_file_name, 1, 6, 0,
6104 doc: /* Read file name, prompting with PROMPT and completing in directory DIR. 6105 doc: /* Read file name, prompting with PROMPT and completing in directory DIR.
6105 Value is not expanded---you must call `expand-file-name' yourself. 6106 Value is not expanded---you must call `expand-file-name' yourself.
6106 Default name to DEFAULT-FILENAME if user enters a null string. 6107 Default name to DEFAULT-FILENAME if user exits the minibuffer with
6108 the same non-empty string that was inserted by this function.
6107 (If DEFAULT-FILENAME is omitted, the visited file name is used, 6109 (If DEFAULT-FILENAME is omitted, the visited file name is used,
6108 except that if INITIAL is specified, that combined with DIR is used.) 6110 except that if INITIAL is specified, that combined with DIR is used.)
6111 If the user exits with an empty minibuffer, this function returns
6112 an empty string. (This can only happen if the user erased the
6113 pre-inserted contents or if `insert-default-directory' is nil.)
6109 Fourth arg MUSTMATCH non-nil means require existing file's name. 6114 Fourth arg MUSTMATCH non-nil means require existing file's name.
6110 Non-nil and non-t means also require confirmation after completion. 6115 Non-nil and non-t means also require confirmation after completion.
6111 Fifth arg INITIAL specifies text to start with. 6116 Fifth arg INITIAL specifies text to start with.
6112 If optional sixth arg PREDICATE is non-nil, possible completions and the 6117 If optional sixth arg PREDICATE is non-nil, possible completions and
6113 resulting file name must satisfy (funcall PREDICATE NAME). 6118 the resulting file name must satisfy (funcall PREDICATE NAME).
6114 DIR defaults to current buffer's directory default. 6119 DIR should be an absolute directory name. It defaults to the value of
6120 `default-directory'.
6115 6121
6116 If this command was invoked with the mouse, use a file dialog box if 6122 If this command was invoked with the mouse, use a file dialog box if
6117 `use-dialog-box' is non-nil, and the window system or X toolkit in use 6123 `use-dialog-box' is non-nil, and the window system or X toolkit in use
6118 provides a file dialog box. */) 6124 provides a file dialog box. */)
6119 (prompt, dir, default_filename, mustmatch, initial, predicate) 6125 (prompt, dir, default_filename, mustmatch, initial, predicate)
6273 6279
6274 tem = Fstring_equal (val, CONSP (insdef) ? XCAR (insdef) : insdef); 6280 tem = Fstring_equal (val, CONSP (insdef) ? XCAR (insdef) : insdef);
6275 6281
6276 if (!NILP (tem) && !NILP (default_filename)) 6282 if (!NILP (tem) && !NILP (default_filename))
6277 val = default_filename; 6283 val = default_filename;
6278 else if (SCHARS (val) == 0 && NILP (insdef))
6279 {
6280 if (!NILP (default_filename))
6281 val = default_filename;
6282 else
6283 error ("No default file name");
6284 }
6285 val = Fsubstitute_in_file_name (val); 6284 val = Fsubstitute_in_file_name (val);
6286 6285
6287 if (replace_in_history) 6286 if (replace_in_history)
6288 /* Replace what Fcompleting_read added to the history 6287 /* Replace what Fcompleting_read added to the history
6289 with what we will actually return. */ 6288 with what we will actually return. */
6455 DEFVAR_LISP ("read-file-name-predicate", &Vread_file_name_predicate, 6454 DEFVAR_LISP ("read-file-name-predicate", &Vread_file_name_predicate,
6456 doc: /* Current predicate used by `read-file-name-internal'. */); 6455 doc: /* Current predicate used by `read-file-name-internal'. */);
6457 Vread_file_name_predicate = Qnil; 6456 Vread_file_name_predicate = Qnil;
6458 6457
6459 DEFVAR_BOOL ("insert-default-directory", &insert_default_directory, 6458 DEFVAR_BOOL ("insert-default-directory", &insert_default_directory,
6460 doc: /* *Non-nil means when reading a filename start with default dir in minibuffer. */); 6459 doc: /* *Non-nil means when reading a filename start with default dir in minibuffer.
6460 If the initial minibuffer contents are non-empty, you can usually
6461 request a default filename by typing RETURN without editing. For some
6462 commands, exiting with an empty minibuffer has a special meaning,
6463 such as making the current buffer visit no file in the case of
6464 `set-visited-file-name'.
6465 If this variable is non-nil, the minibuffer contents are always
6466 initially non-empty and typing RETURN without editing will fetch the
6467 default name, if one is provided. Note however that this default name
6468 is not necessarily the name originally inserted in the minibuffer, if
6469 that is just the default directory.
6470 If this variable is nil, the minibuffer often starts out empty. In
6471 that case you may have to explicitly fetch the next history element to
6472 request the default name. */);
6461 insert_default_directory = 1; 6473 insert_default_directory = 1;
6462 6474
6463 DEFVAR_BOOL ("vms-stmlf-recfm", &vms_stmlf_recfm, 6475 DEFVAR_BOOL ("vms-stmlf-recfm", &vms_stmlf_recfm,
6464 doc: /* *Non-nil means write new files with record format `stmlf'. 6476 doc: /* *Non-nil means write new files with record format `stmlf'.
6465 nil means use format `var'. This variable is meaningful only on VMS. */); 6477 nil means use format `var'. This variable is meaningful only on VMS. */);