aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLuc Teirlinck2004-01-31 04:24:23 +0000
committerLuc Teirlinck2004-01-31 04:24:23 +0000
commit238aedc9732c558901ef632311445cb03adc529c (patch)
tree1d490253ff7691f6542268961a1457e4f622015c /src
parenta0367d423d5a84324074d382685b7d5e9626ae34 (diff)
downloademacs-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.c36
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
6103DEFUN ("read-file-name", Fread_file_name, Sread_file_name, 1, 6, 0, 6104DEFUN ("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.
6105Value is not expanded---you must call `expand-file-name' yourself. 6106Value is not expanded---you must call `expand-file-name' yourself.
6106Default name to DEFAULT-FILENAME if user enters a null string. 6107Default name to DEFAULT-FILENAME if user exits the minibuffer with
6108the 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.)
6111If the user exits with an empty minibuffer, this function returns
6112an empty string. (This can only happen if the user erased the
6113pre-inserted contents or if `insert-default-directory' is nil.)
6109Fourth arg MUSTMATCH non-nil means require existing file's name. 6114Fourth 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.
6111Fifth arg INITIAL specifies text to start with. 6116Fifth arg INITIAL specifies text to start with.
6112If optional sixth arg PREDICATE is non-nil, possible completions and the 6117If optional sixth arg PREDICATE is non-nil, possible completions and
6113resulting file name must satisfy (funcall PREDICATE NAME). 6118the resulting file name must satisfy (funcall PREDICATE NAME).
6114DIR defaults to current buffer's directory default. 6119DIR should be an absolute directory name. It defaults to the value of
6120`default-directory'.
6115 6121
6116If this command was invoked with the mouse, use a file dialog box if 6122If 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.
6460If the initial minibuffer contents are non-empty, you can usually
6461request a default filename by typing RETURN without editing. For some
6462commands, exiting with an empty minibuffer has a special meaning,
6463such as making the current buffer visit no file in the case of
6464`set-visited-file-name'.
6465If this variable is non-nil, the minibuffer contents are always
6466initially non-empty and typing RETURN without editing will fetch the
6467default name, if one is provided. Note however that this default name
6468is not necessarily the name originally inserted in the minibuffer, if
6469that is just the default directory.
6470If this variable is nil, the minibuffer often starts out empty. In
6471that case you may have to explicitly fetch the next history element to
6472request 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,