X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/06bc5dbf8e9e729eeedae6cac07c8f29243b9f2e..0cb9b63a7b9a35168c20862a7c67a1d1e12b0be3:/lisp/emacs-lisp/cl.el diff --git a/lisp/emacs-lisp/cl.el b/lisp/emacs-lisp/cl.el index def4d24188..f2ced20e59 100644 --- a/lisp/emacs-lisp/cl.el +++ b/lisp/emacs-lisp/cl.el @@ -178,7 +178,7 @@ Keywords supported: :test :test-not :key" (defun cl-set-substring (str start end val) (if end (if (< end 0) (incf end (length str))) (setq end (length str))) - (if (< start 0) (incf start str)) + (if (< start 0) (incf start (length str))) (concat (and (> start 0) (substring str 0 start)) val (and (< end (length str)) (substring str end)))) @@ -207,7 +207,7 @@ Keywords supported: :test :test-not :key" "Return multiple values, Common Lisp style. The arguments of `values' are the values that the containing function should return." - (apply 'list values)) + values) (defsubst values-list (list) "Return multiple values, Common Lisp style, taken from a list. @@ -229,6 +229,10 @@ right when EXPRESSION calls an ordinary Emacs Lisp function that returns just one value." (apply function expression)) +(defalias 'multiple-value-call 'apply + "Apply FUNCTION to ARGUMENTS, taking multiple values into account. +This implementation only handles the case where there is only one argument.") + (defsubst nth-value (n expression) "Evaluate EXPRESSION to get multiple values and return the Nth one. This handles multiple values in Common Lisp style, but it does not work @@ -514,6 +518,15 @@ Thus, `(list* A B C D)' is equivalent to `(nconc (list A B C) D)', or to (push (pop list) res)) (nreverse res))) +(defun 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))) + (defun cl-maclisp-member (item list) (while (and list (not (equal item (car list)))) (setq list (cdr list))) list) @@ -665,8 +678,8 @@ Keywords supported: :test :test-not :key" (defun cl-hack-byte-compiler () (if (and (not cl-hacked-flag) (fboundp 'byte-compile-file-form)) (progn - (cl-compile-time-init) ; in cl-macs.el - (setq cl-hacked-flag t)))) + (setq cl-hacked-flag t) ; Do it first, to prevent recursion. + (cl-compile-time-init)))) ; In cl-macs.el. ;;; Try it now in case the compiler has already been loaded. (cl-hack-byte-compiler)