;;; esh-util.el --- general utilities
-;; Copyright (C) 1999, 2000, 2001 Free Software Foundation
+;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004,
+;; 2005, 2006 Free Software Foundation, Inc.
;; Author: John Wiegley <johnw@gnu.org>
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
(provide 'esh-util)
"Return non-nil if we are running under MS-DOS/Windows."
(memq system-type '(ms-dos windows-nt)))
-(defsubst eshell-under-cygwin-p ()
- "Return non-nil if we are running under Cygwin."
- (eq system-type 'cygwin32))
-
(defmacro eshell-condition-case (tag form &rest handlers)
"Like `condition-case', but only if `eshell-pass-through-errors' is nil."
(if eshell-handle-errors
parts)
(if (and (eshell-under-windows-p)
(> len 2)
- (eq (aref path 0) directory-sep-char)
- (eq (aref path 1) directory-sep-char))
+ (eq (aref path 0) ?/)
+ (eq (aref path 1) ?/))
(setq i 2))
(while (< i len)
- (if (and (eq (aref path i) directory-sep-char)
+ (if (and (eq (aref path i) ?/)
(not (get-text-property i 'escaped path)))
- (setq parts (cons (if (= li i)
- (char-to-string directory-sep-char)
+ (setq parts (cons (if (= li i) "/"
(substring path li (1+ i))) parts)
li (1+ i)))
(setq i (1+ i)))
(setq parts (cons (substring path li i) parts)))
(if (and (eshell-under-windows-p)
(string-match "\\`[A-Za-z]:\\'" (car (last parts))))
- (setcar (last parts)
- (concat (car (last parts))
- (char-to-string directory-sep-char))))
+ (setcar (last parts) (concat (car (last parts)) "/")))
(nreverse parts)))
(defun eshell-to-flat-string (value)
(point) (progn (end-of-line)
(point))) ":")))
(if (and (and fields (nth 0 fields) (nth 2 fields))
- (not (assq (string-to-int (nth 2 fields)) names)))
- (setq names (cons (cons (string-to-int (nth 2 fields))
+ (not (assq (string-to-number (nth 2 fields)) names)))
+ (setq names (cons (cons (string-to-number (nth 2 fields))
(nth 0 fields))
names))))
(forward-line))))
string)))
(unless (fboundp 'directory-files-and-attributes)
- (defun directory-files-and-attributes (dir &optional full match nosort)
- (documentation 'directory-files)
- (let ((dir (expand-file-name dir)) ange-cache)
+ (defun directory-files-and-attributes (directory &optional full match nosort)
+ "Return a list of names of files and their attributes in DIRECTORY.
+There are three optional arguments:
+If FULL is non-nil, return absolute file names. Otherwise return names
+ that are relative to the specified directory.
+If MATCH is non-nil, mention only file names that match the regexp MATCH.
+If NOSORT is non-nil, the list is not sorted--its order is unpredictable.
+ NOSORT is useful if you plan to sort the result yourself."
+ (let ((directory (expand-file-name directory)) ange-cache)
(mapcar
(function
(lambda (file)
- (cons file (eshell-file-attributes (expand-file-name file dir)))))
- (directory-files dir full match nosort)))))
+ (cons file (eshell-file-attributes (expand-file-name file directory)))))
+ (directory-files directory full match nosort)))))
(eval-when-compile
(defvar ange-cache))
;;; Code:
+;;; arch-tag: 70159778-5c7a-480a-bae4-3ad332fca19d
;;; esh-util.el ends here