Have avandu-headlines use a plist

Calling `(avandu-headlines -4 :view-mode "unread" :show-excerpt t)'
seems much cleaner than
`(avandu-headlines -4 nil nil nil t nil "unread")'.
This commit is contained in:
Tom Willemsen 2012-08-04 18:07:23 +02:00
parent a92da69dea
commit 7a7b7fb8b3

View file

@ -334,49 +334,62 @@ There are a number of special category IDs:
,@(when limit `((limit . ,limit))) ,@(when limit `((limit . ,limit)))
,@(when offset `((offset . ,offset)))))))) ,@(when offset `((offset . ,offset))))))))
(defun avandu-headlines (feed-id &optional limit skip is-cat show-excerpt (defun avandu-headlines (feed-id &rest plist)
show-content view-mode
include-attachments since-id)
"Get a list of headlines from Tiny Tiny RSS from the feed "Get a list of headlines from Tiny Tiny RSS from the feed
identified by FEED-ID. If LIMIT is specified only get LIMIT identified by FEED-ID. Options about what to get can be
number of headlines, and if SKIP has been specified skip the specified in the form of a property list PLIST.
first SKIP headlines. If IS-CAT is non-nil, that means FEED-ID
is actually the ID of a category. When SHOW-EXCERPT is non-nil, If `:limit' is specified only get that many headlines, and if
send back an excerpt along with the headline and if SHOW-CONTENT `:skip' has been specified skip that many headlines first.
is non-nil send along the entire article.
If `:is-cat' is non-nil, that means FEED-ID is actually the ID of
a category.
When `:show-excerpt' is non-nil, send back an excerpt along with
the headline and if `:show-content' is non-nil send along the
entire article.
`:view-mode' determines what type of headlines are sent back:
VIEW-MODE determines what type of headlines are sent back.
all_articles -- All articles found are sent back. all_articles -- All articles found are sent back.
unread -- Only unread articles are sent back. unread -- Only unread articles are sent back.
adaptive -- ? adaptive -- ?
marked -- ? marked -- ?
updated -- ? updated -- ?
If INCLUDE-ATTATCHMENTS is non-nil, send along any files enclosed If `:include-attatchments' is non-nil, send along any files
in the articles. enclosed in the articles.
If SINCE-ID is specified, send only articles with a FEED-ID If `:since-id' is specified, send only articles with a FEED-ID
greater than this. greater than this.
There are some special feed ids: There are some special feed IDs:
-1 -- Starred feeds -1 -- Starred feeds
-2 -- Published feeds -2 -- Published feeds
-3 -- Fresh feeds (less than X hours old) -3 -- Fresh feeds (less than X hours old)
-4 -- All articles -4 -- All articles
0 -- Archived articles 0 -- Archived articles
IDs < -10 -- Labels" IDs < -10 -- Labels"
(cdr (assq 'content (let ((limit (plist-get plist :limit))
(avandu--send-command (skip (plist-get plist :skip))
`((op . "getHeadlines") (is-cat (plist-get plist :is-cat))
(feed_id . ,feed-id) (show-excerpt (plist-get plist :show-excerpt))
,@(when limit `((limit . ,limit))) (show-content (plist-get plist :show-content))
,@(when skip `((skip . ,skip))) (view-mode (plist-get plist :view-mode))
,@(when is-cat `((is_cat . ,is-cat))) (include-attachments (plist-get plist :include-attachments))
,@(when show-excerpt `((show_excerpt . ,show-excerpt))) (since-id (plist-get plist :since-id)))
,@(when show-content `((show_content . ,show-content))) (cdr (assq 'content
,@(when view-mode `((view_mode . ,view-mode))) (avandu--send-command
,@(when include-attachments `((include_attachments . ,include-attachments))) `((op . "getHeadlines")
,@(when since-id `((since_id . ,since-id)))))))) (feed_id . ,feed-id)
,@(when limit `((limit . ,limit)))
,@(when skip `((skip . ,skip)))
,@(when is-cat `((is_cat . ,is-cat)))
,@(when show-excerpt `((show_excerpt . ,show-excerpt)))
,@(when show-content `((show_content . ,show-content)))
,@(when view-mode `((view_mode . ,view-mode)))
,@(when include-attachments `((include_attachments . ,include-attachments)))
,@(when since-id `((since_id . ,since-id)))))))))
;; Commands ;; Commands
(defun avandu-browse-article () (defun avandu-browse-article ()
@ -528,7 +541,7 @@ by feed."
(interactive) (interactive)
(avandu--check-login) (avandu--check-login)
(let ((buffer (get-buffer-create "*avandu-overview*")) (let ((buffer (get-buffer-create "*avandu-overview*"))
(result (avandu-headlines -4 nil nil nil t nil "unread")) (result (avandu-headlines -4 :show-excerpt t :view-mode "unread"))
feed-id) feed-id)
(with-current-buffer buffer (with-current-buffer buffer
(setq buffer-read-only nil) (setq buffer-read-only nil)