diff options
author | Tom Willemse | 2014-04-12 22:49:31 +0200 |
---|---|---|
committer | Tom Willemse | 2014-04-12 22:49:31 +0200 |
commit | 0c818bfc59608f1c897f8db80d8139de677e0f10 (patch) | |
tree | d5dcf939c9d0122a850160f09e213cdad1cfdecd | |
parent | 9297b07df13d9fe47c1ececb367db1225ddd84f8 (diff) | |
download | avandu-0c818bfc59608f1c897f8db80d8139de677e0f10.tar.gz avandu-0c818bfc59608f1c897f8db80d8139de677e0f10.zip |
Add category completion to feed subscription
Change the `avandu-categories' function to return a hash table of
title/id value pairs for each category from tt-rss. This makes it easier
to use it in some other places.
-rw-r--r-- | avandu.el | 22 |
1 files changed, 16 insertions, 6 deletions
@@ -447,9 +447,14 @@ in which case the result is returned as-is." If UNREAD is non-nil only get categories with feeds with unread articles in them." - (avandu--send-command-sync - `((op . "getCategories") - ,@(when unread `((unread_only . ,unread)))))) + (let ((hash (make-hash-table :test 'equal))) + (mapc (lambda (category) + (setf (gethash (cdr (assq 'title category)) hash) + (cdr (assq 'id category)))) + (avandu--send-command-sync + `((op . "getCategories") + ,@(when unread `((unread_only . ,unread)))))) + hash)) (defun avandu-feeds (&optional category unread limit offset) "Get the subscribed feeds. @@ -720,12 +725,17 @@ If BUTTON is nil, try to use a button at `point'." version)) ;;;###autoload -(defun avandu-subscribe-to-feed (url) +(defun avandu-subscribe-to-feed (url category) "Subscribe to the feed at URL optionally putting it in CATEGORY." - (interactive "MUrl: ") + (interactive (let ((categories (avandu-categories))) + (list (read-from-minibuffer "URL: ") + (gethash (completing-read "Category: " + categories nil t) + categories)))) (let ((status (avu-prop (avu-prop (avandu--send-command-sync `((op . "subscribeToFeed") - (feed_url . ,url))) + (feed_url . ,url) + (category_id . ,category))) status) code))) (if (= status 1) |