Show unread count in mode-line

* avandu.el (avandu-new-articles-count): Only show a message in the
  echo area if it has been called interactively in any way.

  (avandu-overview-mode): Set MODE-NAME to the format of
  "Avandu:Overview[#]" where `#' is replaced by the number of unread
  articles.
This commit is contained in:
Tom Willemsen 2012-08-04 00:30:15 +02:00
parent 7546b86c4b
commit ea83dd8c2c
2 changed files with 25 additions and 10 deletions

View file

@ -57,6 +57,9 @@
"What to replace the part between & and ; of HTML entities with "What to replace the part between & and ; of HTML entities with
names.") names.")
(defconst avandu-overview-mode-name "Avandu:Overview"
"The default name for `avandu-overview-mode'.")
(defconst avandu-version 0 (defconst avandu-version 0
"The current version of avandu.") "The current version of avandu.")
@ -377,8 +380,13 @@ bounds of a button."
feeds." feeds."
(interactive) (interactive)
(avandu--check-login) (avandu--check-login)
(let ((result (avandu--send-command '((op . "getUnread"))))) (let* ((result (avandu--send-command '((op . "getUnread"))))
(message (cdr (assq 'unread (assq 'content result)))))) (count (cdr (assq 'unread (assq 'content result)))))
(when (called-interactively-p 'any)
(message "There are %s unread articles" count))
count))
(defun avandu-next-article () (defun avandu-next-article ()
"Search forward for the next article." "Search forward for the next article."
@ -425,7 +433,8 @@ feeds."
version)) version))
;; Overview ;; Overview
(define-derived-mode avandu-overview-mode special-mode "Avandu:Overview" (define-derived-mode avandu-overview-mode special-mode
avandu-overview-mode-name
"Major mode fo the avandu overview screen. "Major mode fo the avandu overview screen.
This screen shows the articles categorized by feed as a list. It This screen shows the articles categorized by feed as a list. It
@ -435,7 +444,10 @@ doesn't sort the list, so you'll have to set that up in tt-rss.
\\<avandu-overview-map>" \\<avandu-overview-map>"
(use-local-map avandu-overview-map) (use-local-map avandu-overview-map)
(set (make-local-variable 'revert-buffer-function) (set (make-local-variable 'revert-buffer-function)
#'(lambda (ignore-auto noconfirm) (avandu-list)))) #'(lambda (ignore-auto noconfirm) (avandu-list)))
(setq mode-name (format "%s[%s]"
avandu-overview-mode-name
(avandu-new-articles-count))))
;;;###autoload ;;;###autoload
(defun avandu-list () (defun avandu-list ()
@ -487,11 +499,7 @@ by feed."
;; (unread . t) ;; (unread . t)
;; (id . 109)) ;; (id . 109))
;; (get-version)
;; (login user password) ;; (login user password)
;; (logout)
;; (is-logged-in)
;; (get-unread)
;; (get-counters output-mode) ;; (get-counters output-mode)
;; (get-feeds category-id unread-only limit offset) ;; (get-feeds category-id unread-only limit offset)
;; (get-categories unread-only) ;; (get-categories unread-only)

View file

@ -221,8 +221,15 @@ Apart from viewing unread articles there are a number of other things
that can be done. that can be done.
@deffn Command avandu-new-articles-count @deffn Command avandu-new-articles-count
Shows the total number of unread articles in Tiny Tiny RSS in the echo Ask Tiny Tiny RSS for the total number of unread articles. If this
area. function is called interactively in any way it shows a message en the
echo area like:
@example
There are # unread articles
@end example
and it returns the number of unread articles as a string.
@end deffn @end deffn
@deffn Command avandu-logged-in-p @deffn Command avandu-logged-in-p