Subject: bug#27 closed by Stefan Monnier <[email-masked]> (Re: incorrect code in dired-insert-directory)

From: [email-masked] (Emacs bug Tracking System)

This is an automatic notification regarding your bug report
which was filed against the emacs package:

#27: incorrect code in dired-insert-directory

It has been closed by Stefan Monnier <[email-masked]>.

Their explanation is attached below along with your original report.
If this explanation is unsatisfactory and you have not received a
better one in a separate message then please contact Stefan Monnier <[email-masked]> by
replying to this email.

-- 
27: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=27
Emacs Bug Tracking System
Contact [email-masked] with problems
>From [email-masked] Tue Jun 10 12:11:39 2008
From: Stefan Monnier <[email-masked]>
To: [email-masked]
Subject: Re: incorrect code in dired-insert-directory
Date: Tue, 10 Jun 2008 15:11:31 -0400

I believe this was fixed by the patch below,

        Stefan

--- dired.el.~1.399.~	2008-06-06 21:10:43.000000000 -0400
+++ dired.el	2008-06-10 15:09:37.000000000 -0400
@@ -1044,7 +1044,9 @@
     ;; Insert text at the beginning to standardize things.
     (save-excursion
       (goto-char opoint)
-      (if (and (or hdr wildcard) (not (looking-at "^  /.*:$")))
+      (if (and (or hdr wildcard)
+               (not (and (looking-at "^  \\(.*\\):$")
+                         (file-name-absolute-p (match-string 1)))))
 	  ;; Note that dired-build-subdir-alist will replace the name
 	  ;; by its expansion, so it does not matter whether what we insert
 	  ;; here is fully expanded, but it should be absolute.

>From [email-masked] Sun Mar  2 18:58:32 2008
Resent-Message-ID: <[email-masked]>
Resent-To: [email-masked]
Resent-From: Stefan Monnier <[email-masked]>
Resent-Date: Sun, 02 Mar 2008 21:58:10 -0500
From: "Drew Adams" <[email-masked]>
To: <[email-masked]>
Date: Thu, 28 Feb 2008 23:08:52 -0800
Subject: incorrect code in dired-insert-directory
Sender: bug-gnu-emacs-bounces+monnier=[email-masked]

This line near the end of dired-insert-directory is wrong:
 
 (if (and (or hdr wildcard) (not (looking-at "^  /.*:$")))
 
The problem is that "^ /.*:$" does not recognize a directory name on
MS Windows. The purpose of this code is to see if the directory name
is already in the buffer - if not, then it adds it. The test always
fails on Windows, so, whenever (or hdr wildcard) is non-nil, the `if'
test succeeds. That inserts a second copy of the directory name in the
buffer in some situations.
 
The regexp works only for Unix and GNU/Linux, not for Windows, which
has directories that have drive letters: c:/foobar/.

To reproduce (on Windows):

emacs -Q
Load the source file files.el.

C-u C-x 4 d 

Use switches -lR, and enter some directory name.

The first directory name in the buffer appears twice (the others are OK).

Note: The problem does not seem to arise if you don't load the source file,
for some reason.

This problem also exists in 22.1.90. And it exists as far back as Emacs 20.

In GNU Emacs 22.1.1 (i386-mingw-nt5.1.2600)
 of 2007-06-02 on RELEASE
Windowing system distributor `Microsoft Corp.', version 5.1.2600
configured using `configure --with-gcc (3.4) --cflags -Ic:/gnuwin32/include'