summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--init.el7
-rw-r--r--lisp/km-elfeed.el55
2 files changed, 62 insertions, 0 deletions
diff --git a/init.el b/init.el
index 7303d17..ddf01bc 100644
--- a/init.el
+++ b/init.el
@@ -2059,6 +2059,13 @@
("s" . elfeed-search-set-filter)
("S" . elfeed-search-live-filter)))
+(use-package km-elfeed
+ :defer t
+ :init
+ (after 'elfeed
+ (bind-keys :map elfeed-search-mode-map
+ ("t" . km/elfeed-set-tag))))
+
;;; Miscellaneous configuration
diff --git a/lisp/km-elfeed.el b/lisp/km-elfeed.el
new file mode 100644
index 0000000..0e67e01
--- /dev/null
+++ b/lisp/km-elfeed.el
@@ -0,0 +1,55 @@
+;;; km-elfeed.el --- Extensions for elfeed
+
+;; Copyright (C) 2012-2016 Kyle Meyer <kyle@kyleam.com>
+
+;; Author: Kyle Meyer <kyle@kyleam.com>
+;; URL: https://github.com/kyleam/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)))))))))
+
+(provide 'km-elfeed)
+;;; km-elfeed.el ends here