emacs-diffs
[Top][All Lists]
Advanced

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

master cd5dfa0 2/2: Replace two functions with seq-subseq


From: Stefan Kangas
Subject: master cd5dfa0 2/2: Replace two functions with seq-subseq
Date: Fri, 2 Apr 2021 21:17:17 -0400 (EDT)

branch: master
commit cd5dfa086d204c01791bfdcdf9fe1215c4bf1e42
Author: Stefan Kangas <stefan@marxist.se>
Commit: Stefan Kangas <stefan@marxist.se>

    Replace two functions with seq-subseq
    
    * lisp/emacs-lisp/seq.el (seq-subseq): Add autoload cookie.
    * lisp/eshell/esh-util.el (eshell-sublist): Redefine using seq-subseq
    and make obsolete.  Update callers.
    * lisp/wid-edit.el (widget-sublist): Redefine as obsolete function
    alias for seq-subseq.  Update callers.
---
 lisp/emacs-lisp/seq.el  |  1 +
 lisp/eshell/em-hist.el  |  2 +-
 lisp/eshell/esh-util.el | 20 ++++++++------------
 lisp/wid-edit.el        | 19 +++++--------------
 4 files changed, 15 insertions(+), 27 deletions(-)

diff --git a/lisp/emacs-lisp/seq.el b/lisp/emacs-lisp/seq.el
index 2b8807f..f2f7d67 100644
--- a/lisp/emacs-lisp/seq.el
+++ b/lisp/emacs-lisp/seq.el
@@ -147,6 +147,7 @@ the sequence, and its index within the sequence."
   "Return a shallow copy of SEQUENCE."
   (copy-sequence sequence))
 
+;;;###autoload
 (cl-defgeneric seq-subseq (sequence start &optional end)
   "Return the sequence of elements of SEQUENCE from START to END.
 END is exclusive.
diff --git a/lisp/eshell/em-hist.el b/lisp/eshell/em-hist.el
index b7b1778..e559f5b 100644
--- a/lisp/eshell/em-hist.el
+++ b/lisp/eshell/em-hist.el
@@ -758,7 +758,7 @@ matched."
        (setq nth (eshell-hist-word-reference nth)))
       (unless (numberp mth)
        (setq mth (eshell-hist-word-reference mth)))
-      (cons (mapconcat #'identity (eshell-sublist textargs nth mth) " ")
+      (cons (mapconcat #'identity (seq-subseq textargs nth (1+ mth)) " ")
            end))))
 
 (defun eshell-hist-parse-modifier (hist reference)
diff --git a/lisp/eshell/esh-util.el b/lisp/eshell/esh-util.el
index 8ef1ac9..1dcbed3 100644
--- a/lisp/eshell/esh-util.el
+++ b/lisp/eshell/esh-util.el
@@ -223,18 +223,6 @@ then quoting is done by a backslash, rather than a doubled 
delimiter."
              (string-to-number string)
            string))))))
 
-(defun eshell-sublist (l &optional n m)
-  "Return from LIST the N to M elements.
-If N or M is nil, it means the end of the list."
-  (let ((a (copy-sequence l)))
-    (if (and m (consp (nthcdr m a)))
-       (setcdr (nthcdr m a) nil))
-    (if n
-       (setq a (nthcdr n a))
-      (setq n (1- (length a))
-           a (last a)))
-    a))
-
 (defvar-local eshell-path-env (getenv "PATH")
   "Content of $PATH.
 It might be different from \(getenv \"PATH\"), when
@@ -710,9 +698,17 @@ gid format.  Valid values are `string' and `integer', 
defaulting to
 ;     (or result
 ;      (file-attributes filename))))
 
+;; Obsolete.
+
 (define-obsolete-function-alias 'eshell-copy-tree #'copy-tree "28.1")
 (define-obsolete-function-alias 'eshell-user-name #'user-login-name "28.1")
 
+(defun eshell-sublist (l &optional n m)
+  "Return from LIST the N to M elements.
+If N or M is nil, it means the end of the list."
+  (declare (obsolete seq-subseq "28.1"))
+  (seq-subseq l n (1+ m)))
+
 (provide 'esh-util)
 
 ;;; esh-util.el ends here
diff --git a/lisp/wid-edit.el b/lisp/wid-edit.el
index e71290c..51c6b49 100644
--- a/lisp/wid-edit.el
+++ b/lisp/wid-edit.el
@@ -1878,20 +1878,9 @@ as the argument to `documentation-property'."
   (let ((value (widget-get widget :value)))
     (and (listp value)
         (<= (length value) (length vals))
-        (let ((head (widget-sublist vals 0 (length value))))
+         (let ((head (seq-subseq vals 0 (length value))))
           (and (equal head value)
-               (cons head (widget-sublist vals (length value))))))))
-
-(defun widget-sublist (list start &optional end)
-  "Return the sublist of LIST from START to END.
-If END is omitted, it defaults to the length of LIST."
-  (if (> start 0) (setq list (nthcdr start list)))
-  (if end
-      (unless (<= end start)
-       (setq list (copy-sequence list))
-       (setcdr (nthcdr (- end start 1) list) nil)
-       list)
-    (copy-sequence list)))
+                (cons head (seq-subseq vals (length value))))))))
 
 (defun widget-item-action (widget &optional event)
   ;; Just notify itself.
@@ -4117,7 +4106,9 @@ is inline."
        (setq help-echo (funcall help-echo widget)))
     (if help-echo (message "%s" (eval help-echo)))))
 
-;;; The End:
+;;; Obsolete.
+
+(define-obsolete-function-alias 'widget-sublist #'seq-subseq "28.1")
 
 (provide 'wid-edit)
 



reply via email to

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