blob: 70469d53dd3e24f263c26bd9d76234cf4818697a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
;;; km-elfeed.el --- Extensions for elfeed
;; Copyright (C) 2012-2020 Kyle Meyer <kyle@kyleam.com>
;; Author: Kyle Meyer <kyle@kyleam.com>
;; URL: https://git.kyleam.com/emacs.d
;; 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 <http://www.gnu.org/licenses/>.
;;; Code:
(defvar km/elfeed-tag-keys nil
"Keys used by `km/elfeed-set-tag' to select tags.
? and . are reserved.")
;;;###autoload
(defun km/elfeed-set-tag ()
"Filter to a tag defined in `km/elfeed-tag-keys'.
? and . are reserved for showing a help buffer and resetting the
filter to the default, respectively."
(interactive)
(let ((tag-key (read-char-choice
(concat "Tag [?. "
(mapconcat (lambda (x) (char-to-string (car x)))
km/elfeed-tag-keys "")
"]: ")
(append (list ?. ??)
(mapcar #'car km/elfeed-tag-keys)))))
(if (eq tag-key ??)
(with-current-buffer (get-buffer-create "*Elfeed tags*")
(erase-buffer)
(insert (format "\n. default filter\n\n"))
(insert (mapconcat (lambda (x) (format "%c %s" (car x) (cdr x)))
km/elfeed-tag-keys
"\n"))
(display-buffer (current-buffer)))
(elfeed-search-set-filter
(concat (default-value 'elfeed-search-filter)
(and (not (eq tag-key ?.))
(format " +%s"
(cdr (assq tag-key km/elfeed-tag-keys)))))))))
;;;###autoload
(defun km/elfeed-default-filter ()
(interactive)
(elfeed-search-set-filter (default-value 'elfeed-search-filter)))
;;;###autoload
(defun km/elfeed-catchup ()
(interactive)
(mark-whole-buffer)
(elfeed-search-untag-all-unread)
(km/elfeed-default-filter))
(provide 'km-elfeed)
;;; km-elfeed.el ends here
|