diff options
| author | Kenichi Handa | 2003-01-23 05:59:47 +0000 |
|---|---|---|
| committer | Kenichi Handa | 2003-01-23 05:59:47 +0000 |
| commit | 99f01c91bc65227544638a2ad436bb076cb4e00e (patch) | |
| tree | 52ba472be06eb3af3e48ffef8ebafc57f481cd16 | |
| parent | ecc39168868aab987f91f690273b1d1a649746a4 (diff) | |
| download | emacs-99f01c91bc65227544638a2ad436bb076cb4e00e.tar.gz emacs-99f01c91bc65227544638a2ad436bb076cb4e00e.zip | |
(insert-directory): Read the output of "ls" by
no-conversion, and decode it later while preserving
`dired-filename' property.
| -rw-r--r-- | lisp/files.el | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/lisp/files.el b/lisp/files.el index 321c52460c9..8a801a3d530 100644 --- a/lisp/files.el +++ b/lisp/files.el | |||
| @@ -4017,12 +4017,15 @@ If WILDCARD, it also runs the shell specified by `shell-file-name'." | |||
| 4017 | 4017 | ||
| 4018 | ;; Read the actual directory using `insert-directory-program'. | 4018 | ;; Read the actual directory using `insert-directory-program'. |
| 4019 | ;; RESULT gets the status code. | 4019 | ;; RESULT gets the status code. |
| 4020 | (let* ((coding-system-for-read | 4020 | (let* (;; We at first read by no-conversion, then after |
| 4021 | ;; putting text property `dired-filename, decode one | ||
| 4022 | ;; bunch by one to preserve that property. | ||
| 4023 | (coding-system-for-read 'no-conversion) | ||
| 4024 | ;; This is to control encoding the arguments in call-process. | ||
| 4025 | (coding-system-for-write | ||
| 4021 | (and enable-multibyte-characters | 4026 | (and enable-multibyte-characters |
| 4022 | (or file-name-coding-system | 4027 | (or file-name-coding-system |
| 4023 | default-file-name-coding-system))) | 4028 | default-file-name-coding-system)))) |
| 4024 | ;; This is to control encoding the arguments in call-process. | ||
| 4025 | (coding-system-for-write coding-system-for-read)) | ||
| 4026 | (setq result | 4029 | (setq result |
| 4027 | (if wildcard | 4030 | (if wildcard |
| 4028 | ;; Run ls in the directory part of the file pattern | 4031 | ;; Run ls in the directory part of the file pattern |
| @@ -4106,6 +4109,23 @@ If WILDCARD, it also runs the shell specified by `shell-file-name'." | |||
| 4106 | (beginning-of-line) | 4109 | (beginning-of-line) |
| 4107 | (delete-region (point) (progn (forward-line 2) (point))))) | 4110 | (delete-region (point) (progn (forward-line 2) (point))))) |
| 4108 | 4111 | ||
| 4112 | ;; Now decode what read if necessary. | ||
| 4113 | (let ((coding (or coding-system-for-write | ||
| 4114 | (detect-coding-region beg (point) t))) | ||
| 4115 | val pos) | ||
| 4116 | (if (not (eq (coding-system-base coding) 'undecided)) | ||
| 4117 | (save-restriction | ||
| 4118 | (narrow-to-region beg (point)) | ||
| 4119 | (goto-char (point-min)) | ||
| 4120 | (while (not (eobp)) | ||
| 4121 | (setq pos (point) | ||
| 4122 | val (get-text-property (point) 'dired-filename)) | ||
| 4123 | (goto-char (next-single-property-change | ||
| 4124 | (point) 'dired-filename nil (point-max))) | ||
| 4125 | (decode-coding-region pos (point) coding) | ||
| 4126 | (if val | ||
| 4127 | (put-text-property pos (point) 'dired-filename t)))))) | ||
| 4128 | |||
| 4109 | (if full-directory-p | 4129 | (if full-directory-p |
| 4110 | ;; Try to insert the amount of free space. | 4130 | ;; Try to insert the amount of free space. |
| 4111 | (save-excursion | 4131 | (save-excursion |