From 891a847b0fff0ec1abfa717ede28250a16d5c429 Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Sat, 12 Apr 2014 23:26:16 +0200 Subject: Add unsubscribe command --- avandu.el | 22 ++++++++++++++++++++++ doc/avandu.texinfo | 5 +++++ 2 files changed, 27 insertions(+) diff --git a/avandu.el b/avandu.el index f6e67f0..a7d31ca 100644 --- a/avandu.el +++ b/avandu.el @@ -476,6 +476,15 @@ There are a number of special category IDs: ,@(when limit `((limit . ,limit))) ,@(when offset `((offset . ,offset)))))) +(defun avandu--all-feeds-hash () + "Get a hashtable of all feeds subsrcibed to in tt-rss." + (let ((hash (make-hash-table :test 'equal))) + (mapc (lambda (feed) + (setf (gethash (cdr (assq 'title feed)) hash) + (cdr (assq 'id feed)))) + (avandu-feeds -3)) + hash)) + (defun avandu-headlines (feed-id &rest plist) "Get a list of headlines from Tiny Tiny RSS. @@ -742,6 +751,19 @@ If BUTTON is nil, try to use a button at `point'." (message "Succesfully subscribed to feed") (message "Could not subscribe to feed")))) +;;;###autoload +(defun avandu-unsubscribe-from-feed (id) + "Unsubscribe from ID." + (interactive (let ((feeds (avandu--all-feeds-hash))) + (list (gethash (completing-read "Feed: " feeds nil t) + feeds)))) + (let ((status (avu-prop (avandu--send-command-sync + `((op . "unsubscribeFeed") + (feed_id . ,id))) status))) + (if (string= status "OK") + (message "Succesfully unsubscribed from feed") + (message "Could not unsubscribe from feed")))) + (defun avandu-view-possibly-external (start end) "Maybe execute a command on the region between START and END. diff --git a/doc/avandu.texinfo b/doc/avandu.texinfo index 8e45904..da21dc1 100644 --- a/doc/avandu.texinfo +++ b/doc/avandu.texinfo @@ -334,3 +334,8 @@ the id of the category as known in Tiny Tiny RSS. When used interactively the user will be prompted for both, and completions will be offered for @var{category} to make things easier. @end deffn + +@deffn Command avandu-unsubscribe-from-feed id +Ask Tiny Tiny RSS to unsubscribe from the feed identified with +@var{id}. Completion is provided to make selection easier. +@end deffn -- cgit v1.2.3-54-g00ecf