(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))))
"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.
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
(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)
(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)