diff options
| author | Kim F. Storm | 2002-05-28 09:08:42 +0000 |
|---|---|---|
| committer | Kim F. Storm | 2002-05-28 09:08:42 +0000 |
| commit | 5d4d17b82396debb1ae3f1042f111f075fd93cd3 (patch) | |
| tree | f6b6c4825497ffee53bd44988b11c2cc914f522b | |
| parent | da46f04f2c88c210ddec0a1acf63868beeb34c63 (diff) | |
| download | emacs-5d4d17b82396debb1ae3f1042f111f075fd93cd3.tar.gz emacs-5d4d17b82396debb1ae3f1042f111f075fd93cd3.zip | |
(read-directory-name): New function.
(cd): Use it instead of read-file-name.
| -rw-r--r-- | lisp/files.el | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/lisp/files.el b/lisp/files.el index b01472171a9..51b2ca50387 100644 --- a/lisp/files.el +++ b/lisp/files.el | |||
| @@ -469,6 +469,25 @@ However, on some systems, the function is redefined with a definition | |||
| 469 | that really does change some file names to canonicalize certain | 469 | that really does change some file names to canonicalize certain |
| 470 | patterns and to guarantee valid names." | 470 | patterns and to guarantee valid names." |
| 471 | filename) | 471 | filename) |
| 472 | |||
| 473 | (defun read-directory-name (prompt &optional dir default-dirname mustmatch initial) | ||
| 474 | "Read directory name, prompting with PROMPT and completing in directory DIR. | ||
| 475 | Value is not expanded---you must call `expand-file-name' yourself. | ||
| 476 | Default name to DEFAULT-DIRNAME if user enters a null string. | ||
| 477 | (If DEFAULT-DIRNAME is omitted, the current buffer's directory is used, | ||
| 478 | except that if INITIAL is specified, that combined with DIR is used.) | ||
| 479 | Fourth arg MUSTMATCH non-nil means require existing directory's name. | ||
| 480 | Non-nil and non-t means also require confirmation after completion. | ||
| 481 | Fifth arg INITIAL specifies text to start with. | ||
| 482 | DIR defaults to current buffer's directory default." | ||
| 483 | (unless dir | ||
| 484 | (setq dir default-directory)) | ||
| 485 | (unless default-dirname | ||
| 486 | (setq default-dirname | ||
| 487 | (if initial (concat dir initial) default-directory))) | ||
| 488 | (read-file-name prompt dir default-dirname mustmatch initial | ||
| 489 | 'file-directory-p)) | ||
| 490 | |||
| 472 | 491 | ||
| 473 | (defun pwd () | 492 | (defun pwd () |
| 474 | "Show the current default directory." | 493 | "Show the current default directory." |
| @@ -517,7 +536,7 @@ Not actually set up until the first time you use it.") | |||
| 517 | If your environment includes a `CDPATH' variable, try each one of that | 536 | If your environment includes a `CDPATH' variable, try each one of that |
| 518 | colon-separated list of directories when resolving a relative directory name." | 537 | colon-separated list of directories when resolving a relative directory name." |
| 519 | (interactive | 538 | (interactive |
| 520 | (list (read-file-name "Change default directory: " | 539 | (list (read-directory-name "Change default directory: " |
| 521 | default-directory default-directory | 540 | default-directory default-directory |
| 522 | (and (member cd-path '(nil ("./"))) | 541 | (and (member cd-path '(nil ("./"))) |
| 523 | (null (getenv "CDPATH")))))) | 542 | (null (getenv "CDPATH")))))) |