emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 0e4dd67: * lisp/emacs-lisp/seq.el: Don't require cl-lib.


From: Stefan Monnier
Subject: master 0e4dd67: * lisp/emacs-lisp/seq.el: Don't require cl-lib.
Date: Sun, 27 Oct 2019 13:25:05 -0400 (EDT)

branch: master
commit 0e4dd67aae8b10032317a29a6bd99d2d4a64c897
Author: Stefan Monnier <address@hidden>
Commit: Stefan Monnier <address@hidden>

    * lisp/emacs-lisp/seq.el: Don't require cl-lib.
    
    (seq-subseq): Move cl-subseq's code here instyead of calling it.
    * lisp/emacs-lisp/cl-extra.el (cl-subseq): Use seq-subseq.
---
 lisp/emacs-lisp/cl-extra.el | 22 ++--------------------
 lisp/emacs-lisp/seq.el      | 23 +++++++++++++++++++++--
 2 files changed, 23 insertions(+), 22 deletions(-)

diff --git a/lisp/emacs-lisp/cl-extra.el b/lisp/emacs-lisp/cl-extra.el
index 3a6def7..91034de 100644
--- a/lisp/emacs-lisp/cl-extra.el
+++ b/lisp/emacs-lisp/cl-extra.el
@@ -38,6 +38,7 @@
 ;;; Code:
 
 (require 'cl-lib)
+(require 'seq)
 
 ;;; Type coercion.
 
@@ -549,26 +550,7 @@ too large if positive or too small if negative)."
               (macroexp-let2 nil new new
                `(progn (cl-replace ,seq ,new :start1 ,start :end1 ,end)
                        ,new)))))
-  (cond ((or (stringp seq) (vectorp seq)) (substring seq start end))
-        ((listp seq)
-         (let (len
-               (errtext (format "Bad bounding indices: %s, %s" start end)))
-           (and end (< end 0) (setq end (+ end (setq len (length seq)))))
-           (if (< start 0) (setq start (+ start (or len (setq len (length 
seq))))))
-           (unless (>= start 0)
-             (error "%s" errtext))
-           (when (> start 0)
-             (setq seq (nthcdr (1- start) seq))
-             (or seq (error "%s" errtext))
-             (setq seq (cdr seq)))
-           (if end
-               (let ((res nil))
-                 (while (and (>= (setq end (1- end)) start) seq)
-                   (push (pop seq) res))
-                 (or (= (1+ end) start) (error "%s" errtext))
-                 (nreverse res))
-             (copy-sequence seq))))
-        (t (error "Unsupported sequence: %s" seq))))
+  (seq-subseq seq start end))
 
 ;;;###autoload
 (defun cl-concatenate (type &rest sequences)
diff --git a/lisp/emacs-lisp/seq.el b/lisp/emacs-lisp/seq.el
index 918b0dc..9a5872c 100644
--- a/lisp/emacs-lisp/seq.el
+++ b/lisp/emacs-lisp/seq.el
@@ -57,7 +57,6 @@
 ;;; Code:
 
 (eval-when-compile (require 'cl-generic))
-(require 'cl-lib) ;; for cl-subseq
 
 (defmacro seq-doseq (spec &rest body)
   "Loop over a sequence.
@@ -151,7 +150,27 @@ If END is omitted, it defaults to the length of the 
sequence.  If
 START or END is negative, it counts from the end.  Signal an
 error if START or END are outside of the sequence (i.e too large
 if positive or too small if negative)."
-  (cl-subseq sequence start end))
+  (cond
+   ((or (stringp sequence) (vectorp sequence)) (substring sequence start end))
+   ((listp sequence)
+    (let (len
+          (errtext (format "Bad bounding indices: %s, %s" start end)))
+      (and end (< end 0) (setq end (+ end (setq len (length sequence)))))
+      (if (< start 0) (setq start (+ start (or len (setq len (length 
sequence))))))
+      (unless (>= start 0)
+        (error "%s" errtext))
+      (when (> start 0)
+        (setq sequence (nthcdr (1- start) sequence))
+        (or sequence (error "%s" errtext))
+        (setq sequence (cdr sequence)))
+      (if end
+          (let ((res nil))
+            (while (and (>= (setq end (1- end)) start) sequence)
+              (push (pop sequence) res))
+            (or (= (1+ end) start) (error "%s" errtext))
+            (nreverse res))
+        (copy-sequence sequence))))
+   (t (error "Unsupported sequence: %s" sequence))))
 
 
 (cl-defgeneric seq-map (function sequence)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]