diff options
Diffstat (limited to 'lisp/eshell/esh-util.el')
-rw-r--r-- | lisp/eshell/esh-util.el | 53 |
1 files changed, 27 insertions, 26 deletions
diff --git a/lisp/eshell/esh-util.el b/lisp/eshell/esh-util.el index f8dd6f08f45..4835e63baa9 100644 --- a/lisp/eshell/esh-util.el +++ b/lisp/eshell/esh-util.el @@ -232,6 +232,14 @@ It might be different from \(getenv \"PATH\"), when `default-directory' points to a remote host.") (make-variable-buffer-local 'eshell-path-env) +(defun eshell-get-path () + "Return $PATH as a list. +Add the current directory on MS-Windows." + (eshell-parse-colon-path + (if (eshell-under-windows-p) + (concat "." path-separator eshell-path-env) + eshell-path-env))) + (defun eshell-parse-colon-path (path-env) "Split string with `parse-colon-path'. Prepend remote identification of `default-directory', if any." @@ -285,17 +293,9 @@ Prepend remote identification of `default-directory', if any." ,@forms) (setq list-iter (cdr list-iter))))) -(defun eshell-flatten-list (args) - "Flatten any lists within ARGS, so that there are no sublists." - (let ((new-list (list t))) - (dolist (a args) - (if (and (listp a) - (listp (cdr a))) - (nconc new-list (eshell-flatten-list a)) - (nconc new-list (list a)))) - (cdr new-list))) - -(defun eshell-uniqify-list (l) +(define-obsolete-function-alias 'eshell-flatten-list #'flatten-tree "27.1") + +(defun eshell-uniquify-list (l) "Remove occurring multiples in L. You probably want to sort first." (let ((m l)) (while m @@ -305,6 +305,9 @@ Prepend remote identification of `default-directory', if any." (setcdr m (cddr m))) (setq m (cdr m)))) l) +(define-obsolete-function-alias + 'eshell-uniqify-list + 'eshell-uniquify-list "27.1") (defun eshell-stringify (object) "Convert OBJECT into a string value." @@ -327,7 +330,7 @@ Prepend remote identification of `default-directory', if any." (defsubst eshell-flatten-and-stringify (&rest args) "Flatten and stringify all of the ARGS into a single string." - (mapconcat 'eshell-stringify (eshell-flatten-list args) " ")) + (mapconcat 'eshell-stringify (flatten-tree args) " ")) (defsubst eshell-directory-files (regexp &optional directory) "Return a list of files in the given DIRECTORY matching REGEXP." @@ -444,7 +447,7 @@ list." (not (symbol-value timestamp-var)) (time-less-p (symbol-value timestamp-var) - (nth 5 (file-attributes file)))) + (file-attribute-modification-time (file-attributes file)))) (progn (set result-var (eshell-read-passwd-file file)) (set timestamp-var (current-time)))) @@ -483,24 +486,22 @@ list." (insert-file-contents (or filename eshell-hosts-file)) (goto-char (point-min)) (while (re-search-forward - "^\\([^#[:space:]]+\\)\\s-+\\(\\S-+\\)\\(\\s-*\\(\\S-+\\)\\)?" nil t) - (if (match-string 1) - (cl-pushnew (match-string 1) hosts :test #'equal)) - (if (match-string 2) - (cl-pushnew (match-string 2) hosts :test #'equal)) - (if (match-string 4) - (cl-pushnew (match-string 4) hosts :test #'equal)))) - (sort hosts #'string-lessp))) + ;; "^ \t\\([^# \t\n]+\\)[ \t]+\\([^ \t\n]+\\)\\([ \t]*\\([^ \t\n]+\\)\\)?" + "^[ \t]*\\([^# \t\n]+\\)[ \t]+\\([^ \t\n].+\\)" nil t) + (push (cons (match-string 1) + (split-string (match-string 2))) + hosts))) + (nreverse hosts))) (defun eshell-read-hosts (file result-var timestamp-var) - "Read the contents of /etc/passwd for user names." + "Read the contents of /etc/hosts for host names." (if (or (not (symbol-value result-var)) (not (symbol-value timestamp-var)) (time-less-p (symbol-value timestamp-var) - (nth 5 (file-attributes file)))) + (file-attribute-modification-time (file-attributes file)))) (progn - (set result-var (eshell-read-hosts-file file)) + (set result-var (apply #'nconc (eshell-read-hosts-file file))) (set timestamp-var (current-time)))) (symbol-value result-var)) @@ -653,11 +654,11 @@ If NOSORT is non-nil, the list is not sorted--its order is unpredictable. (match-string 6)))) (if (nth 0 moment) (setcar (nthcdr 5 moment) - (nth 5 (decode-time))) + (decoded-time-year (decode-time))) (setcar (nthcdr 0 moment) 0) (setcar (nthcdr 1 moment) 0) (setcar (nthcdr 2 moment) 0)) - (apply 'encode-time moment)) + (encode-time moment)) (ange-ftp-file-modtime (expand-file-name name dir)))) symlink) (if (string-match "\\(.+\\) -> \\(.+\\)" name) |