Function: eshell-ls-applicable

eshell-ls-applicable is a macro defined in em-ls.el.gz.

Signature

(eshell-ls-applicable ATTRS INDEX FUNC FILE)

Documentation

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.

Source Code

;; Defined in /usr/src/emacs/lisp/eshell/em-ls.el.gz
(defmacro eshell-ls-applicable (attrs index func file)
  "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 (file-attribute-user-id ,attrs))
	 (modes (file-attribute-modes ,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)))))