Simplify gnus-or and gnus-and

* lisp/gnus/gnus-art.el: Make implicit seq.el dependency explicit.
(gnus-treat-predicate): Use seq-some in place of mapcar + gnus-or
and evaluate lambda predicate.
* lisp/gnus/gnus-util.el (gnus-or, gnus-and): Simplify.
parent c89900eb
Pipeline #1827 failed with stage
in 16 seconds
......@@ -41,6 +41,7 @@
(require 'mm-uu)
(require 'message)
(require 'mouse)
(require 'seq)
(autoload 'gnus-msg-mail "gnus-msg" nil t)
(autoload 'gnus-button-mailto "gnus-msg")
......@@ -8580,11 +8581,9 @@ For example:
nil)
(gnus-treat-condition
(eq gnus-treat-condition val))
((and (listp val)
(stringp (car val)))
(apply #'gnus-or (mapcar `(lambda (s)
(string-match s ,(or gnus-newsgroup-name "")))
val)))
((stringp (car-safe val))
(let ((name (or gnus-newsgroup-name "")))
(seq-some (lambda (s) (string-match-p s name)) val)))
((listp val)
(let ((pred (pop val)))
(cond
......
......@@ -34,6 +34,7 @@
(eval-when-compile (require 'cl-lib))
(require 'seq)
(require 'time-date)
(require 'text-property-search)
......@@ -1160,20 +1161,13 @@ ARG is passed to the first function."
(eq (cadr (memq 'gnus-undeletable (text-properties-at b))) t)
(text-property-any b e 'gnus-undeletable t)))
(defun gnus-or (&rest elems)
"Return non-nil if any of the elements are non-nil."
(catch 'found
(while elems
(when (pop elems)
(throw 'found t)))))
(defun gnus-and (&rest elems)
"Return non-nil if all of the elements are non-nil."
(catch 'found
(while elems
(unless (pop elems)
(throw 'found nil)))
t))
(defun gnus-or (&rest elements)
"Return non-nil if any one of ELEMENTS is non-nil."
(seq-drop-while #'null elements))
(defun gnus-and (&rest elements)
"Return non-nil if all ELEMENTS are non-nil."
(not (memq nil elements)))
;; gnus.el requires mm-util.
(declare-function mm-disable-multibyte "mm-util")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment