Fix a bunch of docstring-related warnings

This commit is contained in:
Tom Willemse 2014-02-14 01:17:11 +01:00
parent aef68eb804
commit 76a4cbd0cc

149
avandu.el
View file

@ -56,8 +56,7 @@
("qout" . 34) ("qout" . 34)
("amp" . 38) ("amp" . 38)
("nbsp" . 32)) ("nbsp" . 32))
"What to replace the part between & and ; of HTML entities with "What to replace certain HTML entities with.")
names.")
(defconst avandu-overview-mode-name "Avandu:Overview" (defconst avandu-overview-mode-name "Avandu:Overview"
"The default name for `avandu-overview-mode'.") "The default name for `avandu-overview-mode'.")
@ -128,8 +127,9 @@
:type 'function) :type 'function)
(defcustom avandu-tt-rss-api-url nil (defcustom avandu-tt-rss-api-url nil
"URL of your Tiny Tiny RSS instance. For example: "URL of your Tiny Tiny RSS instance.
http://tt-rss.org/demo/api/"
For example: http://tt-rss.org/demo/api/"
:group 'avandu :group 'avandu
:type 'string) :type 'string)
@ -145,7 +145,7 @@
;; Variables ;; Variables
(defvar avandu--session-id nil (defvar avandu--session-id nil
"*internal* Session id for avandu.") "*Internal* Session id for avandu.")
(defvar avandu-article-button-map (defvar avandu-article-button-map
(let ((map (make-sparse-keymap))) (let ((map (make-sparse-keymap)))
@ -208,29 +208,33 @@
(goto-char pos)))) (goto-char pos))))
(defmacro avandu-getset (var prompt &optional passwdp) (defmacro avandu-getset (var prompt &optional passwdp)
"Ask the user for, and then save, VAR with PROMPT. Use "Ask the user for VAR with PROMPT.
After getting the answer from the user save the value. Use
`read-passwd' if PASSWDP and `read-string' otherwise." `read-passwd' if PASSWDP and `read-string' otherwise."
`(or ,var (setq ,var (,(if passwdp 'read-passwd 'read-string) `(or ,var (setq ,var (,(if passwdp 'read-passwd 'read-string)
,prompt)))) ,prompt))))
(defmacro avu-prop (element property) (defmacro avu-prop (element property)
"Get PROPERTY from ELEMENT." "Look in ELEMENT for PROPERTY."
`(cdr (assq (quote ,property) ,element))) `(cdr (assq (quote ,property) ,element)))
;; Internal ;; Internal
(defun avandu--check-login () (defun avandu--check-login ()
"Check to see if we're (still) logged in, try to login "Check to see if we're (still) logged in.
otherwise. Signals an error if we're not logged in *and* login
was unsuccesful." Try to login otherwise. Signals an error if we're not logged in
*and* login was unsuccesful."
(unless (or (and avandu--session-id (avandu-logged-in-p)) (unless (or (and avandu--session-id (avandu-logged-in-p))
(avandu-login)) (avandu-login))
(avandu--clear-data) (avandu--clear-data)
(error "Could not log in to tt-rss"))) (error "Could not log in to tt-rss")))
(defun avandu--clean-text (text) (defun avandu--clean-text (text)
"Go through TEXT and remove any trailing and leading whitespace "Go through TEXT and remove any trailing and leading whitespace.
from it, then look for any HTML entities and either replace them
with their char value or with the value in Then look for any HTML entities and either replace them with
their char value or with the value in
`avandu-entity-replacement-alist'." `avandu-entity-replacement-alist'."
(with-temp-buffer (with-temp-buffer
(insert text) (insert text)
@ -260,7 +264,7 @@ with their char value or with the value in
text) text)
(defun avandu--clear-data () (defun avandu--clear-data ()
"Clean up login data. This makes for a clean slate next time." "Clean up login data. Clean the slate for next time."
(setq avandu-user nil (setq avandu-user nil
avandu--session-id nil) avandu--session-id nil)
@ -269,8 +273,10 @@ with their char value or with the value in
(setq avandu-password nil))) (setq avandu-password nil)))
(defun avandu--get-credentials () (defun avandu--get-credentials ()
"Get a username and password for Tiny Tiny RSS. Try it first "Get a username and password for Tiny Tiny RSS.
with `auth-source-search' and then by asking the user."
Try it first with `auth-source-search' and then by asking the
user."
(let ((credentials (auth-source-search :max 1 (let ((credentials (auth-source-search :max 1
:host avandu-tt-rss-api-url :host avandu-tt-rss-api-url
:type 'netrc :type 'netrc
@ -291,7 +297,7 @@ with `auth-source-search' and then by asking the user."
(avu-prop results status)) (avu-prop results status))
(defun avandu--insert-article-excerpt (excerpt) (defun avandu--insert-article-excerpt (excerpt)
"Insert the excerpt of an article." "Insert EXCERPT of an article."
(let ((start-pos (point)) (let ((start-pos (point))
end-pos end-pos
(text (avandu--oneline excerpt))) (text (avandu--oneline excerpt)))
@ -305,8 +311,10 @@ with `auth-source-search' and then by asking the user."
(insert-char ?\n 1)))) (insert-char ?\n 1))))
(defun avandu--insert-article-title (id link title) (defun avandu--insert-article-title (id link title)
"Insert a button with the label TITLE and store ID and LINK in "Insert a button.
the article-id and link properties, respectively."
Store ID and LINK in the `article-id' and `link' properties
respectively, use TITLE as the text for the button."
(let ((pos (point))) (let ((pos (point)))
(insert-button (insert-button
(avandu--oneline title) (avandu--oneline title)
@ -321,8 +329,10 @@ the article-id and link properties, respectively."
(insert-char ?\n 1))) (insert-char ?\n 1)))
(defun avandu--insert-feed-title (id title) (defun avandu--insert-feed-title (id title)
"Insert a button with the label TITLE and store ID in the "Insert a button.
feed-id property."
Store ID in the `feed-id' property and use TITLE as the text of
the button."
(unless (eq (point) (point-min)) (insert-char ?\n 1)) (unless (eq (point) (point-min)) (insert-char ?\n 1))
(let ((pos (point))) (let ((pos (point)))
@ -341,8 +351,10 @@ feed-id property."
(replace-regexp-in-string "[ \n\t]*$" "" (avandu--clean-text text))) (replace-regexp-in-string "[ \n\t]*$" "" (avandu--clean-text text)))
(defun avandu--password () (defun avandu--password ()
"Get the password. This means either return `avandu-password' "Get the password.
as-is, or if it's a function return the result of that function."
This means either return `avandu-password' as-is, or if it's a
function return the result of that function."
(if (functionp avandu-password) (if (functionp avandu-password)
(funcall avandu-password) (funcall avandu-password)
avandu-password)) avandu-password))
@ -356,6 +368,7 @@ as-is, or if it's a function return the result of that function."
(defun avandu--send-command-async (data func) (defun avandu--send-command-async (data func)
"Send a command with parameters DATA to tt-rss asynchronously. "Send a command with parameters DATA to tt-rss asynchronously.
The current session-id is added to the request and then DATA is The current session-id is added to the request and then DATA is
passed on to `json-encode'. passed on to `json-encode'.
@ -369,9 +382,10 @@ FUNC should be a callback function as defined by
(message "Complete.")))) (message "Complete."))))
(defun avandu--send-command-sync (data &optional raw) (defun avandu--send-command-sync (data &optional raw)
"Send a command with parameters DATA to tt-rss. The current "Send a command with parameters DATA to tt-rss.
session-id is added to the request and then DATA is passed on to
`json-encode'. The current session-id is added to the request and then DATA is
passed on to `json-encode'.
DATA should be an association list with at least an OP value. DATA should be an association list with at least an OP value.
For example: For example:
@ -395,17 +409,20 @@ in which case the result is returned as-is."
result))) result)))
(defun avandu-categories (&optional unread) (defun avandu-categories (&optional unread)
"Get the created categories. If UNREAD is non-nil only get "Get the created categories.
categories with feeds with unread articles in them."
If UNREAD is non-nil only get categories with feeds with unread
articles in them."
(avandu--send-command-sync (avandu--send-command-sync
`((op . "getCategories") `((op . "getCategories")
,@(when unread `((unread_only . ,unread)))))) ,@(when unread `((unread_only . ,unread))))))
(defun avandu-feeds (&optional category unread limit offset) (defun avandu-feeds (&optional category unread limit offset)
"Get the subscribed feeds. If CATEGORY has been specified show "Get the subscribed feeds.
only the feeds in CATEGORY. If UNREAD has been specified only
show feeds with unread articles in them. Only fets LIMIT If CATEGORY has been specified show only the feeds in CATEGORY.
number of feeds, starting from OFFSET. If UNREAD has been specified only show feeds with unread articles
in them. Only fets LIMIT number of feeds, starting from OFFSET.
There are a number of special category IDs: There are a number of special category IDs:
0 -- Uncategorized feeds 0 -- Uncategorized feeds
@ -421,9 +438,11 @@ There are a number of special category IDs:
,@(when offset `((offset . ,offset)))))) ,@(when offset `((offset . ,offset))))))
(defun avandu-headlines (feed-id &rest plist) (defun avandu-headlines (feed-id &rest plist)
"Get a list of headlines from Tiny Tiny RSS from the feed "Get a list of headlines from Tiny Tiny RSS.
identified by FEED-ID. Options about what to get can be
specified in the form of a property list PLIST. Get the ones for the feed identified by FEED-ID. Options about
what to get can be specified in the form of a property list
PLIST.
If `:limit' is specified only get that many headlines, and if If `:limit' is specified only get that many headlines, and if
`:skip' has been specified skip that many headlines first. `:skip' has been specified skip that many headlines first.
@ -478,8 +497,9 @@ There are some special feed IDs:
,@(when since-id `((since_id . ,since-id))))))) ,@(when since-id `((since_id . ,since-id)))))))
(defun avandu-update-article (article-ids mode field &optional data) (defun avandu-update-article (article-ids mode field &optional data)
"Update the status of FIELD to MODE for the articles identified "Update the status of a field.
by ARTICLE-IDS.
For each id in ARTICLE-IDS put MODE in FIELD.
ARTICLE-IDS should either be a single integer or a ARTICLE-IDS should either be a single integer or a
comma-separated list of integers. comma-separated list of integers.
@ -505,9 +525,10 @@ When updating FIELD 3 DATA functions as the note's contents."
(message "Update done.")))) (message "Update done."))))
(defun avandu-get-article (article-ids) (defun avandu-get-article (article-ids)
"Get one or more articles from Tiny Tiny RSS with ARTICLE-IDS, "Get one or more articles from Tiny Tiny RSS.
if you're using version 1.5.0 or higher this can also be a
comma-separated list of ids." Filter the articles by ARTICLE-IDS, if you're using version 1.5.0
or higher this can also be a comma-separated list of ids."
(avandu--send-command-sync `((op . "getArticle") (avandu--send-command-sync `((op . "getArticle")
(article_id . ,article-ids)))) (article_id . ,article-ids))))
@ -523,10 +544,11 @@ When updating FIELD 3 DATA functions as the note's contents."
(message "Opened: %s" (button-label button)))) (message "Opened: %s" (button-label button))))
(defun avandu-feed-catchup () (defun avandu-feed-catchup ()
"Send a request to tt-rss to \"Catch up\" with a feed. This "Send a request to tt-rss to \"Catch up\" with a feed.
means that all the (unread) articles in a feed will be marked
as read. After having completed this request the overview is This means that all the (unread) articles in a feed will be
reloaded." marked as read. After having completed this request the overview
is reloaded."
(interactive) (interactive)
(let* ((button (button-at (point))) (let* ((button (button-at (point)))
(id (button-get button 'feed-id))) (id (button-get button 'feed-id)))
@ -537,8 +559,9 @@ When updating FIELD 3 DATA functions as the note's contents."
(revert-buffer)) (revert-buffer))
(defun avandu-logged-in-p () (defun avandu-logged-in-p ()
"Send a request to tt-rss to see if we're (still) logged "Send a request to tt-rss to see if we're (still) logged in.
in. This function returns t if we are, or nil if we're not."
This function returns t if we are, or nil if we're not."
(let* ((response (avandu--send-command-sync '((op . "isLoggedIn")))) (let* ((response (avandu--send-command-sync '((op . "isLoggedIn"))))
(result (avu-prop response status))) (result (avu-prop response status)))
(if (eq result :json-false) (if (eq result :json-false)
@ -546,10 +569,11 @@ in. This function returns t if we are, or nil if we're not."
result))) result)))
(defun avandu-login () (defun avandu-login ()
"Send a request to log in to tt-rss. If `avandu-user' or "Send a request to log in to tt-rss.
`avandu-password' have not been specified they will be asked for
and saved in memory. This function returns t on succes, nil If `avandu-user' or `avandu-password' have not been specified
otherwise." they will be asked for and saved in memory. This function
returns t on succes, nil otherwise."
(interactive) (interactive)
(unless (and avandu-user avandu-password) (unless (and avandu-user avandu-password)
(avandu--get-credentials)) (avandu--get-credentials))
@ -575,27 +599,24 @@ otherwise."
(defun avandu-mark-article-read (id) (defun avandu-mark-article-read (id)
"Send a request to tt-rss to mark an article as read. "Send a request to tt-rss to mark an article as read.
BUTTON, if given, should be a button widget, as created by Update the article identified by ID."
`button-insert' and such, which contains FEED-ID. If BUTTON is
nil, it will be assumed that `point' is currently within the
bounds of a button."
(interactive) (interactive)
(let* ((message-truncate-lines t)) (let* ((message-truncate-lines t))
(avandu-update-article id 0 2))) (avandu-update-article id 0 2)))
(defun avandu-ui-mark-article-read (&optional button) (defun avandu-ui-mark-article-read (&optional button)
"Try to change the state of BUTTON to a read article button, if "Try to change the state of BUTTON to a read article button.
BUTTON is nil, try to use a button at `point'."
If BUTTON is nil, try to use a button at `point'."
(let ((button (or button (button-at (point))))) (let ((button (or button (button-at (point)))))
(if button (if button
(progn (progn
(button-put button 'face 'avandu-overview-read-article) (button-put button 'face 'avandu-overview-read-article)
(avandu-next-article)) (avandu-next-article))
(error "No button found.")))) (error "No button found"))))
(defun avandu-new-articles-count () (defun avandu-new-articles-count ()
"Send a request to tt-rss for the total number of unread "Get the total number of unread feeds."
feeds."
(interactive) (interactive)
(avandu--check-login) (avandu--check-login)
(let* ((result (avandu--send-command-sync '((op . "getUnread")))) (let* ((result (avandu--send-command-sync '((op . "getUnread"))))
@ -649,14 +670,16 @@ feeds."
version)) version))
(defun avandu-view-possibly-external (start end) (defun avandu-view-possibly-external (start end)
"If `avandu-html2text-command' has been specified use that on "Maybe execute a command on the region between START and END.
the given region, otherwise just leave it alone."
If `avandu-html2text-command' has been specified use that on the
given region, otherwise just leave it alone."
(when avandu-html2text-command (when avandu-html2text-command
(shell-command-on-region (shell-command-on-region
start end avandu-html2text-command t t))) start end avandu-html2text-command t t)))
(defun avandu-view-w3m (start end) (defun avandu-view-w3m (start end)
"Use w3m to view an article." "Render the region between START and END with w3m."
(when (require 'w3m nil t) (when (require 'w3m nil t)
(w3m-region start end) (w3m-region start end)
(w3m-minor-mode))) (w3m-minor-mode)))
@ -729,7 +752,7 @@ meaningless, but it's easy."
(switch-to-buffer buffer))) (switch-to-buffer buffer)))
(defun avandu-view-article (id) (defun avandu-view-article (id)
"Show a single article in a new buffer." "Show a single article identified by ID in a new buffer."
(interactive "nArticle id: ") (interactive "nArticle id: ")
(let* ((data (avandu-get-article id)) (let* ((data (avandu-get-article id))
(buffer (get-buffer-create "*avandu-article*")) (buffer (get-buffer-create "*avandu-article*"))