;;; bbdb-picture.el --- picture support for bbdb ;;; Commentary: ;;; This mode display pictures next to name and company. Picture are ;;; looked in to `bbbd-picture-path' with extension ;;; `bbdb-picture-extension'. For example say you have a record name ;;; of "Ivan Kanis" and `bbbd-picture-path' is set to "~/picture" and ;;; `bbdb-picture-extension' to ".png" you would save the image as ;;; "~/picture/Ivan Kanis.png. ;;; THANKS: ;;; BUGS: ;;; INSTALLATION: ;;; Put this file somewhere in your load-path then stick this in your ;;; .emacs ;;; (require 'bbdb-picture.el) ;;; Code: (require 'bbdb) (defvar bbdb-picture-path "~/picture/" "Directory where pictures are stored. Don't forget to put a trailing slash.") (defvar bbdb-picture-extension ".png" "Extension of your picture.") (defun bbdb-picture-display-image (name) "Search for face properties and display the faces." (let* ((image-file (concat bbdb-picture-path name bbdb-picture-extension)) (image (if (file-exists-p image-file) (create-image image-file)))) (if image (progn (insert " ") (insert-image image))))) (defun bbdb-format-record-name-company (record) "Display name, company and picture. Override function defined in bbdb.el." (let ((name (or (bbdb-record-name record) "???")) (company (bbdb-record-company record)) (start (point))) (insert name) (put-text-property start (point) 'bbdb-field '(name)) (bbdb-picture-display-image name) (when company (insert " - ") (setq start (point)) (insert company) (put-text-property start (point) 'bbdb-field '(company))))) (provide 'bbdb-picture) ;; Local Variables: ;; compile-command: "make" ;; End: ;; Copyright (C) 2009 Ivan Kanis ;; Author: Ivan Kanis ;; $Id$ ;; ;; This program is free software ; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation ; either version 2 of the License, or ;; (at your option) any later version. ;; ;; This program is distributed in the hope that it will be useful, but ;; WITHOUT ANY WARRANTY ; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; General Public License for more details. ;; ;; You should have received a copy of the GNU General Public License ;; along with this program ; if not, write to the Free Software ;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA