236 |
(defun eshell-sublist (l &optional n m) |
(defun eshell-sublist (l &optional n m) |
237 |
"Return from LIST the N to M elements. |
"Return from LIST the N to M elements. |
238 |
If N or M is nil, it means the end of the list." |
If N or M is nil, it means the end of the list." |
239 |
(let* ((a (eshell-copy-list l)) |
(let* ((a (copy-sequence l)) |
240 |
result) |
result) |
241 |
(if (and m (consp (nthcdr m a))) |
(if (and m (consp (nthcdr m a))) |
242 |
(setcdr (nthcdr m a) nil)) |
(setcdr (nthcdr m a) nil)) |
710 |
(setq entry nil))))))) |
(setq entry nil))))))) |
711 |
(or entry (funcall handler 'file-attributes file))))) |
(or entry (funcall handler 'file-attributes file))))) |
712 |
|
|
|
(defun eshell-copy-list (list) |
|
|
"Return a copy of a list, which may be a dotted list. |
|
|
The elements of the list are not copied, just the list structure itself." |
|
|
(if (consp list) |
|
|
(let ((res nil)) |
|
|
(while (consp list) (push (pop list) res)) |
|
|
(prog1 (nreverse res) (setcdr res list))) |
|
|
(car list))) |
|
|
|
|
713 |
(defun eshell-copy-tree (tree &optional vecp) |
(defun eshell-copy-tree (tree &optional vecp) |
714 |
"Make a copy of TREE. |
"Make a copy of TREE. |
715 |
If TREE is a cons cell, this recursively copies both its car and its cdr. |
If TREE is a cons cell, this recursively copies both its car and its cdr. |
716 |
Contrast to copy-sequence, which copies only along the cdrs. With second |
Contrast to copy-sequence, which copies only along the cdrs. With second |
717 |
argument VECP, this copies vectors as well as conses." |
argument VECP, this copies vectors as well as conses." |
718 |
(if (consp tree) |
(if (consp tree) |
719 |
(let ((p (setq tree (eshell-copy-list tree)))) |
(let ((p (setq tree (copy-sequence tree)))) |
720 |
(while (consp p) |
(while (consp p) |
721 |
(if (or (consp (car p)) (and vecp (vectorp (car p)))) |
(if (or (consp (car p)) (and vecp (vectorp (car p)))) |
722 |
(setcar p (eshell-copy-tree (car p) vecp))) |
(setcar p (eshell-copy-tree (car p) vecp))) |