1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-15 10:30:25 -08:00

Fix cl-subseq and cl-concatenate

* lisp/emacs-lisp/cl-extra.el (cl-subseq, cl-concatenate): Do not use
seq functions.
* lisp/emacs-lisp/seq.el (seq-concatenate): Call cl-concatenate in
seq-concatenate.
This commit is contained in:
Nicolas Petton 2015-08-24 10:12:31 +02:00
parent 24c61cab07
commit 291593a057
2 changed files with 11 additions and 11 deletions

View file

@ -529,8 +529,8 @@ too large if positive or too small if negative)."
((listp seq) ((listp seq)
(let (len (let (len
(errtext (format "Bad bounding indices: %s, %s" start end))) (errtext (format "Bad bounding indices: %s, %s" start end)))
(and end (< end 0) (setq end (+ end (setq len (seq-length seq))))) (and end (< end 0) (setq end (+ end (setq len (length seq)))))
(if (< start 0) (setq start (+ start (or len (setq len (seq-length seq)))))) (if (< start 0) (setq start (+ start (or len (setq len (length seq))))))
(unless (>= start 0) (unless (>= start 0)
(error "%s" errtext)) (error "%s" errtext))
(when (> start 0) (when (> start 0)
@ -543,14 +543,18 @@ too large if positive or too small if negative)."
(push (pop seq) res)) (push (pop seq) res))
(or (= (1+ end) start) (error "%s" errtext)) (or (= (1+ end) start) (error "%s" errtext))
(nreverse res)) (nreverse res))
(seq-copy seq)))) (copy-sequence seq))))
(t (error "Unsupported sequence: %s" seq)))) (t (error "Unsupported sequence: %s" seq))))
;;;###autoload ;;;###autoload
(defalias 'cl-concatenate #'seq-concatenate (defun cl-concatenate (type &rest sequences)
"Concatenate, into a sequence of type TYPE, the argument SEQUENCEs. "Concatenate, into a sequence of type TYPE, the argument SEQUENCEs.
\n(fn TYPE SEQUENCE...)") \n(fn TYPE SEQUENCE...)"
(pcase type
(`vector (apply #'vconcat sequences))
(`string (apply #'concat sequences))
(`list (apply #'append (append sequences '(nil))))
(_ (error "Not a sequence type name: %S" type))))
;;; List functions. ;;; List functions.

View file

@ -200,11 +200,7 @@ The result is a sequence of the same type as SEQ."
TYPE must be one of following symbols: vector, string or list. TYPE must be one of following symbols: vector, string or list.
\n(fn TYPE SEQUENCE...)" \n(fn TYPE SEQUENCE...)"
(pcase type (apply #'cl-concatenate type seqs))
(`vector (apply #'vconcat seqs))
(`string (apply #'concat seqs))
(`list (apply #'append (append seqs '(nil))))
(_ (error "Not a sequence type name: %S" type))))
(cl-defgeneric seq-into (seq type) (cl-defgeneric seq-into (seq type)
"Convert the sequence SEQ into a sequence of type TYPE. "Convert the sequence SEQ into a sequence of type TYPE.