aboutsummaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorHolger Dürer <me@hdurer.net>2021-11-01 12:28:32 +0100
committerHolger Dürer <me@hdurer.net>2021-11-01 14:31:26 +0100
commitd7593a06912b7946d2fb318093ec7e27c64b3be7 (patch)
tree6efc758297a927434861e66c913d1b8b5aa19c60 /lisp
parent04465567450d6fc9cdec1a1ba0ef12557b0ab54b (diff)
Fix compilation warnings.
This is mostly reflowing / reworkding docstrings to keep within 80 characters limit and adding autoloads. There are two warning remaining that I don't understand: - mastodon-async.el:359:16: Warning: reference to free variable ‘url-http-end-of-headers’ - mastodon-http.el:139:8: Warning: value returned from (string-equal json-string "") is unused When adding autoloads this sorts them for better readability.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/mastodon-async.el14
-rw-r--r--lisp/mastodon-auth.el13
-rw-r--r--lisp/mastodon-http.el2
-rw-r--r--lisp/mastodon-media.el5
-rw-r--r--lisp/mastodon-notifications.el15
-rw-r--r--lisp/mastodon-search.el9
-rw-r--r--lisp/mastodon-tl.el7
-rw-r--r--lisp/mastodon-toot.el41
8 files changed, 65 insertions, 41 deletions
diff --git a/lisp/mastodon-async.el b/lisp/mastodon-async.el
index 6a421d1..56dc230 100644
--- a/lisp/mastodon-async.el
+++ b/lisp/mastodon-async.el
@@ -30,8 +30,14 @@
;;; Code:
(require 'json)
+(require 'url-http)
+(autoload 'mastodon-auth--access-token "mastodon-auth")
+(autoload 'mastodon-http--api "mastodon-http")
+(autoload 'mastodon-http--get-json "mastodon-http")
+(autoload 'mastodon-mode "mastodon")
(autoload 'mastodon-notifications--timeline "mastodon-notifications")
+(autoload 'mastodon-tl--timeline "mastodon-tl")
(defgroup mastodon-async nil
"An async module for mastodon streams."
@@ -129,7 +135,9 @@
Then start an async stream at ENDPOINT filtering toots
using FILTER.
TIMELINE is a specific target, such as federated or home.
-NAME is the center portion of the buffer name for *mastodon-async-buffer and *mastodon-async-queue."
+NAME is the center portion of the buffer name for
+*mastodon-async-buffer and *mastodon-async-queue."
+ (ignore timeline) ;; TODO: figure out what this is meant to be used for
(let ((buffer (mastodon-async--start-process
endpoint filter name)))
(with-current-buffer buffer
@@ -238,7 +246,9 @@ Filter the toots using FILTER."
(async-buffer (mastodon-async--setup-buffer "" (or name stream) endpoint))
(http-buffer (mastodon-async--get
(mastodon-http--api stream)
- (lambda (status) (message "HTTP SOURCE CLOSED")))))
+ (lambda (status)
+ (ignore status)
+ (message "HTTP SOURCE CLOSED")))))
(mastodon-async--setup-http http-buffer (or name stream))
(mastodon-async--set-http-buffer async-buffer http-buffer)
(mastodon-async--set-http-buffer async-queue http-buffer)
diff --git a/lisp/mastodon-auth.el b/lisp/mastodon-auth.el
index 0b0c703..b22b51e 100644
--- a/lisp/mastodon-auth.el
+++ b/lisp/mastodon-auth.el
@@ -63,7 +63,10 @@ if you are happy with unencryped storage use e.g. \"~/authinfo\"."
(defun mastodon-auth--generate-token ()
"Make POST to generate auth token.
-If no auth-sources file, runs `mastodon-auth--generate-token-no-storing-credentials'. If auth-sources file exists, runs `mastodon-auth--generate-token-and-store'."
+If no auth-sources file, runs
+`mastodon-auth--generate-token-no-storing-credentials'. If
+auth-sources file exists, runs
+`mastodon-auth--generate-token-and-store'."
(if (or (null mastodon-auth-source-file)
(string= "" mastodon-auth-source-file))
(mastodon-auth--generate-token-no-storing-credentials)
@@ -124,9 +127,13 @@ Reads and/or stores secrets in `MASTODON-AUTH-SOURCE-FILE'."
(json-read-from-string json-string))))
(defun mastodon-auth--access-token ()
- "If an access token for `mastodon-instance-url' is in `mastodon-auth--token-alist', return it.
+ "Return exiting or generate new access token.
-Otherwise, generate a token and pass it to `mastodon-auth--handle-token-reponse'."
+If an access token for `mastodon-instance-url' is in
+`mastodon-auth--token-alist', return it.
+
+Otherwise, generate a token and pass it to
+`mastodon-auth--handle-token-reponse'."
(if-let ((token (cdr (assoc mastodon-instance-url mastodon-auth--token-alist))))
token
diff --git a/lisp/mastodon-http.el b/lisp/mastodon-http.el
index d6158eb..27f8ef0 100644
--- a/lisp/mastodon-http.el
+++ b/lisp/mastodon-http.el
@@ -145,7 +145,7 @@ Pass response buffer to CALLBACK function."
(buffer-substring-no-properties (point) (point-max))
'utf-8)))
(kill-buffer)
- (unless (or (string= "" json-string) (equal nil json-string)))
+ (unless (or (string-equal "" json-string) (null json-string)))
(json-read-from-string json-string)))
(defun mastodon-http--delete (url)
diff --git a/lisp/mastodon-media.el b/lisp/mastodon-media.el
index 808a23d..5f8f46c 100644
--- a/lisp/mastodon-media.el
+++ b/lisp/mastodon-media.el
@@ -32,6 +32,8 @@
;; required by the server and client.
;;; Code:
+(require 'url-cache)
+
(defvar url-show-status)
(defvar mastodon-tl--shr-image-map-replacement)
@@ -141,7 +143,8 @@ fKRJkmVZjAQwh78A6vCRWJE8K+8AAAAASUVORK5CYII=")
STATUS-PLIST is the usual plist of status events as per `url-retrieve'.
IMAGE-OPTIONS are the precomputed options to apply to the image.
MARKER is the marker to where the response should be visible.
-REGION-LENGTH is the length of the region that should be replaced with the image."
+REGION-LENGTH is the length of the region that should be replaced
+with the image."
(when (marker-buffer marker) ; only if the buffer hasn't been kill in the meantime
(let ((url-buffer (current-buffer))
(is-error-response-p (eq :error (car status-plist))))
diff --git a/lisp/mastodon-notifications.el b/lisp/mastodon-notifications.el
index 2e9aea3..ad3d7b4 100644
--- a/lisp/mastodon-notifications.el
+++ b/lisp/mastodon-notifications.el
@@ -29,22 +29,23 @@
;;; Code:
+(autoload 'mastodon-http--api "mastodon-http.el")
+(autoload 'mastodon-http--post "mastodon-http.el")
+(autoload 'mastodon-http--triage "mastodon-http.el")
(autoload 'mastodon-media--inline-images "mastodon-media.el")
+(autoload 'mastodon-tl--byline "mastodon-tl.el")
(autoload 'mastodon-tl--byline-author "mastodon-tl.el")
(autoload 'mastodon-tl--clean-tabs-and-nl "mastodon-tl.el")
(autoload 'mastodon-tl--content "mastodon-tl.el")
-(autoload 'mastodon-tl--byline "mastodon-tl.el")
-(autoload 'mastodon-tl--toot-id "mastodon-tl.el")
(autoload 'mastodon-tl--field "mastodon-tl.el")
+(autoload 'mastodon-tl--find-property-range "mastodon-tl.el")
(autoload 'mastodon-tl--has-spoiler "mastodon-tl.el")
(autoload 'mastodon-tl--init "mastodon-tl.el")
+(autoload 'mastodon-tl--init-sync "mastodon-tl.el")
(autoload 'mastodon-tl--insert-status "mastodon-tl.el")
-(autoload 'mastodon-tl--spoiler "mastodon-tl.el")
(autoload 'mastodon-tl--property "mastodon-tl.el")
-(autoload 'mastodon-tl--find-property-range "mastodon-tl.el")
-(autoload 'mastodon-http--triage "mastodon-http.el")
-(autoload 'mastodon-http--post "mastodon-http.el")
-(autoload 'mastodon-http--api "mastodon-http.el")
+(autoload 'mastodon-tl--spoiler "mastodon-tl.el")
+(autoload 'mastodon-tl--toot-id "mastodon-tl.el")
(defvar mastodon-tl--display-media-p)
diff --git a/lisp/mastodon-search.el b/lisp/mastodon-search.el
index 03301ce..2227d79 100644
--- a/lisp/mastodon-search.el
+++ b/lisp/mastodon-search.el
@@ -46,12 +46,6 @@
;; functions for company completion of mentions in mastodon-toot
-(defun mastodon-search--get-user-info (account)
- "Get user handle, display name and account URL from ACCOUNT."
- (list (cdr (assoc 'display_name account))
- (concat "@" (cdr (assoc 'acct account)))
- (cdr (assoc 'url account))))
-
(defun mastodon-search--search-accounts-query (query)
"Prompt for a search QUERY and return accounts synchronously.
Returns a nested list containing user handle, display name, and URL."
@@ -161,7 +155,8 @@ We use this to fetch the complete status from the server."
(defun mastodon-search--fetch-full-status-from-id (id)
"Fetch the full status with id ID from the server.
-This allows us to access the full account etc. details and to render them properly."
+This allows us to access the full account etc. details and to
+render them properly."
(let* ((url (concat mastodon-instance-url "/api/v1/statuses/" (mastodon-tl--as-string id)))
(json (mastodon-http--get-json url)))
json))
diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el
index 9bbc44f..e5ded3f 100644
--- a/lisp/mastodon-tl.el
+++ b/lisp/mastodon-tl.el
@@ -67,7 +67,7 @@
:group 'mastodon)
(defcustom mastodon-tl--enable-relative-timestamps t
- "Nonnil to enable showing relative (to the current time) timestamps.
+ "Whether to show relative (to the current time) timestamps.
This will require periodic updates of a timeline buffer to
keep the timestamps current as time progresses."
@@ -630,7 +630,10 @@ Used for a mouse-click EVENT on a link."
(mastodon-tl--do-link-action-at-point (posn-point (event-end event))))
(defun mastodon-tl--has-spoiler (toot)
- "Check if the given TOOT has a spoiler text that should initially be shown only while the main content should be hidden."
+ "Check if the given TOOT has a spoiler text.
+
+Spoiler text should initially be shown only while the main
+content should be hidden."
(let ((spoiler (mastodon-tl--field 'spoiler_text toot)))
(and spoiler (> (length spoiler) 0))))
diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el
index b0b7e13..7698226 100644
--- a/lisp/mastodon-toot.el
+++ b/lisp/mastodon-toot.el
@@ -43,24 +43,25 @@
(defvar mastodon-instance-url)
(autoload 'mastodon-auth--user-acct "mastodon-auth")
(autoload 'mastodon-http--api "mastodon-http")
-(autoload 'mastodon-http--post "mastodon-http")
-(autoload 'mastodon-http--triage "mastodon-http")
(autoload 'mastodon-http--delete "mastodon-http")
-(autoload 'mastodon-http--process-json "mastodon-http")
(autoload 'mastodon-http--get-json "mastodon-http")
+(autoload 'mastodon-http--get-json-async "mastodon-htpp")
+(autoload 'mastodon-http--post "mastodon-http")
+(autoload 'mastodon-http--post-media-attachment "mastodon-http")
+(autoload 'mastodon-http--process-json "mastodon-http")
+(autoload 'mastodon-http--read-file-as-string "mastodon-http")
+(autoload 'mastodon-http--triage "mastodon-http")
+(autoload 'mastodon-search--search-accounts-query "mastodon-search")
(autoload 'mastodon-tl--as-string "mastodon-tl")
(autoload 'mastodon-tl--clean-tabs-and-nl "mastodon-tl")
(autoload 'mastodon-tl--field "mastodon-tl")
(autoload 'mastodon-tl--find-property-range "mastodon-tl")
+(autoload 'mastodon-tl--find-property-range "mastodon-tl")
(autoload 'mastodon-tl--goto-next-toot "mastodon-tl")
(autoload 'mastodon-tl--property "mastodon-tl")
-(autoload 'mastodon-tl--find-property-range "mastodon-tl")
-(autoload 'mastodon-toot "mastodon")
-(autoload 'mastodon-http--post-media-attachment "mastodon-http")
-(autoload 'mastodon-http--read-file-as-string "mastodon-http")
-(autoload 'mastodon-tl--toot-id "mastodon-tl")
(autoload 'mastodon-tl--reload-timeline-or-profile "mastodon-tl")
-(autoload 'mastodon-search--search-accounts-query "mastodon-search")
+(autoload 'mastodon-tl--toot-id "mastodon-tl")
+(autoload 'mastodon-toot "mastodon")
(defgroup mastodon-toot nil
"Tooting in Mastodon."
@@ -70,7 +71,8 @@
(defcustom mastodon-toot--default-visibility "public"
"The default visibility for new toots.
-Must be one of \"public\", \"unlisted\", \"private\" (for followers-only), or \"direct\"."
+Must be one of \"public\", \"unlisted\", \"private\" (for
+followers-only), or \"direct\"."
:group 'mastodon-toot
:type '(choice
(const :tag "public" "public")
@@ -88,14 +90,17 @@ Must be one of \"public\", \"unlisted\", \"private\" (for followers-only), or \"
:group 'mastodon-toot
:type 'integer)
-(when (require 'company nil :noerror)
- (defcustom mastodon-toot--enable-completion-for-mentions "following"
- "Whether to enable company completion for mentions in toot compose buffer."
- :group 'mastodon-toot
- :type '(choice
- (const :tag "off" nil)
- (const :tag "following only" "following")
- (const :tag "all users" "all"))))
+(defcustom mastodon-toot--enable-completion-for-mentions (if (require 'company nil :noerror) "following" "off")
+ "Whether to enable company completion for mentions.
+
+Used for completion in toot compose buffer.
+
+This is only used if company mode is installed."
+ :group 'mastodon-toot
+ :type '(choice
+ (const :tag "off" nil)
+ (const :tag "following only" "following")
+ (const :tag "all users" "all")))
(defvar mastodon-toot--content-warning nil
"A flag whether the toot should be marked with a content warning.")