From: Basil L. Contovounesios Date: Wed, 29 May 2019 14:53:31 +0000 (+0100) Subject: Simplify gnus-or and gnus-and X-Git-Tag: emacs-27.0.90~2763 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=7f3b0d1c0003f3b883a6df3d2fae7f847f6d3070;p=emacs.git 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. --- diff --git a/lisp/gnus/gnus-art.el b/lisp/gnus/gnus-art.el index 8f0695222cb..0cd34e445cc 100644 --- a/lisp/gnus/gnus-art.el +++ b/lisp/gnus/gnus-art.el @@ -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 diff --git a/lisp/gnus/gnus-util.el b/lisp/gnus/gnus-util.el index 6b0f29b0afb..e4bc9b900c2 100644 --- a/lisp/gnus/gnus-util.el +++ b/lisp/gnus/gnus-util.el @@ -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")