From 74e51d906c503efae1cc322b0da9fba3c4d8560f Mon Sep 17 00:00:00 2001 From: Bram Schoenmakers Date: Sun, 4 Aug 2024 13:07:19 +0200 Subject: [PATCH] Entry filters only accept an entry object Simplify at a bit by no longer passing a feed object. If a filter needs it, it can be retrieved with 'elfeed-entry-feed'. --- README.org | 2 +- elfeed-export.el | 13 ++++++------- elfeed-export.info | 3 +-- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/README.org b/README.org index d969aea..15818bb 100644 --- a/README.org +++ b/README.org @@ -84,7 +84,7 @@ Likewise, if you use [[https://github.com/rnadler/elfeed-curate][elfeed-curate]] ** Customize entry filters -The variable ~elfeed-export-predicates~ is a list of predicates applied to each entry. An entry that matches all predicates makes it into the export. Each predicate takes two arguments: the entry object and the corresponding feed URL. +The variable ~elfeed-export-predicates~ is a list of predicates applied to each entry. An entry that matches all predicates makes it into the export. Each predicate takes one argument: the entry object. By default, there is a tag-based predicate, which is configured by the variables ~elfeed-export-include-tags~ and ~elfeed-export-exclude-tags~. They're a list of symbols that represent a tag. E.g., to export unread items only, use: diff --git a/elfeed-export.el b/elfeed-export.el index 1f1aa79..b4d8bf2 100644 --- a/elfeed-export.el +++ b/elfeed-export.el @@ -58,8 +58,8 @@ The function takes an entry argument for extracting the desired value." (list #'elfeed-export--include-entry-by-tag-p) "Entries that match all of these predicates are exported. -Each predicate accepts an entry and a feed object and should -return t when the entry should be exported." +Each predicate accepts an entry object and should return t when +the entry should be exported." :group 'elfeed-export :type '(repeat function)) @@ -73,7 +73,7 @@ return t when the entry should be exported." :group 'elfeed-export :type '(repeat symbol)) -(defun elfeed-export--include-entry-by-tag-p (entry _feed) +(defun elfeed-export--include-entry-by-tag-p (entry) (let ((tags (elfeed-entry-tags entry))) (and (or (not elfeed-export-include-tags) @@ -107,10 +107,9 @@ return t when the entry should be exported." (defun elfeed-export-filter-entries (entries) "Filter ENTRIES according to all predictates in `elfeed-export-predicates'." (seq-filter (lambda (entry) - (let ((feed (elfeed-entry-feed entry))) - (seq-every-p (lambda (pred) - (funcall pred entry feed)) - elfeed-export-predicates))) + (seq-every-p (lambda (pred) + (funcall pred entry)) + elfeed-export-predicates)) entries)) (defun elfeed-export--entries () diff --git a/elfeed-export.info b/elfeed-export.info index 27e2e4d..e29face 100644 --- a/elfeed-export.info +++ b/elfeed-export.info @@ -114,8 +114,7 @@ File: elfeed-export.info, Node: Customize entry filters, Prev: Customize expor The variable ‘elfeed-export-predicates’ is a list of predicates applied to each entry. An entry that matches all predicates makes it into the -export. Each predicate takes two arguments: the entry object and the -corresponding feed URL. +export. Each predicate takes one argument: the entry object. By default, there is a tag-based predicate, which is configured by the variables ‘elfeed-export-include-tags’ and