comparison lisp/files.el @ 30907:46752ce55a92

(insert-directory): Don't lose original file name, undoing an undocumented change.
author Andreas Schwab <schwab@suse.de>
date Thu, 17 Aug 2000 12:07:05 +0000
parents df4c120d3d81
children 187803ce240e
comparison
equal deleted inserted replaced
30906:cab5c3c01776 30907:46752ce55a92
3501 3501
3502 This works by running a directory listing program 3502 This works by running a directory listing program
3503 whose name is in the variable `insert-directory-program'. 3503 whose name is in the variable `insert-directory-program'.
3504 If WILDCARD, it also runs the shell specified by `shell-file-name'." 3504 If WILDCARD, it also runs the shell specified by `shell-file-name'."
3505 ;; We need the directory in order to find the right handler. 3505 ;; We need the directory in order to find the right handler.
3506 (let* ((file (expand-file-name file)) 3506 (let ((handler (find-file-name-handler (expand-file-name file)
3507 (handler (find-file-name-handler file 'insert-directory))) 3507 'insert-directory)))
3508 (if handler 3508 (if handler
3509 (funcall handler 'insert-directory file switches 3509 (funcall handler 'insert-directory file switches
3510 wildcard full-directory-p) 3510 wildcard full-directory-p)
3511 (if (eq system-type 'vax-vms) 3511 (if (eq system-type 'vax-vms)
3512 (vms-read-directory file switches (current-buffer)) 3512 (vms-read-directory file switches (current-buffer))
3513 (let* ((coding-system-for-read 3513 (let* ((coding-system-for-read
3517 ;; This is to control encoding the arguments in call-process. 3517 ;; This is to control encoding the arguments in call-process.
3518 (coding-system-for-write coding-system-for-read) 3518 (coding-system-for-write coding-system-for-read)
3519 (result 3519 (result
3520 (if wildcard 3520 (if wildcard
3521 ;; Run ls in the directory of the file pattern we asked for 3521 ;; Run ls in the directory of the file pattern we asked for
3522 (let ((default-directory (file-name-directory file)) 3522 (let ((default-directory
3523 (if (file-name-absolute-p file)
3524 (file-name-directory file)
3525 (file-name-directory (expand-file-name file))))
3523 (pattern (file-name-nondirectory file))) 3526 (pattern (file-name-nondirectory file)))
3524 (call-process 3527 (call-process
3525 shell-file-name nil t nil 3528 shell-file-name nil t nil
3526 "-c" (concat (if (memq system-type '(ms-dos windows-nt)) 3529 "-c" (concat (if (memq system-type '(ms-dos windows-nt))
3527 "" 3530 ""
3528 "\\") ; Disregard Unix shell aliases! 3531 "\\") ; Disregard Unix shell aliases!
3529 insert-directory-program 3532 insert-directory-program
3530 " -d " 3533 " -d "
3531 (if (stringp switches) 3534 (if (stringp switches)
3532 switches 3535 switches
3533 (mapconcat 'identity switches " ")) 3536 (mapconcat 'identity switches " "))
3534 " -- " 3537 " -- "
3535 ;; Quote some characters that have 3538 ;; Quote some characters that have
3536 ;; special meanings in shells; but 3539 ;; special meanings in shells; but
3537 ;; don't quote the wildcards--we 3540 ;; don't quote the wildcards--we
3538 ;; want them to be special. We 3541 ;; want them to be special. We
3539 ;; also currently don't quote the 3542 ;; also currently don't quote the
3540 ;; quoting characters in case 3543 ;; quoting characters in case
3541 ;; people want to use them 3544 ;; people want to use them
3542 ;; explicitly to quote wildcard 3545 ;; explicitly to quote wildcard
3543 ;; characters. 3546 ;; characters.
3544 (shell-quote-wildcard-pattern pattern)))) 3547 (shell-quote-wildcard-pattern pattern))))
3545 ;; SunOS 4.1.3, SVr4 and others need the "." to list the 3548 ;; SunOS 4.1.3, SVr4 and others need the "." to list the
3546 ;; directory if FILE is a symbolic link. 3549 ;; directory if FILE is a symbolic link.
3547 (apply 'call-process 3550 (apply 'call-process
3548 insert-directory-program nil t nil 3551 insert-directory-program nil t nil
3549 (append 3552 (append
3550 (if (listp switches) switches 3553 (if (listp switches) switches
3551 (unless (equal switches "") 3554 (unless (equal switches "")
3552 ;; Split the switches at any spaces so we can 3555 ;; Split the switches at any spaces so we can
3553 ;; pass separate options as separate args. 3556 ;; pass separate options as separate args.
3554 (split-string switches))) 3557 (split-string switches)))
3555 ;; Avoid lossage if FILE starts with `-'. 3558 ;; Avoid lossage if FILE starts with `-'.
3556 '("--") 3559 '("--")
3557 (progn 3560 (progn
3558 (if (string-match "\\`~" file) 3561 (if (string-match "\\`~" file)
3559 (setq file (expand-file-name file))) 3562 (setq file (expand-file-name file)))
3560 (list 3563 (list
3561 (if full-directory-p 3564 (if full-directory-p
3562 (concat (file-name-as-directory file) ".") 3565 (concat (file-name-as-directory file) ".")
3563 file)))))))) 3566 file))))))))
3564 (if (/= result 0) 3567 (if (/= result 0)
3565 ;; We get here if `insert-directory-program' failed. 3568 ;; We get here if `insert-directory-program' failed.
3566 ;; On non-Posix systems, we cannot open a directory, so 3569 ;; On non-Posix systems, we cannot open a directory, so
3567 ;; don't even try, because that will always result in 3570 ;; don't even try, because that will always result in
3568 ;; the ubiquitous "Access denied". Instead, show them 3571 ;; the ubiquitous "Access denied". Instead, show them