Commit 50a12de8 authored by Lars Ingebrigtsen's avatar Lars Ingebrigtsen

Make gravatar-build-url respect dynamically bound variables again

* lisp/image/gravatar.el (gravatar-build-url): Compute
query-string first, so that dynamically bound values of
`gravatar-rating' (etc.) are respected, instead of computing it
when the callback happens.
parent 5c631309
Pipeline #6178 failed with stage
in 8 seconds
......@@ -188,14 +188,15 @@ to track whether you're reading a specific mail."
(defun gravatar-build-url (mail-address callback)
"Find the URL of a gravatar for MAIL-ADDRESS and call CALLBACK with it."
;; https://gravatar.com/site/implement/images/
(funcall (alist-get gravatar-service gravatar-service-alist)
mail-address
(lambda (url)
(funcall callback
(format "%s/%s?%s"
url
(gravatar-hash mail-address)
(gravatar--query-string))))))
(let ((query-string (gravatar--query-string)))
(funcall (alist-get gravatar-service gravatar-service-alist)
mail-address
(lambda (url)
(funcall callback
(format "%s/%s?%s"
url
(gravatar-hash mail-address)
query-string))))))
(defun gravatar-get-data ()
"Return body of current URL buffer, or nil on failure."
......
......@@ -65,8 +65,13 @@
"Test `gravatar-build-url'."
(let ((gravatar-default-image nil)
(gravatar-force-default nil)
(gravatar-size nil))
(should (equal (gravatar-build-url "foo") "\
(gravatar-size nil)
(gravatar-service 'gravatar)
url)
(gravatar-build-url "foo" (lambda (u) (setq url u)))
(while (not url)
(sleep-for 0.01))
(should (equal url "\
https://www.gravatar.com/avatar/acbd18db4cc2f85cedef654fccc4a4d8?r=g"))))
;;; gravatar-tests.el ends here
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment