From: Eric Abrahamsen <eric@ericabrahamsen.net>
To: 29489@debbugs.gnu.org
Subject: bug#29489: Obsolete gnus-remove-if and gnus-remove-if-not
Date: Tue, 28 Nov 2017 09:02:49 -0800 [thread overview]
Message-ID: <87o9nmgwue.fsf@ericabrahamsen.net> (raw)
[-- Attachment #1: Type: text/plain, Size: 348 bytes --]
Here's another one of these.
I've replaced these with `seq-remove' and `seq-filter', and I suppose
someone might object to that -- the other option would be `cl-remove-if'
and `cl-remove-if-not'. I don't believe there's much practical difference.
Gnus v5.13
GNU Emacs 27.0.50 (build 13, x86_64-pc-linux-gnu, GTK+ Version 3.22.26)
of 2017-11-27
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Obsolete-gnus-remove-if-and-gnus-remove-if-not.patch --]
[-- Type: text/x-diff, Size: 9083 bytes --]
From 39b8e2bf7371df930081642b5127db268fcf4d46 Mon Sep 17 00:00:00 2001
From: Eric Abrahamsen <eric@ericabrahamsen.net>
Date: Sat, 25 Nov 2017 18:42:55 -0800
Subject: [PATCH] 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 | 4 ++--
lisp/gnus/gnus-topic.el | 4 ++--
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 +-
| 2 +-
11 files changed, 16 insertions(+), 47 deletions(-)
diff --git a/lisp/gnus/gnus-art.el b/lisp/gnus/gnus-art.el
index 97aa878ab6..6ee0d7b023 100644
--- a/lisp/gnus/gnus-art.el
+++ b/lisp/gnus/gnus-art.el
@@ -5219,7 +5219,7 @@ gnus-mime-view-part-as-type
(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 cca4a81d1c..38c3ea36d6 100644
--- a/lisp/gnus/gnus-icalendar.el
+++ b/lisp/gnus/gnus-icalendar.el
@@ -169,7 +169,7 @@ gnus-icalendar-event--find-attendee
(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 @@ gnus-icalendar-event--get-attendee-names
(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 765dfab570..a2cc07db46 100644
--- a/lisp/gnus/gnus-score.el
+++ b/lisp/gnus/gnus-score.el
@@ -921,7 +921,7 @@ gnus-summary-score-effect
(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 e599a8460f..dfecd2713d 100644
--- a/lisp/gnus/gnus-sum.el
+++ b/lisp/gnus/gnus-sum.el
@@ -12275,12 +12275,12 @@ gnus-read-move-group-name
((null split-name)
(gnus-group-completing-read
prom
- (gnus-remove-if-not 'gnus-valid-move-group-p gnus-active-hashtb t)
+ (seq-filter 'gnus-valid-move-group-p gnus-active-hashtb)
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)
+ (seq-filter 'gnus-valid-move-group-p gnus-active-hashtb)
nil prefix 'gnus-group-history (car split-name)))
(t
(gnus-completing-read
diff --git a/lisp/gnus/gnus-topic.el b/lisp/gnus/gnus-topic.el
index ba756e0314..065215b471 100644
--- a/lisp/gnus/gnus-topic.el
+++ b/lisp/gnus/gnus-topic.el
@@ -460,9 +460,9 @@ gnus-group-prepare-topics
(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)))
+ (gethash group gnus-killed-hashtb)))
not-in-list)
gnus-level-killed ?K regexp)))
diff --git a/lisp/gnus/gnus-util.el b/lisp/gnus/gnus-util.el
index b7477a7fa8..ed112273ca 100644
--- a/lisp/gnus/gnus-util.el
+++ b/lisp/gnus/gnus-util.el
@@ -1117,41 +1117,9 @@ gnus-alive-p
(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 8e47ae3f98..4f720463b4 100644
--- a/lisp/gnus/gnus-win.el
+++ b/lisp/gnus/gnus-win.el
@@ -513,7 +513,7 @@ gnus-get-buffer-window
(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 3458fdea71..597470c381 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 ad58d29208..5ed80a9bb6 100644
--- a/lisp/gnus/nnmail.el
+++ b/lisp/gnus/nnmail.el
@@ -2034,7 +2034,7 @@ nnmail-purge-split-history
"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 708a3426af..3e4a87cee7 100644
--- a/lisp/gnus/nnmaildir.el
+++ b/lisp/gnus/nnmaildir.el
@@ -915,7 +915,7 @@ nnmaildir-request-scan
(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
--git a/lisp/gnus/nnrss.el b/lisp/gnus/nnrss.el
index 9a3a562a5d..aa19c376d1 100644
--- a/lisp/gnus/nnrss.el
+++ b/lisp/gnus/nnrss.el
@@ -625,7 +625,7 @@ nnrss-mime-encode-string
;;; 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)))
--
2.15.0
next reply other threads:[~2017-11-28 17:02 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-28 17:02 Eric Abrahamsen [this message]
2017-11-28 17:23 ` bug#29489: Obsolete gnus-remove-if and gnus-remove-if-not John Wiegley
2017-11-28 18:01 ` Eric Abrahamsen
2017-11-28 23:44 ` Noam Postavsky
2017-11-29 0:07 ` Eric Abrahamsen
2017-11-29 0:40 ` Noam Postavsky
2017-11-29 1:42 ` Eric Abrahamsen
2017-11-29 2:36 ` Noam Postavsky
2017-11-29 3:31 ` Eric Abrahamsen
2017-11-30 18:29 ` Eric Abrahamsen
2017-12-02 2:38 ` Noam Postavsky
2017-12-02 18:50 ` Eric Abrahamsen
2017-12-02 18:54 ` Noam Postavsky
2017-12-02 18:53 ` Eric Abrahamsen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87o9nmgwue.fsf@ericabrahamsen.net \
--to=eric@ericabrahamsen.net \
--cc=29489@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).