summaryrefslogtreecommitdiff
path: root/lisp/files.el
diff options
context:
space:
mode:
authorKenichi Handa <handa@m17n.org>1998-03-03 01:35:39 +0000
committerKenichi Handa <handa@m17n.org>1998-03-03 01:35:39 +0000
commit73ba53dc85bde59ad3682dc6af9b7ecf5f425576 (patch)
tree7b3a98f4224f9ca1ebe2755318b62f5564c3dcf0 /lisp/files.el
parent5280b5956058c1afeaab96f52febcb2641a280bb (diff)
downloademacs-73ba53dc85bde59ad3682dc6af9b7ecf5f425576.tar.gz
(insert-directory): Bind coding-system-for-read to
file-name-coding-system or default-file-name-coding-system if enable-multibyte-characters is non-nil
Diffstat (limited to 'lisp/files.el')
-rw-r--r--lisp/files.el123
1 files changed, 64 insertions, 59 deletions
diff --git a/lisp/files.el b/lisp/files.el
index a3ea8adac28..c25799990d7 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -2984,65 +2984,70 @@ If WILDCARD, it also runs the shell specified by `shell-file-name'."
wildcard full-directory-p)
(if (eq system-type 'vax-vms)
(vms-read-directory file switches (current-buffer))
- (or (= 0
- (if wildcard
- ;; Run ls in the directory of the file pattern we asked for.
- (let ((default-directory
- (if (file-name-absolute-p file)
- (file-name-directory file)
- (file-name-directory (expand-file-name file))))
- (pattern (file-name-nondirectory file))
- (beg 0))
- ;; Quote some characters that have special meanings in shells;
- ;; but don't quote the wildcards--we want them to be special.
- ;; We also currently don't quote the quoting characters
- ;; in case people want to use them explicitly to quote
- ;; wildcard characters.
- (while (string-match "[ \t\n;<>&|()#$]" pattern beg)
- (setq pattern
- (concat (substring pattern 0 (match-beginning 0))
- "\\"
- (substring pattern (match-beginning 0)))
- beg (1+ (match-end 0))))
- (call-process shell-file-name nil t nil
- "-c" (concat "\\" ;; Disregard shell aliases!
- insert-directory-program
- " -d "
- (if (stringp switches)
- switches
- (mapconcat 'identity switches " "))
- " -- "
- (encode-coding-string
- pattern
- file-name-coding-system t))))
- ;; SunOS 4.1.3, SVr4 and others need the "." to list the
- ;; directory if FILE is a symbolic link.
- (apply 'call-process
- insert-directory-program nil t nil
- (let (list)
- (if (listp switches)
- (setq list switches)
- (if (not (equal switches ""))
- (progn
- ;; Split the switches at any spaces
- ;; so we can pass separate options as separate args.
- (while (string-match " " switches)
- (setq list (cons (substring switches 0 (match-beginning 0))
- list)
- switches (substring switches (match-end 0))))
- (setq list (nreverse (cons switches list))))))
- (append list
- ;; Avoid lossage if FILE starts with `-'.
- '("--")
- (list
- (encode-coding-string
- (if full-directory-p
- (concat (file-name-as-directory file) ".")
- file)
- file-name-coding-system t)))))))
- ;; We get here if ls failed.
- ;; Access the file to get a suitable error.
- (access-file file "Reading directory"))))))
+ (let* ((coding-system-for-read
+ (and enable-multibyte-characters
+ (or file-name-coding-system
+ default-file-name-coding-system)))
+ (result
+ (if wildcard
+ ;; Run ls in the directory of the file pattern we asked for.
+ (let ((default-directory
+ (if (file-name-absolute-p file)
+ (file-name-directory file)
+ (file-name-directory (expand-file-name file))))
+ (pattern (file-name-nondirectory file))
+ (beg 0))
+ ;; Quote some characters that have special meanings in shells;
+ ;; but don't quote the wildcards--we want them to be special.
+ ;; We also currently don't quote the quoting characters
+ ;; in case people want to use them explicitly to quote
+ ;; wildcard characters.
+ (while (string-match "[ \t\n;<>&|()#$]" pattern beg)
+ (setq pattern
+ (concat (substring pattern 0 (match-beginning 0))
+ "\\"
+ (substring pattern (match-beginning 0)))
+ beg (1+ (match-end 0))))
+ (call-process shell-file-name nil t nil
+ "-c" (concat "\\";; Disregard shell aliases!
+ insert-directory-program
+ " -d "
+ (if (stringp switches)
+ switches
+ (mapconcat 'identity switches " "))
+ " -- "
+ (encode-coding-string
+ pattern
+ file-name-coding-system t))))
+ ;; SunOS 4.1.3, SVr4 and others need the "." to list the
+ ;; directory if FILE is a symbolic link.
+ (apply 'call-process
+ insert-directory-program nil t nil
+ (let (list)
+ (if (listp switches)
+ (setq list switches)
+ (if (not (equal switches ""))
+ (progn
+ ;; Split the switches at any spaces
+ ;; so we can pass separate options as separate args.
+ (while (string-match " " switches)
+ (setq list (cons (substring switches 0 (match-beginning 0))
+ list)
+ switches (substring switches (match-end 0))))
+ (setq list (nreverse (cons switches list))))))
+ (append list
+ ;; Avoid lossage if FILE starts with `-'.
+ '("--")
+ (list
+ (encode-coding-string
+ (if full-directory-p
+ (concat (file-name-as-directory file) ".")
+ file)
+ file-name-coding-system t))))))))
+ (if (/= result 0)
+ ;; We get here if ls failed.
+ ;; Access the file to get a suitable error.
+ (access-file file "Reading directory")))))))
(defvar kill-emacs-query-functions nil
"Functions to call with no arguments to query about killing Emacs.