]> git.eshelyaron.com Git - emacs.git/commitdiff
(insert-directory): Take care of empty directory, listed without -a switch.
authorLuc Teirlinck <teirllm@auburn.edu>
Sun, 23 Jan 2005 20:44:12 +0000 (20:44 +0000)
committerLuc Teirlinck <teirllm@auburn.edu>
Sun, 23 Jan 2005 20:44:12 +0000 (20:44 +0000)
lisp/ChangeLog
lisp/files.el

index 4575a3dc30154a2b108ee1dfc69c0f70807fd95b..f0c3b802ac19e3384d11648fd6badfe5310bd325 100644 (file)
@@ -1,3 +1,8 @@
+2005-01-23  Luc Teirlinck  <teirllm@auburn.edu>
+
+       * files.el (insert-directory): Take care of empty directory,
+       listed without -a switch.
+
 2005-01-23  Stefan Monnier  <monnier@iro.umontreal.ca>
 
        * term/w32-win.el: Simplify code.
index cdaa7a5adb8bed40ebb0b835ba39feb96ca0821a..841332b957a26a36b8187e36476fa4841fc6fcee 100644 (file)
@@ -4550,45 +4550,54 @@ normally equivalent short `-D' option is just passed on to
          (when (if (stringp switches)
                    (string-match "--dired\\>" switches)
                  (member "--dired" switches))
+           ;; The following overshoots by one line for an empty
+           ;; directory listed with "--dired", but without "-a"
+           ;; switch, where the ls output contains a
+           ;; "//DIRED-OPTIONS//" line, but no "//DIRED//" line.
+           ;; We take care of that case later.
            (forward-line -2)
             (when (looking-at "//SUBDIRED//")
               (delete-region (point) (progn (forward-line 1) (point)))
               (forward-line -1))
-           (when (looking-at "//DIRED//")
-             (let ((end (line-end-position))
-                   (linebeg (point))
-                   error-lines)
-               ;; Find all the lines that are error messages,
-               ;; and record the bounds of each one.
-               (goto-char beg)
-               (while (< (point) linebeg)
-                 (or (eql (following-char) ?\s)
-                     (push (list (point) (line-end-position)) error-lines))
-                 (forward-line 1))
-               (setq error-lines (nreverse error-lines))
-               ;; Now read the numeric positions of file names.
-               (goto-char linebeg)
-               (forward-word 1)
-               (forward-char 3)
-               (while (< (point) end)
-                 (let ((start (insert-directory-adj-pos
+           (if (looking-at "//DIRED//")
+               (let ((end (line-end-position))
+                     (linebeg (point))
+                     error-lines)
+                 ;; Find all the lines that are error messages,
+                 ;; and record the bounds of each one.
+                 (goto-char beg)
+                 (while (< (point) linebeg)
+                   (or (eql (following-char) ?\s)
+                       (push (list (point) (line-end-position)) error-lines))
+                   (forward-line 1))
+                 (setq error-lines (nreverse error-lines))
+                 ;; Now read the numeric positions of file names.
+                 (goto-char linebeg)
+                 (forward-word 1)
+                 (forward-char 3)
+                 (while (< (point) end)
+                   (let ((start (insert-directory-adj-pos
+                                 (+ beg (read (current-buffer)))
+                                 error-lines))
+                         (end (insert-directory-adj-pos
                                (+ beg (read (current-buffer)))
-                               error-lines))
-                       (end (insert-directory-adj-pos
-                             (+ beg (read (current-buffer)))
-                             error-lines)))
-                   (if (memq (char-after end) '(?\n ?\ ))
-                       ;; End is followed by \n or by " -> ".
-                       (put-text-property start end 'dired-filename t)
-                     ;; It seems that we can't trust ls's output as to
-                     ;; byte positions of filenames.
-                     (put-text-property beg (point) 'dired-filename nil)
-                     (end-of-line))))
-               (goto-char end)
-               (beginning-of-line)
-               (delete-region (point) (progn (forward-line 1) (point))))
-             (if (looking-at "//DIRED-OPTIONS//")
-                 (delete-region (point) (progn (forward-line 1) (point))))))
+                               error-lines)))
+                     (if (memq (char-after end) '(?\n ?\ ))
+                         ;; End is followed by \n or by " -> ".
+                         (put-text-property start end 'dired-filename t)
+                       ;; It seems that we can't trust ls's output as to
+                       ;; byte positions of filenames.
+                       (put-text-property beg (point) 'dired-filename nil)
+                       (end-of-line))))
+                 (goto-char end)
+                 (beginning-of-line)
+                 (delete-region (point) (progn (forward-line 1) (point))))
+             ;; Take care of the case where the ls output contains a
+             ;; "//DIRED-OPTIONS//"-line, but no "//DIRED//"-line
+             ;; and we went one line too far back (see above).
+             (forward-line 1))
+           (if (looking-at "//DIRED-OPTIONS//")
+               (delete-region (point) (progn (forward-line 1) (point)))))
 
          ;; Now decode what read if necessary.
          (let ((coding (or coding-system-for-read