https://github.com/unhammer/gnavatar
Elisp gravatar/bbdb-image wrapper
https://github.com/unhammer/gnavatar
avatar bbdb emacs gravatar
Last synced: 8 months ago
JSON representation
Elisp gravatar/bbdb-image wrapper
- Host: GitHub
- URL: https://github.com/unhammer/gnavatar
- Owner: unhammer
- Created: 2021-06-19T16:41:16.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2023-03-12T14:33:37.000Z (over 2 years ago)
- Last Synced: 2024-12-27T00:41:50.415Z (9 months ago)
- Topics: avatar, bbdb, emacs, gravatar
- Language: Emacs Lisp
- Homepage:
- Size: 8.79 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.org
Awesome Lists containing this project
README
#+TITLE: gnavatar
[[https://melpa.org/#/gnavatar][https://melpa.org/packages/gnavatar-badge.svg]]
[[https://stable.melpa.org/#/gnavatar][https://stable.melpa.org/packages/gnavatar-badge.svg]]* For users who want to override gravatar
If you want to use this instead of plain Gravatar everywhere, you can
use:
#+begin_src emacs-lisp
(advice-add 'gravatar-retrieve :around #'gnavatar-override)
#+end_srcFor e-mails that exist in Gravatar, you'll get a result from
Gravatar. If they aren't in Gravatar, it'll try BBDB, using the
=image-uri= xfield.Customize =gnavatar-providers= to change the priority (if you want to
try BBDB first).* Use as library to insert avatars
The API is exactly the same as gravatar.el:
#+begin_src emacs-lisp
(require 'gnavatar)
(let ((buf (current-buffer)))
(gnavatar-retrieve
"a-gravatar-user@example.org"
(lambda (i)
(with-current-buffer buf
(insert-image i)))))
#+end_srcIf you use it like this, your end-users don't have to add any advice.
* Interactive helpers to add images to BBDB
#+begin_src emacs-lisp
(require 'gnavatar-bbdb)
(define-key bbdb-mode-map (kbd "y") #'gnavatar-bbdb-add-clipboard-image-contents)
(define-key bbdb-mode-map (kbd "U") #'gnavatar-bbdb-add-clipboard-image-url)
#+end_srcNow you can copy an image and hit =y= or an image url and hit =U= on
a BBDB entry and it'll fill the image-uri field with that.If you want to show the images in BBDB:
#+begin_src emacs-lisp
(defun my-bbdb-image-size-ok (image)
"Is IMAGE small enough?"
(let* ((size (image-size image))
(w (car size))
(h (cdr size)))
(and (< w 10) (< h 10))))(defun my-bbdb-maybe-insert-image (record)
"If RECORD has an image that's small enough, insert it."
(when-let ((image (gnavatar-bbdb-create-image record)))
(when (my-bbdb-image-size-ok image)
(insert " ")
(insert-image image))))(advice-add #'bbdb-display-name-organization :after #'my-bbdb-maybe-insert-image)
#+end_src