aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuc Teirlinck2005-01-23 20:44:12 +0000
committerLuc Teirlinck2005-01-23 20:44:12 +0000
commit9bb99df69185f6c105ee3a214e606f68a3483e5e (patch)
tree4b98c566077b4e10a07ea5aa7d6959c575ca813a
parentbd6a8278adac29297a853a8f8d4651dd1f715932 (diff)
downloademacs-9bb99df69185f6c105ee3a214e606f68a3483e5e.tar.gz
emacs-9bb99df69185f6c105ee3a214e606f68a3483e5e.zip
(insert-directory): Take care of empty directory, listed without -a switch.
-rw-r--r--lisp/ChangeLog5
-rw-r--r--lisp/files.el77
2 files changed, 48 insertions, 34 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 4575a3dc301..f0c3b802ac1 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
12005-01-23 Luc Teirlinck <teirllm@auburn.edu>
2
3 * files.el (insert-directory): Take care of empty directory,
4 listed without -a switch.
5
12005-01-23 Stefan Monnier <monnier@iro.umontreal.ca> 62005-01-23 Stefan Monnier <monnier@iro.umontreal.ca>
2 7
3 * term/w32-win.el: Simplify code. 8 * term/w32-win.el: Simplify code.
diff --git a/lisp/files.el b/lisp/files.el
index cdaa7a5adb8..841332b957a 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -4550,45 +4550,54 @@ normally equivalent short `-D' option is just passed on to
4550 (when (if (stringp switches) 4550 (when (if (stringp switches)
4551 (string-match "--dired\\>" switches) 4551 (string-match "--dired\\>" switches)
4552 (member "--dired" switches)) 4552 (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.
4553 (forward-line -2) 4558 (forward-line -2)
4554 (when (looking-at "//SUBDIRED//") 4559 (when (looking-at "//SUBDIRED//")
4555 (delete-region (point) (progn (forward-line 1) (point))) 4560 (delete-region (point) (progn (forward-line 1) (point)))
4556 (forward-line -1)) 4561 (forward-line -1))
4557 (when (looking-at "//DIRED//") 4562 (if (looking-at "//DIRED//")
4558 (let ((end (line-end-position)) 4563 (let ((end (line-end-position))
4559 (linebeg (point)) 4564 (linebeg (point))
4560 error-lines) 4565 error-lines)
4561 ;; Find all the lines that are error messages, 4566 ;; Find all the lines that are error messages,
4562 ;; and record the bounds of each one. 4567 ;; and record the bounds of each one.
4563 (goto-char beg) 4568 (goto-char beg)
4564 (while (< (point) linebeg) 4569 (while (< (point) linebeg)
4565 (or (eql (following-char) ?\s) 4570 (or (eql (following-char) ?\s)
4566 (push (list (point) (line-end-position)) error-lines)) 4571 (push (list (point) (line-end-position)) error-lines))
4567 (forward-line 1)) 4572 (forward-line 1))
4568 (setq error-lines (nreverse error-lines)) 4573 (setq error-lines (nreverse error-lines))
4569 ;; Now read the numeric positions of file names. 4574 ;; Now read the numeric positions of file names.
4570 (goto-char linebeg) 4575 (goto-char linebeg)
4571 (forward-word 1) 4576 (forward-word 1)
4572 (forward-char 3) 4577 (forward-char 3)
4573 (while (< (point) end) 4578 (while (< (point) end)
4574 (let ((start (insert-directory-adj-pos 4579 (let ((start (insert-directory-adj-pos
4580 (+ beg (read (current-buffer)))
4581 error-lines))
4582 (end (insert-directory-adj-pos
4575 (+ beg (read (current-buffer))) 4583 (+ beg (read (current-buffer)))
4576 error-lines)) 4584 error-lines)))
4577 (end (insert-directory-adj-pos 4585 (if (memq (char-after end) '(?\n ?\ ))
4578 (+ beg (read (current-buffer))) 4586 ;; End is followed by \n or by " -> ".
4579 error-lines))) 4587 (put-text-property start end 'dired-filename t)
4580 (if (memq (char-after end) '(?\n ?\ )) 4588 ;; It seems that we can't trust ls's output as to
4581 ;; End is followed by \n or by " -> ". 4589 ;; byte positions of filenames.
4582 (put-text-property start end 'dired-filename t) 4590 (put-text-property beg (point) 'dired-filename nil)
4583 ;; It seems that we can't trust ls's output as to 4591 (end-of-line))))
4584 ;; byte positions of filenames. 4592 (goto-char end)
4585 (put-text-property beg (point) 'dired-filename nil) 4593 (beginning-of-line)
4586 (end-of-line)))) 4594 (delete-region (point) (progn (forward-line 1) (point))))
4587 (goto-char end) 4595 ;; Take care of the case where the ls output contains a
4588 (beginning-of-line) 4596 ;; "//DIRED-OPTIONS//"-line, but no "//DIRED//"-line
4589 (delete-region (point) (progn (forward-line 1) (point)))) 4597 ;; and we went one line too far back (see above).
4590 (if (looking-at "//DIRED-OPTIONS//") 4598 (forward-line 1))
4591 (delete-region (point) (progn (forward-line 1) (point)))))) 4599 (if (looking-at "//DIRED-OPTIONS//")
4600 (delete-region (point) (progn (forward-line 1) (point)))))
4592 4601
4593 ;; Now decode what read if necessary. 4602 ;; Now decode what read if necessary.
4594 (let ((coding (or coding-system-for-read 4603 (let ((coding (or coding-system-for-read