diff options
| author | Richard M. Stallman | 2002-06-10 09:01:08 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2002-06-10 09:01:08 +0000 |
| commit | cfebd4db43b449b6bee133066de78346151a7e5c (patch) | |
| tree | d9c1c6ac6003ef55956e2f0ffe9e0baaed2e35d4 /lisp | |
| parent | 6b25a2f544161b04915807a873af060fcb6bdc49 (diff) | |
| download | emacs-cfebd4db43b449b6bee133066de78346151a7e5c.tar.gz emacs-cfebd4db43b449b6bee133066de78346151a7e5c.zip | |
(copy-list): Moved to cl.el.
(copy-tree): Don't use copy-list or cl-pop.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/subr.el | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/lisp/subr.el b/lisp/subr.el index 7b613b42e63..b565d8ef7c9 100644 --- a/lisp/subr.el +++ b/lisp/subr.el | |||
| @@ -191,32 +191,26 @@ The comparison is done with `eq'." | |||
| 191 | (delq elt (copy-sequence list)) | 191 | (delq elt (copy-sequence list)) |
| 192 | list)) | 192 | list)) |
| 193 | 193 | ||
| 194 | (defun copy-list (list) | ||
| 195 | "Return a copy of a list, which may be a dotted list. | ||
| 196 | The elements of the list are not copied, just the list structure itself." | ||
| 197 | (if (consp list) | ||
| 198 | (let ((res nil)) | ||
| 199 | (while (consp list) (push (pop list) res)) | ||
| 200 | (prog1 (nreverse res) (setcdr res list))) | ||
| 201 | (car list))) | ||
| 202 | |||
| 203 | (defun copy-tree (tree &optional vecp) | 194 | (defun copy-tree (tree &optional vecp) |
| 204 | "Make a copy of TREE. | 195 | "Make a copy of TREE. |
| 205 | If TREE is a cons cell, this recursively copies both its car and its cdr. | 196 | If TREE is a cons cell, this recursively copies both its car and its cdr. |
| 206 | Contrast to copy-sequence, which copies only along the cdrs. With second | 197 | Contrast to `copy-sequence', which copies only along the cdrs. With second |
| 207 | argument VECP, this copies vectors as well as conses." | 198 | argument VECP, this copies vectors as well as conses." |
| 208 | (if (consp tree) | 199 | (if (consp tree) |
| 209 | (let ((p (setq tree (copy-list tree)))) | 200 | (let (result) |
| 210 | (while (consp p) | 201 | (while (consp tree) |
| 211 | (if (or (consp (car p)) (and vecp (vectorp (car p)))) | 202 | (let ((newcar (car tree))) |
| 212 | (setcar p (copy-tree (car p) vecp))) | 203 | (if (or (consp (car tree)) (and vecp (vectorp (car tree)))) |
| 213 | (or (listp (cdr p)) (setcdr p (copy-tree (cdr p) vecp))) | 204 | (setq newcar (copy-tree (car tree) vecp))) |
| 214 | (cl-pop p))) | 205 | (push newcar result)) |
| 206 | (setq tree (cdr tree))) | ||
| 207 | (nreconc result tree)) | ||
| 215 | (if (and vecp (vectorp tree)) | 208 | (if (and vecp (vectorp tree)) |
| 216 | (let ((i (length (setq tree (copy-sequence tree))))) | 209 | (let ((i (length (setq tree (copy-sequence tree))))) |
| 217 | (while (>= (setq i (1- i)) 0) | 210 | (while (>= (setq i (1- i)) 0) |
| 218 | (aset tree i (copy-tree (aref tree i) vecp)))))) | 211 | (aset tree i (copy-tree (aref tree i) vecp))) |
| 219 | tree) | 212 | tree) |
| 213 | tree))) | ||
| 220 | 214 | ||
| 221 | (defun assoc-default (key alist &optional test default) | 215 | (defun assoc-default (key alist &optional test default) |
| 222 | "Find object KEY in a pseudo-alist ALIST. | 216 | "Find object KEY in a pseudo-alist ALIST. |