Make viper-subseq into obsolete alias for cl-subseq

* lisp/emulation/viper-util.el (viper-subseq): Make into obsolete
function alias for 'cl-subseq'.  Update callers.
This commit is contained in:
Stefan Kangas 2021-09-17 11:39:47 +02:00
parent cfa1e0a11b
commit a1b2ec6e06
2 changed files with 7 additions and 32 deletions

View file

@ -230,9 +230,9 @@ a key is a symbol, e.g., `a', `\\1', `f2', etc., or a list, e.g.,
(cond ((member
key
'(?\b ?\d '^? '^H (control h) (control \?) backspace delete))
(setq key-seq (viper-subseq key-seq 0 (- (length key-seq) 2))))
(setq key-seq (cl-subseq key-seq 0 (- (length key-seq) 2))))
((member key '(tab (control i) ?\t))
(setq key-seq (viper-subseq key-seq 0 (1- (length key-seq))))
(setq key-seq (cl-subseq key-seq 0 (1- (length key-seq))))
(setq message
(format
":unmap%s %s"
@ -611,7 +611,7 @@ mistakes in macro names to be passed to this function is to use
(if (null macro-alist-elt)
(setq macro-alist-elt (car next-best-match)
unmatched-suffix (viper-subseq event-seq (cdr next-best-match))))
unmatched-suffix (cl-subseq event-seq (cdr next-best-match))))
(cond ((null macro-alist-elt))
((setq macro-body (viper-kbd-buf-definition macro-alist-elt)))
@ -693,7 +693,7 @@ mistakes in macro names to be passed to this function is to use
(let ((len1 (length seq1))
(len2 (length seq2)))
(if (<= len1 len2)
(equal seq1 (viper-subseq seq2 0 len1)))))
(equal seq1 (cl-subseq seq2 0 len1)))))
;; find the longest common prefix
(defun viper-common-seq-prefix (&rest seqs)
@ -757,7 +757,7 @@ mistakes in macro names to be passed to this function is to use
(setq macro-def (car lis)
def-len (length (car macro-def)))
(if (and (>= str-len def-len)
(equal (car macro-def) (viper-subseq str 0 def-len)))
(equal (car macro-def) (cl-subseq str 0 def-len)))
(if (or (viper-kbd-buf-definition macro-def)
(viper-kbd-mode-definition macro-def)
(viper-kbd-global-definition macro-def))

View file

@ -927,7 +927,7 @@ Otherwise return the normal value."
(t key)))
((listp key)
(setq modifiers (viper-subseq key 0 (1- (length key)))
(setq modifiers (cl-subseq key 0 (1- (length key)))
base-key (viper-seq-last-elt key)
base-key-name (symbol-name base-key)
char-p (= (length base-key-name) 1))
@ -1345,32 +1345,7 @@ This option is appropriate if you like Emacs-style words."
(not (eq (get-char-property (point) 'field)
(get-char-property (1- (point)) 'field)))))
;; this is copied from cl-extra.el
;; Return the subsequence of SEQ from START to END.
;; If END is omitted, it defaults to the length of the sequence.
;; If START or END is negative, it counts from the end.
(defun viper-subseq (seq start &optional end)
(if (stringp seq) (substring seq start end)
(let (len)
(and end (< end 0) (setq end (+ end (setq len (length seq)))))
(if (< start 0) (setq start (+ start (or len (setq len (length seq))))))
(cond ((listp seq)
(if (> start 0) (setq seq (nthcdr start seq)))
(if end
(let ((res nil))
(while (>= (setq end (1- end)) start)
(push (pop seq) res))
(nreverse res))
(copy-sequence seq)))
(t
(or end (setq end (or len (length seq))))
(let ((res (make-vector (max (- end start) 0) nil))
(i 0))
(while (< start end)
(aset res i (aref seq start))
(setq i (1+ i) start (1+ start)))
res))))))
(define-obsolete-function-alias 'viper-subseq #'cl-subseq "28.1")
(provide 'viper-util)
;;; viper-util.el ends here