]> git.eshelyaron.com Git - emacs.git/commitdiff
Remove local uniquify functions in favour of seq-uniq
authorStefan Kangas <stefan@marxist.se>
Mon, 5 Apr 2021 13:14:19 +0000 (15:14 +0200)
committerStefan Kangas <stefan@marxist.se>
Mon, 5 Apr 2021 13:14:19 +0000 (15:14 +0200)
* lisp/emacs-lisp/seq.el (seq-uniq): Add autoload cookie.
* lisp/pcomplete.el: (pcomplete-uniquify-list): Use seq-uniq.
* lisp/eshell/esh-util.el (eshell-uniqify-list)
(eshell-uniquify-list):
* lisp/nxml/rng-util.el (rng-uniquify-equal):
* lisp/progmodes/idlwave.el (idlwave-uniquify):
* lisp/textmodes/artist.el (artist-uniq): Make into obsolete
function aliases for seq-uniq.  Update callers.
* lisp/nxml/rng-util.el (rng-uniquify-eq): Make obsolete in favor
of seq-uniq.  Update callers.

lisp/emacs-lisp/seq.el
lisp/eshell/em-pred.el
lisp/eshell/esh-util.el
lisp/nxml/rng-loc.el
lisp/nxml/rng-match.el
lisp/nxml/rng-nxml.el
lisp/nxml/rng-util.el
lisp/pcomplete.el
lisp/progmodes/idlwave.el
lisp/textmodes/artist.el

index 7aa5684cfd19e1c79080100038d77ff0013a0074..6c15463ad522f67ed853aa363133dfa642db72a0 100644 (file)
@@ -431,6 +431,7 @@ Equality is defined by TESTFN if non-nil or by `equal' if nil."
         (setq index (1+ index)))
       nil)))
 
+;;;###autoload
 (cl-defgeneric seq-uniq (sequence &optional testfn)
   "Return a list of the elements of SEQUENCE with duplicates removed.
 TESTFN is used to compare elements, or `equal' if TESTFN is nil."
index b0a7544bdab3dd49fbb6058cbe5f12bf3b1f7c6b..0780d6ee83a5a919b5c53583efc49845eeaf7c47 100644 (file)
@@ -130,7 +130,7 @@ The format of each entry is
     (?e . (lambda (lst) (mapcar #'file-name-extension lst)))
     (?t . (lambda (lst) (mapcar #'file-name-nondirectory lst)))
     (?q . (lambda (lst) (mapcar #'eshell-escape-arg lst)))
-    (?u . (lambda (lst) (eshell-uniquify-list lst)))
+    (?u . (lambda (lst) (seq-uniq lst)))
     (?o . (lambda (lst) (sort lst #'string-lessp)))
     (?O . (lambda (lst) (nreverse (sort lst #'string-lessp))))
     (?j . (eshell-join-members))
index 1dcbed3d961b86e3661efdc48c991ffe1ef925c4..a48f62654d5f11b732b056d2cc52fec633caffc1 100644 (file)
@@ -291,20 +291,6 @@ Prepend remote identification of `default-directory', if any."
 
 (define-obsolete-function-alias 'eshell-flatten-list #'flatten-tree "27.1")
 
-(defun eshell-uniquify-list (l)
-  "Remove occurring multiples in L.  You probably want to sort first."
-  (let ((m l))
-    (while m
-      (while (and (cdr m)
-                 (string= (car m)
-                          (cadr m)))
-       (setcdr m (cddr m)))
-      (setq m (cdr m))))
-  l)
-(define-obsolete-function-alias
-  'eshell-uniqify-list
-  'eshell-uniquify-list "27.1")
-
 (defun eshell-stringify (object)
   "Convert OBJECT into a string value."
   (cond
@@ -700,6 +686,8 @@ gid format.  Valid values are `string' and `integer', defaulting to
 
 ;; Obsolete.
 
+(define-obsolete-function-alias 'eshell-uniquify-list #'seq-uniq "28.1")
+(define-obsolete-function-alias 'eshell-uniqify-list #'seq-uniq "28.1")
 (define-obsolete-function-alias 'eshell-copy-tree #'copy-tree "28.1")
 (define-obsolete-function-alias 'eshell-user-name #'user-login-name "28.1")
 
index d5a608d6ff24410c2b1cb0263679aaa922c21523..a38da794226f12d6ca1041a0392d921b7d8d3dee 100644 (file)
@@ -182,7 +182,7 @@ If TYPE-ID is non-nil, then locate the schema for this TYPE-ID."
     (while files
       (setq type-ids (rng-possible-type-ids-using (car files) type-ids))
       (setq files (cdr files)))
-    (rng-uniquify-equal (sort type-ids 'string<))))
+    (seq-uniq (sort type-ids 'string<))))
 
 (defun rng-locate-schema-file-using (files)
   "Locate a schema using the schema locating files FILES.
index 4fc6727d0e6f062ca1190c90a7934dbb5ee3ca3e..7a2739c06162b5705ed9f640c95ecb7fe4661f0f 100644 (file)
@@ -472,7 +472,7 @@ list is nullable and whose cdr is the normalized list."
     (cons nullable
          (if sorted
              head
-           (rng-uniquify-eq (sort head 'rng-compare-ipattern))))))
+            (seq-uniq (sort head 'rng-compare-ipattern) #'eq)))))
 
 (defun rng-compare-ipattern (p1 p2)
   (< (rng--ipattern-index p1)
index 7ea6fb2e49d03c451e90459302602dfeaed57b56..33768a46c94e38ae3718134b4fbc4c2820c97285 100644 (file)
@@ -522,7 +522,7 @@ set `xmltok-dtd'.  Returns the position of the end of the token."
          (unless attribute-flag
            (setcdr ns-prefixes (cons nil (cdr ns-prefixes))))))
       (setq iter (cdr iter)))
-    (rng-uniquify-equal
+    (seq-uniq
      (sort (apply #'append
                  (cons extra-strings
                        (mapcar (lambda (name)
index a20e95086cbeaf8e7ae6563bc7746591afa6e2d0..67e2ee9f1e360919ba6a386d1d006de85f826281 100644 (file)
 
 (defconst rng-builtin-datatypes-uri (rng-make-datatypes-uri ""))
 
-(defun rng-uniquify-eq (list)
-  "Destructively remove `eq' duplicates from LIST."
-  (and list
-       (let ((head list))
-        (while (cdr head)
-          (if (eq (car head) (cadr head))
-              (setcdr head (cddr head)))
-          (setq head (cdr head)))
-        list)))
-
-(defun rng-uniquify-equal (list)
-  "Destructively remove `equal' duplicates from LIST."
-  (and list
-       (let ((head list))
-        (while (cdr head)
-          (if (equal (car head) (cadr head))
-              (setcdr head (cddr head)))
-          (setq head (cdr head)))
-        list)))
-
 (defun rng-blank-p (str) (string-match "\\`[ \t\n\r]*\\'" str))
 
 (defun rng-substq (new old list)
@@ -104,6 +84,14 @@ LIST is not modified."
 
 (define-error 'rng-error nil)
 
+;; Obsolete.
+
+(defun rng-uniquify-eq (list)
+  (declare (obsolete seq-uniq "28.1"))
+  (seq-uniq list #'eq))
+
+(define-obsolete-function-alias 'rng-uniquify-equal #'seq-uniq "28.1")
+
 (provide 'rng-util)
 
 ;;; rng-util.el ends here
index b648ecf09869db5219c80efcebf05cdf5995f95d..bffdcaa2de0d2bc9708a69f6ec26d4740ffa9dc7 100644 (file)
@@ -1260,18 +1260,9 @@ If specific documentation can't be given, be generic."
 
 (defun pcomplete-uniquify-list (l)
   "Sort and remove multiples in L."
-  (setq l (sort l 'string-lessp))
-  (let ((m l))
-    (while m
-      (while (and (cdr m)
-                 (string= (car m)
-                          (cadr m)))
-       (setcdr m (cddr m)))
-      (setq m (cdr m))))
-  l)
-(define-obsolete-function-alias
-  'pcomplete-uniqify-list
-  'pcomplete-uniquify-list "27.1")
+  (setq l (sort l #'string-lessp))
+  (seq-uniq l))
+(define-obsolete-function-alias 'pcomplete-uniqify-list #'pcomplete-uniquify-list "27.1")
 
 (defun pcomplete-process-result (cmd &rest args)
   "Call CMD using `call-process' and return the simplest result."
index f53f3f3b995be464f9a107ff2aba023a6ebbd4f5..75f2016fc24976a39e46d529e7d9907924c0572e 100644 (file)
@@ -7601,15 +7601,6 @@ associated TAG, if any."
           (put-text-property (match-beginning 0) (match-end 0)
                              'face 'font-lock-string-face))))))
 
-(defun idlwave-uniquify (list)
-  (let ((ht (make-hash-table :size (length list) :test 'equal)))
-    (delq nil
-         (mapcar (lambda (x)
-                   (unless (gethash x ht)
-                     (puthash x t ht)
-                     x))
-                 list))))
-
 (defun idlwave-after-successful-completion (type slash &optional verify)
   "Add `=' or `(' after successful completion of keyword and function.
 Restore the pre-completion window configuration if possible."
@@ -9101,6 +9092,9 @@ This function was written since `list-abbrevs' looks terrible for IDLWAVE mode."
 ;; Run the hook
 (run-hooks 'idlwave-load-hook)
 
+;; Obsolete.
+(define-obsolete-function-alias 'idlwave-uniquify #'seq-uniq "28.1")
+
 (provide 'idlwave)
 
 ;;; idlwave.el ends here
index 22ade15921d6eb3640a0c3345025c0fc19d78b19..fbb9d2174fdd48bd804ac3c48414aa969680ca21 100644 (file)
@@ -1753,13 +1753,6 @@ info-variant-part."
   "Call function FN with ARGS, if FN is not nil."
   `(if ,fn (funcall ,fn ,@args)))
 
-(defun artist-uniq (l)
-  "Remove consecutive duplicates in list L.  Comparison is done with `equal'."
-  (cond ((null l) nil)
-       ((null (cdr l)) l)              ; only one element in list
-       ((equal (car l) (car (cdr l))) (artist-uniq (cdr l))) ; first 2 equal
-       (t (cons (car l) (artist-uniq (cdr l)))))) ; first 2 are different
-
 (defun artist-string-split (str r)
   "Split string STR at occurrences of regexp R, returning a list of strings."
   (let ((res nil)
@@ -2761,7 +2754,7 @@ to append to the end of the list, when doing free-hand drawing)."
 Also, the `artist-key-poly-point-list' is reversed."
 
   (setq artist-key-poly-point-list
-       (artist-uniq artist-key-poly-point-list))
+        (seq-uniq artist-key-poly-point-list))
 
   (if (>= (length artist-key-poly-point-list) 2)
 
@@ -5372,10 +5365,7 @@ The event, EV, is the mouse event."
         (concat "Hello Tomas,\n\n"
                 "I have a nice bug report on Artist for you! Here it is:")))))
 
-
-;;
-;; Now provide this minor mode
-;;
+(define-obsolete-function-alias 'artist-uniq #'seq-uniq "28.1")
 
 (provide 'artist)