Mercurial > emacs
comparison lisp/files.el @ 54454:1aa9a08f7ca7
(insert-directory): Fix bug if SWITCHES is a list.
author | Luc Teirlinck <teirllm@auburn.edu> |
---|---|
date | Sun, 21 Mar 2004 04:38:36 +0000 |
parents | accdf6256d6e |
children | 1d3d777fda3f |
comparison
equal
deleted
inserted
replaced
54453:2e0d31caedd0 | 54454:1aa9a08f7ca7 |
---|---|
4203 ;; Filename handlers might have to remove this switch if their | 4203 ;; Filename handlers might have to remove this switch if their |
4204 ;; "ls" command does not support it. | 4204 ;; "ls" command does not support it. |
4205 (defun insert-directory (file switches &optional wildcard full-directory-p) | 4205 (defun insert-directory (file switches &optional wildcard full-directory-p) |
4206 "Insert directory listing for FILE, formatted according to SWITCHES. | 4206 "Insert directory listing for FILE, formatted according to SWITCHES. |
4207 Leaves point after the inserted text. | 4207 Leaves point after the inserted text. |
4208 SWITCHES may be a string of options, or a list of strings. | 4208 SWITCHES may be a string of options, or a list of strings |
4209 representing individual options. | |
4209 Optional third arg WILDCARD means treat FILE as shell wildcard. | 4210 Optional third arg WILDCARD means treat FILE as shell wildcard. |
4210 Optional fourth arg FULL-DIRECTORY-P means file is a directory and | 4211 Optional fourth arg FULL-DIRECTORY-P means file is a directory and |
4211 switches do not contain `d', so that a full listing is expected. | 4212 switches do not contain `d', so that a full listing is expected. |
4212 | 4213 |
4213 This works by running a directory listing program | 4214 This works by running a directory listing program |
4214 whose name is in the variable `insert-directory-program'. | 4215 whose name is in the variable `insert-directory-program'. |
4215 If WILDCARD, it also runs the shell specified by `shell-file-name'." | 4216 If WILDCARD, it also runs the shell specified by `shell-file-name'. |
4217 | |
4218 When SWITCHES contains the long `--dired' option,this function | |
4219 treats it specially, for the sake of dired. However, the | |
4220 normally equivalent short `-D' option is just passed on to | |
4221 `insert-directory-program', as any other option." | |
4216 ;; We need the directory in order to find the right handler. | 4222 ;; We need the directory in order to find the right handler. |
4217 (let ((handler (find-file-name-handler (expand-file-name file) | 4223 (let ((handler (find-file-name-handler (expand-file-name file) |
4218 'insert-directory))) | 4224 'insert-directory))) |
4219 (if handler | 4225 (if handler |
4220 (funcall handler 'insert-directory file switches | 4226 (funcall handler 'insert-directory file switches |
4299 file result) | 4305 file result) |
4300 ;; Unix. Access the file to get a suitable error. | 4306 ;; Unix. Access the file to get a suitable error. |
4301 (access-file file "Reading directory") | 4307 (access-file file "Reading directory") |
4302 (error "Listing directory failed but `access-file' worked"))) | 4308 (error "Listing directory failed but `access-file' worked"))) |
4303 | 4309 |
4304 (when (string-match "--dired\\>" switches) | 4310 (when (if (stringp switches) |
4311 (string-match "--dired\\>" switches) | |
4312 (member "--dired" switches)) | |
4305 (forward-line -2) | 4313 (forward-line -2) |
4306 (when (looking-at "//SUBDIRED//") | 4314 (when (looking-at "//SUBDIRED//") |
4307 (delete-region (point) (progn (forward-line 1) (point))) | 4315 (delete-region (point) (progn (forward-line 1) (point))) |
4308 (forward-line -1)) | 4316 (forward-line -1)) |
4309 (let ((end (line-end-position))) | 4317 (let ((end (line-end-position))) |