aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/eshell
diff options
context:
space:
mode:
authorEli Zaretskii2010-02-13 08:18:46 -0500
committerEli Zaretskii2010-02-13 08:18:46 -0500
commit36447e8d1f292611ce4db90e8fda8f3e25333747 (patch)
treeff731eb7f0b9651d55808eaa167e2e6dd5bc3fa1 /lisp/eshell
parent9a0d7cf1aaffb76aaf4a94f5124795dd9d7c8aed (diff)
parent98599f74d03c2dd4b6ac90d68266c508c5e0342e (diff)
downloademacs-36447e8d1f292611ce4db90e8fda8f3e25333747.tar.gz
emacs-36447e8d1f292611ce4db90e8fda8f3e25333747.zip
Merge from mainline.
Diffstat (limited to 'lisp/eshell')
-rw-r--r--lisp/eshell/em-ls.el50
-rw-r--r--lisp/eshell/esh-util.el9
2 files changed, 36 insertions, 23 deletions
diff --git a/lisp/eshell/em-ls.el b/lisp/eshell/em-ls.el
index 094f3ad9bb3..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."
225 (eq (aref (nth 8 attrs) 0) type))) 225 (eq (aref (nth 8 attrs) 0) type)))
226 226
227(defmacro eshell-ls-applicable (attrs index func file) 227(defmacro eshell-ls-applicable (attrs index func file)
228 "Test whether, for ATTRS, the user UID can do what corresponds to INDEX. 228 "Test whether, for ATTRS, the user can do what corresponds to INDEX.
229This is really just for efficiency, to avoid having to stat the file 229ATTRS is a string of file modes. See `file-attributes'.
230yet again." 230If we cannot determine the answer using ATTRS (e.g., if we need
231 `(if (numberp (nth 2 ,attrs)) 231to know what group the user is in), compute the return value by
232 (if (= (user-uid) (nth 2 ,attrs)) 232calling FUNC with FILE as an argument."
233 (not (eq (aref (nth 8 ,attrs) ,index) ?-)) 233 `(let ((owner (nth 2 ,attrs))
234 (,(eval func) ,file)) 234 (modes (nth 8 ,attrs)))
235 (not (eq (aref (nth 8 ,attrs) 235 (cond ((cond ((numberp owner)
236 (+ ,index (if (member (nth 2 ,attrs) 236 (= owner (user-uid)))
237 (eshell-current-ange-uids)) 237 ((stringp owner)
238 0 6))) 238 (or (string-equal owner (user-login-name))
239 ?-)))) 239 (member owner (eshell-current-ange-uids)))))
240 ;; The user owns this file.
241 (not (eq (aref modes ,index) ?-)))
242 ((eq (aref modes (+ ,index 3))
243 (aref modes (+ ,index 6)))
244 ;; If the "group" and "other" fields give identical
245 ;; results, use that.
246 (not (eq (aref modes (+ ,index 3)) ?-)))
247 (t
248 ;; Otherwise call FUNC.
249 (,(eval func) ,file)))))
240 250
241(defcustom eshell-ls-highlight-alist nil 251(defcustom eshell-ls-highlight-alist nil
242 "*This alist correlates test functions to color. 252 "*This alist correlates test functions to color.
@@ -393,13 +403,13 @@ Sort entries alphabetically across.")
393 (eshell-glob-regexp ignore-pattern)))) 403 (eshell-glob-regexp ignore-pattern))))
394 ;; list the files! 404 ;; list the files!
395 (eshell-ls-entries 405 (eshell-ls-entries
396 (mapcar (function 406 (mapcar (lambda (arg)
397 (lambda (arg) 407 (cons (if (and (eshell-under-windows-p)
398 (cons (if (and (eshell-under-windows-p) 408 (file-name-absolute-p arg))
399 (file-name-absolute-p arg)) 409 (expand-file-name arg)
400 (expand-file-name arg) 410 arg)
401 arg) 411 (eshell-file-attributes
402 (eshell-file-attributes arg)))) 412 arg (if numeric-uid-gid 'integer 'string))))
403 args) 413 args)
404 t (expand-file-name default-directory))) 414 t (expand-file-name default-directory)))
405 (funcall flush-func))) 415 (funcall flush-func)))
@@ -710,7 +720,7 @@ Each member of FILES is either a string or a cons cell of the form
710 (funcall insert-func need-return "\n")))))) 720 (funcall insert-func need-return "\n"))))))
711 721
712(defun eshell-ls-entries (entries &optional separate root-dir) 722(defun eshell-ls-entries (entries &optional separate root-dir)
713 "Output PATH's directory ENTRIES, formatted according to OPTIONS. 723 "Output PATH's directory ENTRIES.
714Each member of ENTRIES may either be a string or a cons cell, the car 724Each member of ENTRIES may either be a string or a cons cell, the car
715of which is the file name, and the cdr of which is the list of 725of which is the file name, and the cdr of which is the list of
716attributes. 726attributes.
diff --git a/lisp/eshell/esh-util.el b/lisp/eshell/esh-util.el
index 7c21e2e3302..1a4c5e1021b 100644
--- a/lisp/eshell/esh-util.el
+++ b/lisp/eshell/esh-util.el
@@ -701,8 +701,11 @@ If NOSORT is non-nil, the list is not sorted--its order is unpredictable.
701 (forward-line))) 701 (forward-line)))
702 entry)) 702 entry))
703 703
704(defun eshell-file-attributes (file) 704(defun eshell-file-attributes (file &optional id-format)
705 "Return the attributes of FILE, playing tricks if it's over ange-ftp." 705 "Return the attributes of FILE, playing tricks if it's over ange-ftp.
706The optional argument ID-FORMAT specifies the preferred uid and
707gid format. Valid values are 'string and 'integer, defaulting to
708'integer. See `file-attributes'."
706 (let* ((file (expand-file-name file)) 709 (let* ((file (expand-file-name file))
707 entry) 710 entry)
708 (if (string-equal (file-remote-p file 'method) "ftp") 711 (if (string-equal (file-remote-p file 'method) "ftp")
@@ -723,7 +726,7 @@ If NOSORT is non-nil, the list is not sorted--its order is unpredictable.
723 (setq entry (cdr fentry)) 726 (setq entry (cdr fentry))
724 (setq entry nil))))) 727 (setq entry nil)))))
725 entry) 728 entry)
726 (file-attributes file)))) 729 (file-attributes file id-format))))
727 730
728(defalias 'eshell-copy-tree 'copy-tree) 731(defalias 'eshell-copy-tree 'copy-tree)
729 732