* 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.
(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."
"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