aboutsummaryrefslogtreecommitdiff
path: root/lisp/mastodon-media.el
diff options
context:
space:
mode:
authorHolger Dürer <me@hdurer.net>2017-05-16 21:09:58 +0100
committerJohnson Denen <johnson.denen@gmail.com>2017-05-18 10:21:21 -0400
commitfe8e4386eacb358df0e16dc5bd37dde4f4d6d57c (patch)
tree2329c867ca4d8434e6e2200aae4f827e7f2a9165 /lisp/mastodon-media.el
parent5f41086d3a03e8781aab77ab17f4d4f95263e07c (diff)
Remove most byte-compile warnings.
We do this by - moving vars into the files where they are (mostly) used - "declaring" vars used elsewhere with the (defvar <var-name>) pattern, - declaring functions defined in others functions rather than loading the file via require.
Diffstat (limited to 'lisp/mastodon-media.el')
-rw-r--r--lisp/mastodon-media.el25
1 files changed, 14 insertions, 11 deletions
diff --git a/lisp/mastodon-media.el b/lisp/mastodon-media.el
index b3565d0..671f159 100644
--- a/lisp/mastodon-media.el
+++ b/lisp/mastodon-media.el
@@ -32,16 +32,20 @@
;; required by the server and client.
;;; Code:
-(require 'mastodon-http nil t)
-
(defgroup mastodon-media nil
"Inline Mastadon media."
:prefix "mastodon-media-"
:group 'mastodon)
-(defvar mastodon-media-show-avatars-p
- (image-type-available-p 'imagemagick)
- "A boolean value stating whether to show avatars in timelines.")
+(defcustom mastodon-media--avatar-height 30
+ "Height of the user avatar images (if shown)."
+ :group 'mastodon-media
+ :type 'integer)
+
+(defcustom mastodon-media--preview-max-height 250
+ "Max height of any media attachment preview to be shown."
+ :group 'mastodon-media
+ :type 'integer)
(defvar mastodon-media--generic-avatar-data
(base64-decode-string
@@ -121,14 +125,13 @@ BAIQCEAgAIEABAIsJVH58WqHw8FIgjUIQCAACAQgEIBAAAIBCAQgEIBAAAIBCAQgEAAEAhAIQCBA
fKRJkmVZjAQwh78A6vCRWJE8K+8AAAAASUVORK5CYII=")
"The PNG data for a generic 200x200 'broken image' view")
-(defun mastodon-media--process-image-response (status-plist marker image-options region-length image-url)
+(defun mastodon-media--process-image-response (status-plist marker image-options region-length)
"Callback function processing the url retrieve response for URL.
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.
-IMAGE-URL is the URL that was retrieved.
"
(let ((url-buffer (current-buffer))
(is-error-response-p (eq :error (car status-plist))))
@@ -164,12 +167,12 @@ MEDIA-TYPE is a symbol and either 'avatar or 'media-link."
(let ((image-options (when (image-type-available-p 'imagemagick)
(cond
((eq media-type 'avatar)
- `(:height ,mastodon-avatar-height))
+ `(:height ,mastodon-media--avatar-height))
((eq media-type 'media-link)
- `(:max-height ,mastodon-preview-max-height))))))
+ `(:max-height ,mastodon-media--preview-max-height))))))
(url-retrieve url
#'mastodon-media--process-image-response
- (list (copy-marker start) image-options region-length url))))
+ (list (copy-marker start) image-options region-length))))
(defun mastodon-media--select-next-media-line ()
"Find coordinates of the next media to load.
@@ -225,7 +228,7 @@ not been returned."
;; This is what a user will see on a non-graphical display
;; where not showing an avatar at all is preferable.
(let ((image-options (when (image-type-available-p 'imagemagick)
- `(:height ,mastodon-avatar-height))))
+ `(:height ,mastodon-media--avatar-height))))
(concat
(propertize " "
'media-url avatar-url