diff options
author | Chong Yidong <cyd@stupidchicken.com> | 2010-02-08 20:58:57 -0500 |
---|---|---|
committer | Chong Yidong <cyd@stupidchicken.com> | 2010-02-08 20:58:57 -0500 |
commit | 3a66e78f66aba46ca62f6b1bb35ac7d2da081b31 (patch) | |
tree | da5b10d5ac2876cf18b85638b86c7cd56b5d6e77 /lisp/eshell | |
parent | 14a225f9c27fa8ea76a0fbee70c9a34dee474bb6 (diff) | |
download | emacs-3a66e78f66aba46ca62f6b1bb35ac7d2da081b31.tar.gz |
* eshell/em-ls.el (eshell-ls-applicable): Frob file attributes correctly (Bug#5548).
Diffstat (limited to 'lisp/eshell')
-rw-r--r-- | lisp/eshell/em-ls.el | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/lisp/eshell/em-ls.el b/lisp/eshell/em-ls.el index 9b008cebf1a..860ad5c77d8 100644 --- a/lisp/eshell/em-ls.el +++ b/lisp/eshell/em-ls.el @@ -225,18 +225,28 @@ really need to stick around for very long." (eq (aref (nth 8 attrs) 0) type))) (defmacro eshell-ls-applicable (attrs index func file) - "Test whether, for ATTRS, the user UID can do what corresponds to INDEX. -This is really just for efficiency, to avoid having to stat the file -yet again." - `(if (numberp (nth 2 ,attrs)) - (if (= (user-uid) (nth 2 ,attrs)) - (not (eq (aref (nth 8 ,attrs) ,index) ?-)) - (,(eval func) ,file)) - (not (eq (aref (nth 8 ,attrs) - (+ ,index (if (member (nth 2 ,attrs) - (eshell-current-ange-uids)) - 0 6))) - ?-)))) + "Test whether, for ATTRS, the user can do what corresponds to INDEX. +ATTRS is a string of file modes. See `file-attributes'. +If we cannot determine the answer using ATTRS (e.g., if we need +to know what group the user is in), compute the return value by +calling FUNC with FILE as an argument." + `(let ((owner (nth 2 ,attrs)) + (modes (nth 8 ,attrs))) + (cond ((cond ((numberp owner) + (= owner (user-uid))) + ((stringp owner) + (or (string-equal owner (user-login-name)) + (member owner (eshell-current-ange-uids))))) + ;; The user owns this file. + (not (eq (aref modes ,index) ?-))) + ((eq (aref modes (+ ,index 3)) + (aref modes (+ ,index 6))) + ;; If the "group" and "other" fields give identical + ;; results, use that. + (not (eq (aref modes (+ ,index 3)) ?-))) + (t + ;; Otherwise call FUNC. + (,(eval func) ,file))))) (defcustom eshell-ls-highlight-alist nil "*This alist correlates test functions to color. |