diff options
| author | Stefan Kangas <stefan@marxist.se> | 2021-04-03 01:21:32 +0200 |
|---|---|---|
| committer | Stefan Kangas <stefan@marxist.se> | 2021-04-03 03:11:35 +0200 |
| commit | cd5dfa086d204c01791bfdcdf9fe1215c4bf1e42 (patch) | |
| tree | b87b59c29cc57b6d19048ba60e8e5b1356eacc38 | |
| parent | be9e3c48fab335c9084e472acef2065f41d20969 (diff) | |
| download | emacs-cd5dfa086d204c01791bfdcdf9fe1215c4bf1e42.tar.gz | |
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.
| -rw-r--r-- | lisp/emacs-lisp/seq.el | 1 | ||||
| -rw-r--r-- | lisp/eshell/em-hist.el | 2 | ||||
| -rw-r--r-- | lisp/eshell/esh-util.el | 20 | ||||
| -rw-r--r-- | 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 2b8807faad5..f2f7d677e88 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 b7b1778ebb1..e559f5b39fe 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 8ef1ac9c345..1dcbed3d961 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 e71290c7ef9..51c6b49e6df 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) |
