unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#29489: Obsolete gnus-remove-if and gnus-remove-if-not
@ 2017-11-28 17:02 Eric Abrahamsen
  2017-11-28 17:23 ` John Wiegley
  2017-11-28 23:44 ` Noam Postavsky
  0 siblings, 2 replies; 14+ messages in thread
From: Eric Abrahamsen @ 2017-11-28 17:02 UTC (permalink / raw)
  To: 29489

[-- 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 +-
 lisp/gnus/nnrss.el          |  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
diff --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


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* bug#29489: Obsolete gnus-remove-if and gnus-remove-if-not
  2017-11-28 17:02 bug#29489: Obsolete gnus-remove-if and gnus-remove-if-not Eric Abrahamsen
@ 2017-11-28 17:23 ` John Wiegley
  2017-11-28 18:01   ` Eric Abrahamsen
  2017-11-28 23:44 ` Noam Postavsky
  1 sibling, 1 reply; 14+ messages in thread
From: John Wiegley @ 2017-11-28 17:23 UTC (permalink / raw)
  To: Eric Abrahamsen; +Cc: 29489

>>>>> "EA" == Eric Abrahamsen <eric@ericabrahamsen.net> writes:

EA> I've replaced these with `seq-remove' and `seq-filter', and I suppose
EA> someone might object to that -- the other option would be `cl-remove-if'
EA> and `cl-remove-if-not'. I don't believe there's much practical difference.

I have no objection to using seq over its cl- equivalents.

-- 
John Wiegley                  GPG fingerprint = 4710 CF98 AF9B 327B B80F
http://newartisans.com                          60E1 46C4 BD1A 7AC1 4BA2





^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#29489: Obsolete gnus-remove-if and gnus-remove-if-not
  2017-11-28 17:23 ` John Wiegley
@ 2017-11-28 18:01   ` Eric Abrahamsen
  0 siblings, 0 replies; 14+ messages in thread
From: Eric Abrahamsen @ 2017-11-28 18:01 UTC (permalink / raw)
  To: 29489

"John Wiegley" <johnw@gnu.org> writes:

>>>>>> "EA" == Eric Abrahamsen <eric@ericabrahamsen.net> writes:
>
> EA> I've replaced these with `seq-remove' and `seq-filter', and I suppose
> EA> someone might object to that -- the other option would be `cl-remove-if'
> EA> and `cl-remove-if-not'. I don't believe there's much practical difference.
>
> I have no objection to using seq over its cl- equivalents.

Cool. I'll run this patch a while longer, then push.

Thanks,
Eric






^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#29489: Obsolete gnus-remove-if and gnus-remove-if-not
  2017-11-28 17:02 bug#29489: Obsolete gnus-remove-if and gnus-remove-if-not Eric Abrahamsen
  2017-11-28 17:23 ` John Wiegley
@ 2017-11-28 23:44 ` Noam Postavsky
  2017-11-29  0:07   ` Eric Abrahamsen
  1 sibling, 1 reply; 14+ messages in thread
From: Noam Postavsky @ 2017-11-28 23:44 UTC (permalink / raw)
  To: Eric Abrahamsen; +Cc: 29489

Eric Abrahamsen <eric@ericabrahamsen.net> writes:

> 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.

Neither the seq nor cl functions handle hash tables right?

> -             (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)))

> -(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."

Although the docstring claims "hash table", while the code says...

> -    (if hash-table-p
> -	(mapatoms (lambda (symbol)
> -		    (unless (funcall predicate symbol)
> -		      (push symbol out)))
> -		  sequence)

obarray?





^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#29489: Obsolete gnus-remove-if and gnus-remove-if-not
  2017-11-28 23:44 ` Noam Postavsky
@ 2017-11-29  0:07   ` Eric Abrahamsen
  2017-11-29  0:40     ` Noam Postavsky
  0 siblings, 1 reply; 14+ messages in thread
From: Eric Abrahamsen @ 2017-11-29  0:07 UTC (permalink / raw)
  To: 29489

Noam Postavsky <npostavs@users.sourceforge.net> writes:

> Eric Abrahamsen <eric@ericabrahamsen.net> writes:
>
>> 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.
>
> Neither the seq nor cl functions handle hash tables right?
>
>> -             (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)))
>
>> -(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."
>
> Although the docstring claims "hash table", while the code says...
>
>> -    (if hash-table-p
>> -	(mapatoms (lambda (symbol)
>> -		    (unless (funcall predicate symbol)
>> -		      (push symbol out)))
>> -		  sequence)
>
> obarray?

Shhh, that's my next patch to Gnus! Turning its "hash tables" into
actual hash tables. The obarrays are an impressive and horrible hack.

For this version of the patch, `seq-filter' works on vectors. In the
next patch, it's replaced by seq-filter->map-keys.

Eric






^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#29489: Obsolete gnus-remove-if and gnus-remove-if-not
  2017-11-29  0:07   ` Eric Abrahamsen
@ 2017-11-29  0:40     ` Noam Postavsky
  2017-11-29  1:42       ` Eric Abrahamsen
  0 siblings, 1 reply; 14+ messages in thread
From: Noam Postavsky @ 2017-11-29  0:40 UTC (permalink / raw)
  To: Eric Abrahamsen; +Cc: 29489

Eric Abrahamsen <eric@ericabrahamsen.net> writes:

>> Although the docstring claims "hash table", while the code says...
>>
>>> -    (if hash-table-p
>>> -	(mapatoms (lambda (symbol)
>>> -		    (unless (funcall predicate symbol)
>>> -		      (push symbol out)))
>>> -		  sequence)
>>
>> obarray?
>
> Shhh, that's my next patch to Gnus! Turning its "hash tables" into
> actual hash tables. The obarrays are an impressive and horrible hack.
>
> For this version of the patch, `seq-filter' works on vectors. In the
> next patch, it's replaced by seq-filter->map-keys.

Hmm, seq-filter works on vectors, but it's not reliable for obarrays:

    (let ((list nil)
          (ob (make-vector 3 0)))
      (intern "foo" ob)
      (intern "bar" ob)
      (intern "xxx" ob)
      (seq-filter (lambda (_) t) ob)) ;=> (xxx 0 0)





^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#29489: Obsolete gnus-remove-if and gnus-remove-if-not
  2017-11-29  0:40     ` Noam Postavsky
@ 2017-11-29  1:42       ` Eric Abrahamsen
  2017-11-29  2:36         ` Noam Postavsky
  0 siblings, 1 reply; 14+ messages in thread
From: Eric Abrahamsen @ 2017-11-29  1:42 UTC (permalink / raw)
  To: 29489

Noam Postavsky <npostavs@users.sourceforge.net> writes:

> Eric Abrahamsen <eric@ericabrahamsen.net> writes:
>
>>> Although the docstring claims "hash table", while the code says...
>>>
>>>> -    (if hash-table-p
>>>> -	(mapatoms (lambda (symbol)
>>>> -		    (unless (funcall predicate symbol)
>>>> -		      (push symbol out)))
>>>> -		  sequence)
>>>
>>> obarray?
>>
>> Shhh, that's my next patch to Gnus! Turning its "hash tables" into
>> actual hash tables. The obarrays are an impressive and horrible hack.
>>
>> For this version of the patch, `seq-filter' works on vectors. In the
>> next patch, it's replaced by seq-filter->map-keys.
>
> Hmm, seq-filter works on vectors, but it's not reliable for obarrays:
>
>     (let ((list nil)
>           (ob (make-vector 3 0)))
>       (intern "foo" ob)
>       (intern "bar" ob)
>       (intern "xxx" ob)
>       (seq-filter (lambda (_) t) ob)) ;=> (xxx 0 0)

For the interim, all that matters is consistency:

(let ((list nil)
      (ob (make-vector 3 0)))
  (intern "foo" ob)
  (intern "bar" ob)
  (intern "xxx" ob)
  (gnus-remove-if-not (lambda (_) t) ob)) ;=> (xxx 0 0)

The goal of this patch series is to get Gnus into a state where behavior
is at-a-glance comprehensible.






^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#29489: Obsolete gnus-remove-if and gnus-remove-if-not
  2017-11-29  1:42       ` Eric Abrahamsen
@ 2017-11-29  2:36         ` Noam Postavsky
  2017-11-29  3:31           ` Eric Abrahamsen
  0 siblings, 1 reply; 14+ messages in thread
From: Noam Postavsky @ 2017-11-29  2:36 UTC (permalink / raw)
  To: Eric Abrahamsen; +Cc: 29489

Eric Abrahamsen <eric@ericabrahamsen.net> writes:

> For the interim, all that matters is consistency:
>
> (let ((list nil)
>       (ob (make-vector 3 0)))
>   (intern "foo" ob)
>   (intern "bar" ob)
>   (intern "xxx" ob)
>   (gnus-remove-if-not (lambda (_) t) ob)) ;=> (xxx 0 0)

But:

(let ((list nil)
      (ob (make-vector 3 0)))
  (intern "foo" ob)
  (intern "bar" ob)
  (intern "xxx" ob)
  (gnus-remove-if-not (lambda (_) t)
                      ob t)) ;=> (xxx bar foo)





^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#29489: Obsolete gnus-remove-if and gnus-remove-if-not
  2017-11-29  2:36         ` Noam Postavsky
@ 2017-11-29  3:31           ` Eric Abrahamsen
  2017-11-30 18:29             ` Eric Abrahamsen
  0 siblings, 1 reply; 14+ messages in thread
From: Eric Abrahamsen @ 2017-11-29  3:31 UTC (permalink / raw)
  To: Noam Postavsky; +Cc: 29489

Noam Postavsky <npostavs@users.sourceforge.net> writes:

> Eric Abrahamsen <eric@ericabrahamsen.net> writes:
>
>> For the interim, all that matters is consistency:
>>
>> (let ((list nil)
>>       (ob (make-vector 3 0)))
>>   (intern "foo" ob)
>>   (intern "bar" ob)
>>   (intern "xxx" ob)
>>   (gnus-remove-if-not (lambda (_) t) ob)) ;=> (xxx 0 0)
>
> But:
>
> (let ((list nil)
>       (ob (make-vector 3 0)))
>   (intern "foo" ob)
>   (intern "bar" ob)
>   (intern "xxx" ob)
>   (gnus-remove-if-not (lambda (_) t)
>                       ob t)) ;=> (xxx bar foo)

Good catch! Thanks for that. I was too hasty, and had already moved on
to running the next patch.

There are only two places in the code where that third argument is
passed. I can rework those two locations so that they work properly,
until the next step is taken.





^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#29489: Obsolete gnus-remove-if and gnus-remove-if-not
  2017-11-29  3:31           ` Eric Abrahamsen
@ 2017-11-30 18:29             ` Eric Abrahamsen
  2017-12-02  2:38               ` Noam Postavsky
  0 siblings, 1 reply; 14+ messages in thread
From: Eric Abrahamsen @ 2017-11-30 18:29 UTC (permalink / raw)
  To: 29489

[-- Attachment #1: Type: text/plain, Size: 1169 bytes --]

Eric Abrahamsen <eric@ericabrahamsen.net> writes:

> Noam Postavsky <npostavs@users.sourceforge.net> writes:
>
>> Eric Abrahamsen <eric@ericabrahamsen.net> writes:
>>
>>> For the interim, all that matters is consistency:
>>>
>>> (let ((list nil)
>>>       (ob (make-vector 3 0)))
>>>   (intern "foo" ob)
>>>   (intern "bar" ob)
>>>   (intern "xxx" ob)
>>>   (gnus-remove-if-not (lambda (_) t) ob)) ;=> (xxx 0 0)
>>
>> But:
>>
>> (let ((list nil)
>>       (ob (make-vector 3 0)))
>>   (intern "foo" ob)
>>   (intern "bar" ob)
>>   (intern "xxx" ob)
>>   (gnus-remove-if-not (lambda (_) t)
>>                       ob t)) ;=> (xxx bar foo)
>
> Good catch! Thanks for that. I was too hasty, and had already moved on
> to running the next patch.
>
> There are only two places in the code where that third argument is
> passed. I can rework those two locations so that they work properly,
> until the next step is taken.

For a brief, amusing moment, I thought I could write a seq-filter method
that specialized on obarrays, but unfortunately there's no specializer
for obarrays. Oh well. Here's another version of the patch. It's not
pretty, but I do hope it's temporary.


[-- 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: 9971 bytes --]

From 75ef198feb472c84a3fab5fd3e8d5f7e03ecdb01 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       | 34 ++++++++++++++++++++--------------
 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 +-
 lisp/gnus/nnrss.el          |  2 +-
 11 files changed, 34 insertions(+), 59 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..4dee306c81 100644
--- a/lisp/gnus/gnus-sum.el
+++ b/lisp/gnus/gnus-sum.el
@@ -12270,21 +12270,27 @@ gnus-read-move-group-name
 		  (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 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
diff --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


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* bug#29489: Obsolete gnus-remove-if and gnus-remove-if-not
  2017-11-30 18:29             ` Eric Abrahamsen
@ 2017-12-02  2:38               ` Noam Postavsky
  2017-12-02 18:50                 ` Eric Abrahamsen
  0 siblings, 1 reply; 14+ messages in thread
From: Noam Postavsky @ 2017-12-02  2:38 UTC (permalink / raw)
  To: Eric Abrahamsen; +Cc: 29489

Eric Abrahamsen <eric@ericabrahamsen.net> writes:

> -			       (gnus-gethash group gnus-killed-hashtb)))
> +			       (gethash group gnus-killed-hashtb)))

Is this from a future patch?  As far as I can tell, you haven't changed
gnus-killed-hashtb to a hashtable yet, it's still an obarray.





^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#29489: Obsolete gnus-remove-if and gnus-remove-if-not
  2017-12-02  2:38               ` Noam Postavsky
@ 2017-12-02 18:50                 ` Eric Abrahamsen
  2017-12-02 18:54                   ` Noam Postavsky
  0 siblings, 1 reply; 14+ messages in thread
From: Eric Abrahamsen @ 2017-12-02 18:50 UTC (permalink / raw)
  To: Noam Postavsky; +Cc: 29489


On 12/01/17 21:38 PM, Noam Postavsky wrote:
> Eric Abrahamsen <eric@ericabrahamsen.net> writes:
>
>> -			       (gnus-gethash group gnus-killed-hashtb)))
>> +			       (gethash group gnus-killed-hashtb)))
>
> Is this from a future patch?  As far as I can tell, you haven't changed
> gnus-killed-hashtb to a hashtable yet, it's still an obarray.

Bah! I'm sorry you've had to wade through my dumb mistakes. I'll make
better use of branches to keep these things separated cleanly.

Do you see anything else obviously wrong with this? I'll spend some more
time testing it, as well.

Eric





^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#29489: Obsolete gnus-remove-if and gnus-remove-if-not
  2017-12-02 18:54                   ` Noam Postavsky
@ 2017-12-02 18:53                     ` Eric Abrahamsen
  0 siblings, 0 replies; 14+ messages in thread
From: Eric Abrahamsen @ 2017-12-02 18:53 UTC (permalink / raw)
  To: Noam Postavsky; +Cc: 29489


On 12/02/17 13:54 PM, Noam Postavsky wrote:
> Eric Abrahamsen <eric@ericabrahamsen.net> writes:
>
>> Do you see anything else obviously wrong with this? I'll spend some more
>> time testing it, as well.
>
> No, it all looks fine apart from that (though I've only eyeballed the
> code, not tried to run anything).

Okay good. I'll test more.





^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#29489: Obsolete gnus-remove-if and gnus-remove-if-not
  2017-12-02 18:50                 ` Eric Abrahamsen
@ 2017-12-02 18:54                   ` Noam Postavsky
  2017-12-02 18:53                     ` Eric Abrahamsen
  0 siblings, 1 reply; 14+ messages in thread
From: Noam Postavsky @ 2017-12-02 18:54 UTC (permalink / raw)
  To: Eric Abrahamsen; +Cc: 29489

Eric Abrahamsen <eric@ericabrahamsen.net> writes:

> Do you see anything else obviously wrong with this? I'll spend some more
> time testing it, as well.

No, it all looks fine apart from that (though I've only eyeballed the
code, not tried to run anything).





^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2017-12-02 18:54 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-28 17:02 bug#29489: Obsolete gnus-remove-if and gnus-remove-if-not Eric Abrahamsen
2017-11-28 17:23 ` 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

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).