4550 |
(when (if (stringp switches) |
(when (if (stringp switches) |
4551 |
(string-match "--dired\\>" switches) |
(string-match "--dired\\>" switches) |
4552 |
(member "--dired" switches)) |
(member "--dired" switches)) |
4553 |
|
;; The following overshoots by one line for an empty |
4554 |
|
;; directory listed with "--dired", but without "-a" |
4555 |
|
;; switch, where the ls output contains a |
4556 |
|
;; "//DIRED-OPTIONS//" line, but no "//DIRED//" line. |
4557 |
|
;; We take care of that case later. |
4558 |
(forward-line -2) |
(forward-line -2) |
4559 |
(when (looking-at "//SUBDIRED//") |
(when (looking-at "//SUBDIRED//") |
4560 |
(delete-region (point) (progn (forward-line 1) (point))) |
(delete-region (point) (progn (forward-line 1) (point))) |
4561 |
(forward-line -1)) |
(forward-line -1)) |
4562 |
(when (looking-at "//DIRED//") |
(if (looking-at "//DIRED//") |
4563 |
(let ((end (line-end-position)) |
(let ((end (line-end-position)) |
4564 |
(linebeg (point)) |
(linebeg (point)) |
4565 |
error-lines) |
error-lines) |
4566 |
;; Find all the lines that are error messages, |
;; Find all the lines that are error messages, |
4567 |
;; and record the bounds of each one. |
;; and record the bounds of each one. |
4568 |
(goto-char beg) |
(goto-char beg) |
4569 |
(while (< (point) linebeg) |
(while (< (point) linebeg) |
4570 |
(or (eql (following-char) ?\s) |
(or (eql (following-char) ?\s) |
4571 |
(push (list (point) (line-end-position)) error-lines)) |
(push (list (point) (line-end-position)) error-lines)) |
4572 |
(forward-line 1)) |
(forward-line 1)) |
4573 |
(setq error-lines (nreverse error-lines)) |
(setq error-lines (nreverse error-lines)) |
4574 |
;; Now read the numeric positions of file names. |
;; Now read the numeric positions of file names. |
4575 |
(goto-char linebeg) |
(goto-char linebeg) |
4576 |
(forward-word 1) |
(forward-word 1) |
4577 |
(forward-char 3) |
(forward-char 3) |
4578 |
(while (< (point) end) |
(while (< (point) end) |
4579 |
(let ((start (insert-directory-adj-pos |
(let ((start (insert-directory-adj-pos |
4580 |
|
(+ beg (read (current-buffer))) |
4581 |
|
error-lines)) |
4582 |
|
(end (insert-directory-adj-pos |
4583 |
(+ beg (read (current-buffer))) |
(+ beg (read (current-buffer))) |
4584 |
error-lines)) |
error-lines))) |
4585 |
(end (insert-directory-adj-pos |
(if (memq (char-after end) '(?\n ?\ )) |
4586 |
(+ beg (read (current-buffer))) |
;; End is followed by \n or by " -> ". |
4587 |
error-lines))) |
(put-text-property start end 'dired-filename t) |
4588 |
(if (memq (char-after end) '(?\n ?\ )) |
;; It seems that we can't trust ls's output as to |
4589 |
;; End is followed by \n or by " -> ". |
;; byte positions of filenames. |
4590 |
(put-text-property start end 'dired-filename t) |
(put-text-property beg (point) 'dired-filename nil) |
4591 |
;; It seems that we can't trust ls's output as to |
(end-of-line)))) |
4592 |
;; byte positions of filenames. |
(goto-char end) |
4593 |
(put-text-property beg (point) 'dired-filename nil) |
(beginning-of-line) |
4594 |
(end-of-line)))) |
(delete-region (point) (progn (forward-line 1) (point)))) |
4595 |
(goto-char end) |
;; Take care of the case where the ls output contains a |
4596 |
(beginning-of-line) |
;; "//DIRED-OPTIONS//"-line, but no "//DIRED//"-line |
4597 |
(delete-region (point) (progn (forward-line 1) (point)))) |
;; and we went one line too far back (see above). |
4598 |
(if (looking-at "//DIRED-OPTIONS//") |
(forward-line 1)) |
4599 |
(delete-region (point) (progn (forward-line 1) (point)))))) |
(if (looking-at "//DIRED-OPTIONS//") |
4600 |
|
(delete-region (point) (progn (forward-line 1) (point))))) |
4601 |
|
|
4602 |
;; Now decode what read if necessary. |
;; Now decode what read if necessary. |
4603 |
(let ((coding (or coding-system-for-read |
(let ((coding (or coding-system-for-read |