Subject: Re: bug#2068: 23.0.60; dired-get-filename includes `*' for executable in name

From: Eli Zaretskii <[email-masked]>
Date: Wed, 28 Jan 2009 21:07:35 +0200

> From: "Drew Adams" <[email-masked]>
> Date: Tue, 27 Jan 2009 12:43:25 -0800
> Cc: 
> 
> > > emacs -Q
> > > 
> > > Create a file named `grep.exe' in some directory.
> > >
> > > Use `C-u C-x d' to visit the directory, and specify `-alF' as the
> > > listing switches.
> > > 
> > > Put the cursor on the line of the file named `grep.exe', which is
> > > displayed as `grep.exe*' to show that it is executable.
> >  
> > > M-: (dired-get-filename) returns "/the/dir/to/grep.exe*"
> >  
> > Can't reproduce this.  If this bug exists, it's probably Windows-only.
> 
> Yes, I pretty much figured it was Windows-only.

ls-lisp.el was putting the `dired-filename' property incorrectly when
the "-F" switch was used.  Fixed as below.

If you want to try this without rebuilding Emacs, you will need to
issue 2 commands, after byte-compiling the patched ls-lisp.el:

  M-x load-library RET files RET
  M-x load-library RET ls-lisp RET

IOW, files.elc needs to be loaded before ls-lisp, because the latter
redefines some functions in the former, and redefining them again will
give you trouble.

2009-01-28  Eli Zaretskii  <[email-masked]>

	* ls-lisp.el (ls-lisp-classify): Propertize file name before
	concatenating the type indicating character.
	(ls-lisp-format): Don't propertize file-name only if
	ls-lisp-classify already did.

Index: lisp/ls-lisp.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/ls-lisp.el,v
retrieving revision 1.80
retrieving revision 1.81
diff -u -r1.80 -r1.81
--- lisp/ls-lisp.el	5 Jan 2009 03:19:31 -0000	1.80
+++ lisp/ls-lisp.el	28 Jan 2009 19:01:42 -0000	1.81
@@ -531,13 +531,17 @@
         (type (cadr filedata)))
     (cond (type
 	   (cons
-	    (concat file-name (if (eq type t) "/" "@"))
+	    (concat (propertize file-name 'dired-filename t)
+		    (if (eq type t) "/" "@"))
 	    (cdr filedata)))
 	  ((string-match "x" (nth 9 filedata))
 	   (cons
-	    (concat file-name "*")
+	    (concat (propertize file-name 'dired-filename t) "*")
 	    (cdr filedata)))
-	  (t filedata))))
+	  (t
+	   (cons
+	    (propertize file-name 'dired-filename t)
+	    (cdr filedata))))))
 
 (defun ls-lisp-extension (filename)
   "Return extension of FILENAME (ignoring any version extension)
@@ -632,7 +636,9 @@
 	    " "
 	    (ls-lisp-format-time file-attr time-index now)
 	    " "
-	    (propertize file-name 'dired-filename t)
+	    (if (not (memq ?F switches)) ; ls-lisp-classify already did that
+		(propertize file-name 'dired-filename t)
+	      file-name)
 	    (if (stringp file-type)	; is a symbolic link
 		(concat " -> " file-type))
 	    "\n"