changeset 107275:cf50b15a097b

Merge from mainline.
author Katsumi Yamaoka <yamaoka@jpl.org>
date Tue, 09 Feb 2010 21:54:40 +0000
parents f401d10ebfb7 (current diff) 0449c21035e7 (diff)
children 2dee04cb649f
files
diffstat 3 files changed, 28 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Tue Feb 09 00:01:14 2010 +0000
+++ b/lisp/ChangeLog	Tue Feb 09 21:54:40 2010 +0000
@@ -1,3 +1,8 @@
+2010-02-09  Chong Yidong  <cyd@stupidchicken.com>
+
+	* eshell/em-ls.el (eshell-ls-applicable): Frob file attributes
+	correctly (Bug#5548).
+
 2010-02-08  Jose E. Marchesi  <jemarch@gnu.org>
 
 	* progmodes/ada-mode.el (ada-in-numeric-literal-p): New function.
--- a/lisp/eshell/em-ls.el	Tue Feb 09 00:01:14 2010 +0000
+++ b/lisp/eshell/em-ls.el	Tue Feb 09 21:54:40 2010 +0000
@@ -225,18 +225,28 @@
       (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.
--- a/src/ChangeLog	Tue Feb 09 00:01:14 2010 +0000
+++ b/src/ChangeLog	Tue Feb 09 21:54:40 2010 +0000
@@ -1,4 +1,4 @@
-2010-02-08  Francis Devereux  <francis@devrx.org>
+2010-02-08  Francis Devereux  <francis@devrx.org>  (tiny change)
 
 	* nsfont.m (nsfont_open): The system's value for the font descent
 	is negative, so round it down to avoid clipping.