From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Luc Teirlinck Newsgroups: gmane.emacs.devel Subject: Recent bug in insert-directory. Date: Sat, 8 Jan 2005 22:41:13 -0600 (CST) Message-ID: <200501090441.j094fDM16300@raven.dms.auburn.edu> NNTP-Posting-Host: deer.gmane.org X-Trace: sea.gmane.org 1105245834 30343 80.91.229.6 (9 Jan 2005 04:43:54 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 9 Jan 2005 04:43:54 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Jan 09 05:43:48 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1CnUvb-000496-00 for ; Sun, 09 Jan 2005 05:43:47 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1CnV72-0003ab-Hh for ged-emacs-devel@m.gmane.org; Sat, 08 Jan 2005 23:55:36 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1CnV6N-0003IQ-Br for emacs-devel@gnu.org; Sat, 08 Jan 2005 23:54:56 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1CnV6J-0003G2-PO for emacs-devel@gnu.org; Sat, 08 Jan 2005 23:54:53 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1CnV6I-0003FK-RW for emacs-devel@gnu.org; Sat, 08 Jan 2005 23:54:50 -0500 Original-Received: from [131.204.53.104] (helo=manatee.dms.auburn.edu) by monty-python.gnu.org with esmtp (Exim 4.34) id 1CnUtP-0004I4-He for emacs-devel@gnu.org; Sat, 08 Jan 2005 23:41:31 -0500 Original-Received: from raven.dms.auburn.edu (raven.dms.auburn.edu [131.204.53.29]) by manatee.dms.auburn.edu (8.12.10/8.12.10) with ESMTP id j094fL9N015941 for ; Sat, 8 Jan 2005 22:41:21 -0600 (CST) Original-Received: (from teirllm@localhost) by raven.dms.auburn.edu (8.11.7p1+Sun/8.11.7) id j094fDM16300; Sat, 8 Jan 2005 22:41:13 -0600 (CST) X-Authentication-Warning: raven.dms.auburn.edu: teirllm set sender to teirllm@dms.auburn.edu using -f Original-To: emacs-devel@gnu.org X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:32067 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:32067 If you do not have "-a" in `dired-listing-switches', an empty directory gets listed in a Dired buffer as: /home/teirllm/empty: total used in directory 0 available 21863712 //DIRED-OPTIONS// --quoting-style=(null) The last line looks weird. This must be a very recent bug, or I would have noticed it sooner. The code in `insert-directory' apparently does no longer take into account that for an empty directory we get: [bash2.05b.0 ~ 3 2] ls -l --dired empty total 0 //DIRED-OPTIONS// --quoting-style=(null) without any //DIRED// line. Or is this just because my version of ls is too old? The patch below fixes the bug. However, I am not familiar with the "error" stuff that led to the recent changes that introduced the bug. I am not sure whether or not the "error problem" can occur for an empty directory, listed without "-a". If not, the patch below should be sufficient. Otherwise, additional (or other) changes would be needed. ===File ~/files.el-diff===================================== *** files.el 04 Jan 2005 16:51:47 -0600 1.742 --- files.el 08 Jan 2005 22:22:27 -0600 *************** *** 4550,4594 **** (when (if (stringp switches) (string-match "--dired\\>" switches) (member "--dired" switches)) (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 (+ 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)))))) ;; Now decode what read if necessary. (let ((coding (or coding-system-for-read --- 4550,4603 ---- (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)) ! (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))) ! (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 ============================================================