Add capability to select which entries to export
This commit is contained in:
parent
4f9c97c790
commit
476b050b94
1 changed files with 44 additions and 1 deletions
|
@ -54,6 +54,39 @@ The function takes an entry argument for extracting the desired value."
|
|||
:type 'alist
|
||||
:group 'elfeed-export)
|
||||
|
||||
(defcustom elfeed-export-predicates
|
||||
(list #'elfeed-export--include-entry-by-date-p
|
||||
#'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."
|
||||
:group 'elfeed-export
|
||||
:type '(repeat function))
|
||||
|
||||
(defcustom elfeed-export-include-tags nil
|
||||
"Export entries that have any of these tags."
|
||||
:group 'elfeed-export
|
||||
:type '(repeat symbol))
|
||||
|
||||
(defcustom elfeed-export-exclude-tags '(noexport)
|
||||
"Do not export entries that have any of these tags."
|
||||
:group 'elfeed-export
|
||||
:type '(repeat symbol))
|
||||
|
||||
(defun elfeed-export--include-entry-by-tag-p (entry _)
|
||||
(let ((tags (elfeed-entry-tags entry)))
|
||||
(and
|
||||
(or (not elfeed-export-include-tags)
|
||||
(seq-intersection elfeed-export-include-tags tags))
|
||||
(or (not elfeed-export-exclude-tags)
|
||||
(not (seq-intersection elfeed-export-exclude-tags tags))))))
|
||||
|
||||
(defun elfeed-export--include-entry-by-date-p (entry _)
|
||||
(let ((date (elfeed-entry-date entry)))
|
||||
;; TODO
|
||||
t))
|
||||
|
||||
(defun elfeed-export--entry-date (entry)
|
||||
"Return an ISO formatted date string for the given ENTRY."
|
||||
(format-time-string "%F %T" (elfeed-entry-date entry)))
|
||||
|
@ -77,6 +110,14 @@ The function takes an entry argument for extracting the desired value."
|
|||
(funcall (cdr field) entry)))
|
||||
elfeed-export-fields))
|
||||
|
||||
(defun elfeed-export-filter-entries (entries)
|
||||
(seq-filter (lambda (entry)
|
||||
(let ((feed (elfeed-entry-feed entry)))
|
||||
(seq-every-p (lambda (pred)
|
||||
(funcall pred entry feed))
|
||||
elfeed-export-predicates)))
|
||||
entries))
|
||||
|
||||
(defun elfeed-export--entries ()
|
||||
"Return all entries that need to be exported."
|
||||
(let ((entries)
|
||||
|
@ -85,7 +126,8 @@ The function takes an entry argument for extracting the desired value."
|
|||
(setq entries
|
||||
(append entries
|
||||
(elfeed-feed-entries feed))))
|
||||
(mapcar #'elfeed-export--entry-to-alist entries)))
|
||||
(mapcar #'elfeed-export--entry-to-alist
|
||||
(elfeed-export-filter-entries entries))))
|
||||
|
||||
(defun elfeed-export-to-json ()
|
||||
"Return the JSON string for all entries that should be exported."
|
||||
|
@ -97,4 +139,5 @@ The function takes an entry argument for extracting the desired value."
|
|||
(write-region (elfeed-export-to-json) nil path nil nil nil t))
|
||||
|
||||
(provide 'elfeed-export)
|
||||
|
||||
;;; elfeed-export.el ends here
|
||||
|
|
Loading…
Reference in a new issue