comparison lisp/files.el @ 45552:0c2a22313f16

(read-directory-name): New function. (cd): Use it instead of read-file-name.
author Kim F. Storm <storm@cua.dk>
date Tue, 28 May 2002 09:08:42 +0000
parents 9a8b2dd39ddc
children 431fa03cb605
comparison
equal deleted inserted replaced
45551:811d06e337cb 45552:0c2a22313f16
467 This function's standard definition is trivial; it just returns the argument. 467 This function's standard definition is trivial; it just returns the argument.
468 However, on some systems, the function is redefined with a definition 468 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."
475 (interactive nil) 494 (interactive nil)
476 (message "Directory %s" default-directory)) 495 (message "Directory %s" default-directory))
515 (defun cd (dir) 534 (defun cd (dir)
516 "Make DIR become the current buffer's default directory. 535 "Make DIR become the current buffer's default directory.
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"))))))
524 (if (file-name-absolute-p dir) 543 (if (file-name-absolute-p dir)
525 (cd-absolute (expand-file-name dir)) 544 (cd-absolute (expand-file-name dir))