aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tom Willemse2014-04-12 22:49:31 +0200
committerGravatar Tom Willemse2014-04-12 22:49:31 +0200
commit0c818bfc59608f1c897f8db80d8139de677e0f10 (patch)
treed5dcf939c9d0122a850160f09e213cdad1cfdecd
parent9297b07df13d9fe47c1ececb367db1225ddd84f8 (diff)
downloadavandu-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.el22
1 files changed, 16 insertions, 6 deletions
diff --git a/avandu.el b/avandu.el
index b1fa309..f6e67f0 100644
--- a/avandu.el
+++ b/avandu.el
@@ -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)