aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sx-question-print.el9
-rw-r--r--test/test-api.el19
2 files changed, 20 insertions, 8 deletions
diff --git a/sx-question-print.el b/sx-question-print.el
index 84dbe44..56481cf 100644
--- a/sx-question-print.el
+++ b/sx-question-print.el
@@ -162,8 +162,13 @@ replaced with the comment."
(const :tag "More active first" sx-answer-more-active-p))
:group 'sx-question-mode)
-(defcustom sx-question-mode-use-images t
- "Non-nil if SX should download and display images."
+(defcustom sx-question-mode-use-images
+ (eval-when-compile
+ (image-type-available-p 'imagemagick))
+ "Non-nil if SX should download and display images.
+By default, this is `t' if the `imagemagick' image type is
+available (checked with `image-type-available-p'). If this image
+type is not available, images won't work."
:type 'boolean
:group 'sx-question-mode)
diff --git a/test/test-api.el b/test/test-api.el
index 0715a2e..faf2e0a 100644
--- a/test/test-api.el
+++ b/test/test-api.el
@@ -18,12 +18,19 @@
(ert-deftest request-get-url ()
(should (sx-request-get-url "http://google.com"))
(should-error (sx-request-get-url "http://github.com/Bruce-Connor/does-not-exist"))
- (should
- ;; If image is not recognized, this returns nil.
- (create-image (sx-request-get-url "https://raw.githubusercontent.com/vermiculus/sx.el/master/list-and-question.png")
- 'imagemagick t
- :width (min sx-question-mode-image-max-width
- (window-body-width nil 'pixel)))))
+ (when sx-question-mode-use-images
+ (should
+ ;; If image is not recognized, this returns nil.
+ (create-image (sx-request-get-url "https://raw.githubusercontent.com/vermiculus/sx.el/master/list-and-question.png")
+ 'imagemagick t
+ :width sx-question-mode-image-max-width)))
+ ;; In case imagemacgick is not available, let's try png so we at
+ ;; least test the function.
+ (when (image-type-available-p 'png)
+ (should
+ (create-image (sx-request-get-url "https://raw.githubusercontent.com/vermiculus/sx.el/master/list-and-question.png")
+ 'png t
+ :width sx-question-mode-image-max-width))))
(ert-deftest request-get-data ()
(should-error (sx-request-get-data "tags/emacs-does-not-exist"))