From 5305808fce747936579f9db965a1b163b20e308b Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Sun, 13 Nov 2016 01:27:44 -0500 Subject: Add elfeed-set-tag command --- init.el | 7 +++++++ lisp/km-elfeed.el | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 lisp/km-elfeed.el 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 + +;; Author: Kyle Meyer +;; 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 . + +;;; 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 -- cgit v1.2.3