comparison lisp/files.el @ 21041:a7526e76aac9

(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
author Kenichi Handa <handa@m17n.org>
date Tue, 03 Mar 1998 01:35:39 +0000
parents 88e63a96a2d4
children 390b026f483d
comparison
equal deleted inserted replaced
21040:290a1c16d25d 21041:a7526e76aac9
2982 (if handler 2982 (if handler
2983 (funcall handler 'insert-directory file switches 2983 (funcall handler 'insert-directory file switches
2984 wildcard full-directory-p) 2984 wildcard full-directory-p)
2985 (if (eq system-type 'vax-vms) 2985 (if (eq system-type 'vax-vms)
2986 (vms-read-directory file switches (current-buffer)) 2986 (vms-read-directory file switches (current-buffer))
2987 (or (= 0 2987 (let* ((coding-system-for-read
2988 (if wildcard 2988 (and enable-multibyte-characters
2989 ;; Run ls in the directory of the file pattern we asked for. 2989 (or file-name-coding-system
2990 (let ((default-directory 2990 default-file-name-coding-system)))
2991 (if (file-name-absolute-p file) 2991 (result
2992 (file-name-directory file) 2992 (if wildcard
2993 (file-name-directory (expand-file-name file)))) 2993 ;; Run ls in the directory of the file pattern we asked for.
2994 (pattern (file-name-nondirectory file)) 2994 (let ((default-directory
2995 (beg 0)) 2995 (if (file-name-absolute-p file)
2996 ;; Quote some characters that have special meanings in shells; 2996 (file-name-directory file)
2997 ;; but don't quote the wildcards--we want them to be special. 2997 (file-name-directory (expand-file-name file))))
2998 ;; We also currently don't quote the quoting characters 2998 (pattern (file-name-nondirectory file))
2999 ;; in case people want to use them explicitly to quote 2999 (beg 0))
3000 ;; wildcard characters. 3000 ;; Quote some characters that have special meanings in shells;
3001 (while (string-match "[ \t\n;<>&|()#$]" pattern beg) 3001 ;; but don't quote the wildcards--we want them to be special.
3002 (setq pattern 3002 ;; We also currently don't quote the quoting characters
3003 (concat (substring pattern 0 (match-beginning 0)) 3003 ;; in case people want to use them explicitly to quote
3004 "\\" 3004 ;; wildcard characters.
3005 (substring pattern (match-beginning 0))) 3005 (while (string-match "[ \t\n;<>&|()#$]" pattern beg)
3006 beg (1+ (match-end 0)))) 3006 (setq pattern
3007 (call-process shell-file-name nil t nil 3007 (concat (substring pattern 0 (match-beginning 0))
3008 "-c" (concat "\\" ;; Disregard shell aliases! 3008 "\\"
3009 insert-directory-program 3009 (substring pattern (match-beginning 0)))
3010 " -d " 3010 beg (1+ (match-end 0))))
3011 (if (stringp switches) 3011 (call-process shell-file-name nil t nil
3012 switches 3012 "-c" (concat "\\";; Disregard shell aliases!
3013 (mapconcat 'identity switches " ")) 3013 insert-directory-program
3014 " -- " 3014 " -d "
3015 (encode-coding-string 3015 (if (stringp switches)
3016 pattern 3016 switches
3017 file-name-coding-system t)))) 3017 (mapconcat 'identity switches " "))
3018 ;; SunOS 4.1.3, SVr4 and others need the "." to list the 3018 " -- "
3019 ;; directory if FILE is a symbolic link. 3019 (encode-coding-string
3020 (apply 'call-process 3020 pattern
3021 insert-directory-program nil t nil 3021 file-name-coding-system t))))
3022 (let (list) 3022 ;; SunOS 4.1.3, SVr4 and others need the "." to list the
3023 (if (listp switches) 3023 ;; directory if FILE is a symbolic link.
3024 (setq list switches) 3024 (apply 'call-process
3025 (if (not (equal switches "")) 3025 insert-directory-program nil t nil
3026 (progn 3026 (let (list)
3027 ;; Split the switches at any spaces 3027 (if (listp switches)
3028 ;; so we can pass separate options as separate args. 3028 (setq list switches)
3029 (while (string-match " " switches) 3029 (if (not (equal switches ""))
3030 (setq list (cons (substring switches 0 (match-beginning 0)) 3030 (progn
3031 list) 3031 ;; Split the switches at any spaces
3032 switches (substring switches (match-end 0)))) 3032 ;; so we can pass separate options as separate args.
3033 (setq list (nreverse (cons switches list)))))) 3033 (while (string-match " " switches)
3034 (append list 3034 (setq list (cons (substring switches 0 (match-beginning 0))
3035 ;; Avoid lossage if FILE starts with `-'. 3035 list)
3036 '("--") 3036 switches (substring switches (match-end 0))))
3037 (list 3037 (setq list (nreverse (cons switches list))))))
3038 (encode-coding-string 3038 (append list
3039 (if full-directory-p 3039 ;; Avoid lossage if FILE starts with `-'.
3040 (concat (file-name-as-directory file) ".") 3040 '("--")
3041 file) 3041 (list
3042 file-name-coding-system t))))))) 3042 (encode-coding-string
3043 ;; We get here if ls failed. 3043 (if full-directory-p
3044 ;; Access the file to get a suitable error. 3044 (concat (file-name-as-directory file) ".")
3045 (access-file file "Reading directory")))))) 3045 file)
3046 file-name-coding-system t))))))))
3047 (if (/= result 0)
3048 ;; We get here if ls failed.
3049 ;; Access the file to get a suitable error.
3050 (access-file file "Reading directory")))))))
3046 3051
3047 (defvar kill-emacs-query-functions nil 3052 (defvar kill-emacs-query-functions nil
3048 "Functions to call with no arguments to query about killing Emacs. 3053 "Functions to call with no arguments to query about killing Emacs.
3049 If any of these functions returns nil, killing Emacs is cancelled. 3054 If any of these functions returns nil, killing Emacs is cancelled.
3050 `save-buffers-kill-emacs' (\\[save-buffers-kill-emacs]) calls these functions, 3055 `save-buffers-kill-emacs' (\\[save-buffers-kill-emacs]) calls these functions,