emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master 7869072: Obsolete gnus-remove-if and gnus-remove-if


From: Eric Abrahamsen
Subject: [Emacs-diffs] master 7869072: Obsolete gnus-remove-if and gnus-remove-if-not
Date: Sun, 10 Dec 2017 12:50:37 -0500 (EST)

branch: master
commit 786907238bcb86ab9e0e2e9ebcc91c52a6eb024c
Author: Eric Abrahamsen <address@hidden>
Commit: Eric Abrahamsen <address@hidden>

    Obsolete gnus-remove-if and gnus-remove-if-not
    
    Use seq-remove and seq-filter, respectively, instead.
    
    * lisp/gnus/gnus-util.el: Remove functions and replace with
      define-obsolete-function-alias calls.
    * lisp/gnus/gnus.el: Require seq here.
    * lisp/gnus/gnus-art.el (gnus-mime-view-part-as-type):
    * lisp/gnus/gnus-icalendar.el (gnus-icalendar-event--get-attendee-names):
    * lisp/gnus/gnus-score.el (gnus-summary-score-effect):
    * lisp/gnus/gnus-sum.el (gnus-read-move-group-name):
    * lisp/gnus/gnus-topic.el (gnus-group-prepare-topics):
    * lisp/gnus/gnus-win.el (gnus-get-buffer-window):
    * lisp/gnus/nnmail.el (nnmail-purge-split-history):
    * lisp/gnus/nnmaildir.el (nnmaildir-request-scan):
    * lisp/gnus/nnrss.el (nnrss-make-hash-index): Replace calls in all
      these locations.
---
 lisp/gnus/gnus-art.el       |  2 +-
 lisp/gnus/gnus-icalendar.el |  4 ++--
 lisp/gnus/gnus-score.el     |  2 +-
 lisp/gnus/gnus-sum.el       | 34 ++++++++++++++++++++--------------
 lisp/gnus/gnus-topic.el     |  2 +-
 lisp/gnus/gnus-util.el      | 38 +++-----------------------------------
 lisp/gnus/gnus-win.el       |  2 +-
 lisp/gnus/gnus.el           |  1 +
 lisp/gnus/nnmail.el         |  2 +-
 lisp/gnus/nnmaildir.el      |  2 +-
 lisp/gnus/nnrss.el          |  2 +-
 11 files changed, 33 insertions(+), 58 deletions(-)

diff --git a/lisp/gnus/gnus-art.el b/lisp/gnus/gnus-art.el
index 97aa878..6ee0d7b 100644
--- a/lisp/gnus/gnus-art.el
+++ b/lisp/gnus/gnus-art.el
@@ -5219,7 +5219,7 @@ available media-types."
            (gnus-completing-read
             "View as MIME type"
             (if pred
-                (gnus-remove-if-not pred (mailcap-mime-types))
+                (seq-filter pred (mailcap-mime-types))
               (mailcap-mime-types))
             nil nil nil
             (car default)))))
diff --git a/lisp/gnus/gnus-icalendar.el b/lisp/gnus/gnus-icalendar.el
index cca4a81..38c3ea3 100644
--- a/lisp/gnus/gnus-icalendar.el
+++ b/lisp/gnus/gnus-icalendar.el
@@ -169,7 +169,7 @@
 
 (defun gnus-icalendar-event--get-attendee-names (ical)
   (let* ((event (car (icalendar--all-events ical)))
-         (attendee-props (gnus-remove-if-not
+         (attendee-props (seq-filter
                           (lambda (p) (eq (car p) 'ATTENDEE))
                           (caddr event))))
 
@@ -180,7 +180,7 @@
          (or (plist-get (cadr prop) 'CN)
              (replace-regexp-in-string "^.*MAILTO:" "" (caddr prop))))
         (attendees-by-type (type)
-                           (gnus-remove-if-not
+                           (seq-filter
                             (lambda (p) (string= (attendee-role p) type))
                             attendee-props))
         (attendee-names-by-type
diff --git a/lisp/gnus/gnus-score.el b/lisp/gnus/gnus-score.el
index 765dfab..a2cc07d 100644
--- a/lisp/gnus/gnus-score.el
+++ b/lisp/gnus/gnus-score.el
@@ -921,7 +921,7 @@ EXTRA is the possible non-standard header."
   (interactive (list (gnus-completing-read "Header"
                                            (mapcar
                                             'car
-                                            (gnus-remove-if-not
+                                            (seq-filter
                                              (lambda (x) (fboundp (nth 2 x)))
                                              gnus-header-index))
                                            t)
diff --git a/lisp/gnus/gnus-sum.el b/lisp/gnus/gnus-sum.el
index e599a84..4dee306 100644
--- a/lisp/gnus/gnus-sum.el
+++ b/lisp/gnus/gnus-sum.el
@@ -12270,21 +12270,27 @@ save those articles instead."
                  (if (> (length articles) 1)
                      (format "these %d articles" (length articles))
                    "this article")))
+        valid-names
         (to-newsgroup
-          (cond
-           ((null split-name)
-            (gnus-group-completing-read
-             prom
-             (gnus-remove-if-not 'gnus-valid-move-group-p gnus-active-hashtb t)
-             nil prefix nil default))
-           ((= 1 (length split-name))
-            (gnus-group-completing-read
-             prom
-            (gnus-remove-if-not 'gnus-valid-move-group-p gnus-active-hashtb t)
-             nil prefix 'gnus-group-history (car split-name)))
-           (t
-            (gnus-completing-read
-             prom (nreverse split-name) nil nil 'gnus-group-history))))
+         (progn
+           (mapatoms (lambda (g)
+                       (when (gnus-valid-move-group-p g)
+                         (push g valid-names)))
+                     gnus-active-hashtb)
+            (cond
+             ((null split-name)
+              (gnus-group-completing-read
+               prom
+               valid-names
+               nil prefix nil default))
+             ((= 1 (length split-name))
+              (gnus-group-completing-read
+               prom
+              valid-names
+               nil prefix 'gnus-group-history (car split-name)))
+             (t
+              (gnus-completing-read
+               prom (nreverse split-name) nil nil 'gnus-group-history)))))
          (to-method (gnus-server-to-method (gnus-group-method to-newsgroup)))
         encoded)
     (when to-newsgroup
diff --git a/lisp/gnus/gnus-topic.el b/lisp/gnus/gnus-topic.el
index ba756e0..3a37366 100644
--- a/lisp/gnus/gnus-topic.el
+++ b/lisp/gnus/gnus-topic.el
@@ -460,7 +460,7 @@ If LOWEST is non-nil, list all newsgroups of level LOWEST 
or higher."
        (unless gnus-killed-hashtb
          (gnus-make-hashtable-from-killed))
        (gnus-group-prepare-flat-list-dead
-        (gnus-remove-if (lambda (group)
+        (seq-remove (lambda (group)
                           (or (gnus-group-entry group)
                               (gnus-gethash group gnus-killed-hashtb)))
                         not-in-list)
diff --git a/lisp/gnus/gnus-util.el b/lisp/gnus/gnus-util.el
index b7477a7..ed11227 100644
--- a/lisp/gnus/gnus-util.el
+++ b/lisp/gnus/gnus-util.el
@@ -1117,41 +1117,9 @@ ARG is passed to the first function."
        (with-current-buffer gnus-group-buffer
         (eq major-mode 'gnus-group-mode))))
 
-(defun gnus-remove-if (predicate sequence &optional hash-table-p)
-  "Return a copy of SEQUENCE with all items satisfying PREDICATE removed.
-SEQUENCE should be a list, a vector, or a string.  Returns always a list.
-If HASH-TABLE-P is non-nil, regards SEQUENCE as a hash table."
-  (let (out)
-    (if hash-table-p
-       (mapatoms (lambda (symbol)
-                   (unless (funcall predicate symbol)
-                     (push symbol out)))
-                 sequence)
-      (unless (listp sequence)
-       (setq sequence (append sequence nil)))
-      (while sequence
-       (unless (funcall predicate (car sequence))
-         (push (car sequence) out))
-       (setq sequence (cdr sequence))))
-    (nreverse out)))
-
-(defun gnus-remove-if-not (predicate sequence &optional hash-table-p)
-  "Return a copy of SEQUENCE with all items not satisfying PREDICATE removed.
-SEQUENCE should be a list, a vector, or a string.  Returns always a list.
-If HASH-TABLE-P is non-nil, regards SEQUENCE as a hash table."
-  (let (out)
-    (if hash-table-p
-       (mapatoms (lambda (symbol)
-                   (when (funcall predicate symbol)
-                     (push symbol out)))
-                 sequence)
-      (unless (listp sequence)
-       (setq sequence (append sequence nil)))
-      (while sequence
-       (when (funcall predicate (car sequence))
-         (push (car sequence) out))
-       (setq sequence (cdr sequence))))
-    (nreverse out)))
+(define-obsolete-function-alias 'gnus-remove-if 'seq-remove "27.1")
+
+(define-obsolete-function-alias 'gnus-remove-if-not 'seq-filter "27.1")
 
 (defun gnus-grep-in-list (word list)
   "Find if a WORD matches any regular expression in the given LIST."
diff --git a/lisp/gnus/gnus-win.el b/lisp/gnus/gnus-win.el
index 8e47ae3..4f72046 100644
--- a/lisp/gnus/gnus-win.el
+++ b/lisp/gnus/gnus-win.el
@@ -513,7 +513,7 @@ should have point."
              (memq frame '(t 0 visible)))
         (car
          (let ((frames (frames-on-display-list)))
-           (gnus-remove-if (lambda (win) (not (memq (window-frame win)
+           (seq-remove (lambda (win) (not (memq (window-frame win)
                                                     frames)))
                            (get-buffer-window-list buffer nil frame)))))
        (t
diff --git a/lisp/gnus/gnus.el b/lisp/gnus/gnus.el
index 3458fde..597470c 100644
--- a/lisp/gnus/gnus.el
+++ b/lisp/gnus/gnus.el
@@ -33,6 +33,7 @@
 (require 'wid-edit)
 (require 'mm-util)
 (require 'nnheader)
+(require 'seq)
 
 ;; These are defined afterwards with gnus-define-group-parameter
 (defvar gnus-ham-process-destinations)
diff --git a/lisp/gnus/nnmail.el b/lisp/gnus/nnmail.el
index ad58d29..5ed80a9 100644
--- a/lisp/gnus/nnmail.el
+++ b/lisp/gnus/nnmail.el
@@ -2034,7 +2034,7 @@ If TIME is nil, then return the cutoff time for oldness 
instead."
   "Remove all instances of GROUP from `nnmail-split-history'."
   (let ((history nnmail-split-history))
     (while history
-      (setcar history (gnus-remove-if (lambda (e) (string= (car e) group))
+      (setcar history (seq-remove (lambda (e) (string= (car e) group))
                                      (car history)))
       (pop history))
     (setq nnmail-split-history (delq nil nnmail-split-history))))
diff --git a/lisp/gnus/nnmaildir.el b/lisp/gnus/nnmaildir.el
index 708a342..3e4a87c 100644
--- a/lisp/gnus/nnmaildir.el
+++ b/lisp/gnus/nnmaildir.el
@@ -915,7 +915,7 @@ This variable is set by `nnmaildir-request-article'.")
            (setq dirs (funcall srv-ls srv-dir nil "\\`[^.]" 'nosort)
                  dirs (if (zerop (length target-prefix))
                           dirs
-                        (gnus-remove-if
+                        (seq-remove
                          (lambda (dir)
                            (and (>= (length dir) (length target-prefix))
                                 (string= (substring dir 0
diff --git a/lisp/gnus/nnrss.el b/lisp/gnus/nnrss.el
index 9a3a562..aa19c37 100644
--- a/lisp/gnus/nnrss.el
+++ b/lisp/gnus/nnrss.el
@@ -625,7 +625,7 @@ which RSS 2.0 allows."
 ;;; Snarf functions
 (defun nnrss-make-hash-index (item)
   (gnus-message 9 "nnrss: Making hash index of %s" (gnus-prin1-to-string item))
-  (setq item (gnus-remove-if
+  (setq item (seq-remove
              (lambda (field)
                (when (listp field)
                  (memq (car field) nnrss-ignore-article-fields)))



reply via email to

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