diff options
| author | Luc Teirlinck | 2004-01-31 04:24:23 +0000 |
|---|---|---|
| committer | Luc Teirlinck | 2004-01-31 04:24:23 +0000 |
| commit | 238aedc9732c558901ef632311445cb03adc529c (patch) | |
| tree | 1d490253ff7691f6542268961a1457e4f622015c /src | |
| parent | a0367d423d5a84324074d382685b7d5e9626ae34 (diff) | |
| download | emacs-238aedc9732c558901ef632311445cb03adc529c.tar.gz emacs-238aedc9732c558901ef632311445cb03adc529c.zip | |
(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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/fileio.c | 36 |
1 files changed, 24 insertions, 12 deletions
diff --git a/src/fileio.c b/src/fileio.c index a2b207169cf..c7959b3672d 100644 --- a/src/fileio.c +++ b/src/fileio.c | |||
| @@ -6095,6 +6095,7 @@ DEFUN ("read-file-name-internal", Fread_file_name_internal, Sread_file_name_inte | |||
| 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); |
| @@ -6103,15 +6104,20 @@ DEFUN ("read-file-name-internal", Fread_file_name_internal, Sread_file_name_inte | |||
| 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 |
| @@ -6275,13 +6281,6 @@ provides a file dialog box. */) | |||
| 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) |
| @@ -6457,7 +6456,20 @@ same format as a regular save would use. */); | |||
| 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, |