mirror of
https://github.com/SqrtMinusOne/elfeed-summary.git
synced 2025-12-10 17:43:03 +03:00
117 lines
3.5 KiB
EmacsLisp
117 lines
3.5 KiB
EmacsLisp
;;; elfeed-summary.el --- TODO -*- lexical-binding: t -*-
|
|
|
|
;; Copyright (C) 2022 Korytov Pavel
|
|
|
|
;; Author: Korytov Pavel <thexcloud@gmail.com>
|
|
;; Maintainer: Korytov Pavel <thexcloud@gmail.com>
|
|
;; Version: 0.1.0
|
|
;; Package-Requires: ((emacs "27.1") (magit-section "3.3.0") (elfeed "3.4.1"))
|
|
;; Homepage: https://github.com/SqrtMinusOne/elfeed-summary.el
|
|
|
|
;; This file is NOT part of GNU Emacs.
|
|
|
|
;; This program is free software: you can redistribute it and/or modify
|
|
;; it under the terms of the GNU General Public License as published by
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
;; (at your option) any later version.
|
|
|
|
;; This program is distributed in the hope that it will be useful,
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
;; GNU General Public License for more details.
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
|
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
;;; Commentary:
|
|
;; TODO
|
|
|
|
;;; Code:
|
|
(require 'elfeed)
|
|
(require 'elfeed-db)
|
|
(require 'seq)
|
|
|
|
(cl-defun elfeed-summary--match-tag (query &key tags title url author title-meta)
|
|
(cond
|
|
;; symbol
|
|
((symbolp query) (member query tags))
|
|
;; (title . "Title")
|
|
;; (title . (rx "Title"))
|
|
((eq (car query) 'title)
|
|
(or (and title
|
|
(string-match-p
|
|
(if (stringp (cdr query))
|
|
(cdr query)
|
|
(eval (cdr query)))
|
|
title))
|
|
(and title-meta
|
|
(string-match-p
|
|
(if (stringp (cdr query))
|
|
(cdr query)
|
|
(eval (cdr query)))
|
|
title-meta))))
|
|
;; (author . "Author")
|
|
;; (author . (rx "Author"))
|
|
((eq (car query) 'author)
|
|
(and author
|
|
(string-match-p
|
|
(if (stringp (cdr query))
|
|
(cdr query)
|
|
(eval (cdr query)))
|
|
author)))
|
|
;; (url . "URL")
|
|
;; (url . (rx "URL"))
|
|
((eq (car query) 'url)
|
|
(and url
|
|
(string-match-p
|
|
(if (stringp (cdr query))
|
|
(cdr query)
|
|
(eval (cdr query)))
|
|
url)))
|
|
;; (and <query-1> <query-2> ... <query-n>)
|
|
((eq (car query) 'and)
|
|
(seq-every-p
|
|
(lambda (query-elem)
|
|
(elfeed-summary--match-tag
|
|
query-elem
|
|
:tags tags
|
|
:title title
|
|
:title-meta title-meta
|
|
:url url
|
|
:author author))
|
|
(cdr query)))
|
|
;; (or <query-1> <query-2> ... <query-n>)
|
|
;; (<query-1> <query-2> ... <query-n>)
|
|
(t (seq-some
|
|
(lambda (query-elem)
|
|
(elfeed-summary--match-tag
|
|
query-elem
|
|
:tags tags
|
|
:title title
|
|
:title-meta title-meta
|
|
:url url
|
|
:author author))
|
|
(if (eq (car query) 'or)
|
|
(cdr query)
|
|
query)))))
|
|
|
|
(defun elfeed-summary--get-feeds (query)
|
|
(cl-loop for feed in elfeed-feeds
|
|
for url = (car feed)
|
|
for tags = (cdr feed)
|
|
for feed = (elfeed-db-get-feed url)
|
|
if (elfeed-summary--match-tag
|
|
query
|
|
:tags tags
|
|
:title (elfeed-feed-title feed)
|
|
:title-meta (plist-get (elfeed-feed-meta feed) :title)
|
|
:url url
|
|
:author (plist-get (car (elfeed-feed-author feed)) :name))
|
|
collect feed))
|
|
|
|
(elfeed-summary--get-feeds '(or (title . "Andrea")
|
|
(author . "Bozhidar")
|
|
(url . (rx "sacha"))))
|
|
|
|
(provide 'elfeed-summary)
|
|
;;; elfeed-summary.el ends here
|