Function: gravatar-retrieve
gravatar-retrieve is an autoloaded and byte-compiled function defined
in gravatar.el.gz.
Signature
(gravatar-retrieve MAIL-ADDRESS CALLBACK &optional CBARGS)
Documentation
Asynchronously retrieve a gravatar for MAIL-ADDRESS.
When finished, call CALLBACK as (apply CALLBACK GRAVATAR CBARGS),
where GRAVATAR is either an image descriptor, or the symbol
error if the retrieval failed.
Source Code
;; Defined in /usr/src/emacs/lisp/image/gravatar.el.gz
;;;###autoload
(defun gravatar-retrieve (mail-address callback &optional cbargs)
"Asynchronously retrieve a gravatar for MAIL-ADDRESS.
When finished, call CALLBACK as (apply CALLBACK GRAVATAR CBARGS),
where GRAVATAR is either an image descriptor, or the symbol
`error' if the retrieval failed."
(let ((cached (gethash mail-address gravatar--cache)))
(gravatar--prune-cache)
(if cached
(apply callback (cdr cached) cbargs)
;; Nothing in the cache, fetch it.
(gravatar-build-url
mail-address
(lambda (url)
(url-retrieve
url
(lambda (status)
(let* ((data (and (not (plist-get status :error))
(gravatar-get-data)))
(image (and data (create-image data nil t))))
;; Store the image in the cache.
(when image
(setf (gethash mail-address gravatar--cache)
(cons (time-convert nil 'integer)
image)))
(prog1
(apply callback (if data image 'error) cbargs)
(kill-buffer))))
nil t))))))