X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/c0ece6a5c4c8dc87be1da6808289c88de19d8398..758c81e87ded2bad9f5a5a6683fb498965eb508c:/lisp/ls-lisp.el diff --git a/lisp/ls-lisp.el b/lisp/ls-lisp.el index 9314f934dc..de48987188 100644 --- a/lisp/ls-lisp.el +++ b/lisp/ls-lisp.el @@ -1,6 +1,6 @@ ;;; ls-lisp.el --- emulate insert-directory completely in Emacs Lisp -;; Copyright (C) 1992, 1994, 2000-2011 Free Software Foundation, Inc. +;; Copyright (C) 1992, 1994, 2000-2012 Free Software Foundation, Inc. ;; Author: Sebastian Kremer ;; Modified by: Francis J. Wright @@ -329,8 +329,9 @@ not contain `d', so that a full listing is expected." (max-gid-len 0) (max-file-size 0) ;; do all bindings here for speed - total-line files elt short file-size fil attr + total-line files elt short file-size attr fuid fgid uid-len gid-len) + (setq file-alist (ls-lisp-sanitize file-alist)) (cond ((memq ?A switches) (setq file-alist (ls-lisp-delete-matching "^\\.\\.?$" file-alist))) @@ -437,6 +438,22 @@ not contain `d', so that a full listing is expected." (message "%s: doesn't exist or is inaccessible" file) (ding) (sit-for 2))))) ; to show user the message! +(defun ls-lisp-sanitize (file-alist) + "Sanitize the elements in FILE-ALIST. +Fixes any elements in the alist for directory entries whose file +attributes are nil (meaning that `file-attributes' failed for +them). This is known to happen for some network shares, in +particular for the \"..\" directory entry. + +If the \"..\" directory entry has nil attributes, the attributes +are copied from the \".\" entry, if they are non-nil. Otherwise, +the offending element is removed from the list, as are any +elements for other directory entries with nil attributes." + (if (and (null (cdr (assoc ".." file-alist))) + (cdr (assoc "." file-alist))) + (setcdr (assoc ".." file-alist) (cdr (assoc "." file-alist)))) + (rassq-delete-all nil file-alist)) + (defun ls-lisp-column-format (file-alist) "Insert the file names (only) in FILE-ALIST into the current buffer. Format in columns, sorted vertically, following GNU ls -C.