[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: directory-files doesn't show "." and ".."
From: |
Thierry Volpiatto |
Subject: |
Re: directory-files doesn't show "." and ".." |
Date: |
Thu, 18 Feb 2010 07:40:15 +0100 |
User-agent: |
Gnus/5.110011 (No Gnus v0.11) Emacs/23.1.92 (gnu/linux) |
Thierry Volpiatto <address@hidden> writes:
> Hi,
> when i use directory-files with the FULL flag, it show the "." and ".."
> with their complete path name:
>
> ,----[ (directory-files default-directory t) ]
> | ("/ssh:thievol:/home/thierry/.emacs.d/themes/indian-theme.el"
> | "/ssh:thievol:/home/thierry/.emacs.d" >>>>>>>>>>>>>>>>>>>>>>>> ".."
> | "/ssh:thievol:/home/thierry/.emacs.d/themes/mybest-theme.el"
> | "/ssh:thievol:/home/thierry/.emacs.d/themes/basic-theme.el"
> | "/ssh:thievol:/home/thierry/.emacs.d/themes" >>>>>>>>>>>>>>>>> "."
> | "/ssh:thievol:/home/thierry/.emacs.d/themes/favorite-theme.el"
> | "/ssh:thievol:/home/thierry/.emacs.d/themes/forest-theme.el")
> `----
>
> However:
>
> ,----[ (directory-files default-directory) ]
> | ("indian-theme.el"
> | ".." >>>>>>>>>>>>> good
> | "mybest-theme.el"
> | "basic-theme.el"
> | "." >>>>>>>>>>>>>> good
> | "favorite-theme.el"
> | "forest-theme.el")
> `----
>
> Is that a bug?
That fix the problem:
(defun tramp-handle-directory-files
(directory &optional full match nosort files-only)
"Like `directory-files' for Tramp files."
;; FILES-ONLY is valid for XEmacs only.
(when (file-directory-p directory)
(setq directory (expand-file-name directory))
(let ((temp (nreverse (file-name-all-completions "" directory)))
result item dot)
(while temp
(setq item (directory-file-name (pop temp)))
(when (and (or (null match) (string-match match item))
(or (null files-only)
;; files only
(and (equal files-only t) (file-regular-p item))
;; directories only
(file-directory-p item)))
(if (and full (or (string= "." item) (string= ".." item)))
(push (concat (file-name-as-directory directory) item) dot)
(push (if full (expand-file-name item directory) item) result))))
(append (sort dot 'string-lessp) result))))
--
Thierry Volpiatto