;; 08-bbdb-sy.el --- Big Brother DataBase (BBDB) -*- Emacs-Lisp -*- ;; Copyright (C) 2007 - 2012 Steve Youngs ;; Author: Steve Youngs ;; Maintainer: Steve Youngs ;; Created: <2007-12-02> ;; Time-stamp: ;; Download: ;; HTMLised: ;; Git Repo: git clone http://git.sxemacs.org/syinit ;; Keywords: init, compile ;; This file is part of SYinit ;; Redistribution and use in source and binary forms, with or without ;; modification, are permitted provided that the following conditions ;; are met: ;; ;; 1. Redistributions of source code must retain the above copyright ;; notice, this list of conditions and the following disclaimer. ;; ;; 2. Redistributions in binary form must reproduce the above copyright ;; notice, this list of conditions and the following disclaimer in the ;; documentation and/or other materials provided with the distribution. ;; ;; 3. Neither the name of the author nor the names of any contributors ;; may be used to endorse or promote products derived from this ;; software without specific prior written permission. ;; ;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR ;; IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ;; DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE ;; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR ;; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ;; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ;; BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ;; OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ;; IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ;;; Commentary: ;; ;; BBDB settings. ;; ;;; Credits: ;; ;; The HTML version of this file was created with Hrvoje Niksic's ;; htmlize.el which is part of the XEmacs "text-modes" package. ;; ;;; Todo: ;; ;; ;;; Code: ;:*======================= ;:* Make sure gnus stuff is loaded (load-file (expand-file-name ".gnus" (user-home-directory))) ;:*====================== ;:* Some standard stuff first (require 'bbdb) (require 'bbdb-pgp) (bbdb-initialize 'gnus 'message 'w3 'sendmail) (bbdb-insinuate-gnus) (bbdb-insinuate-message) (bbdb-insinuate-sc) (bbdb-insinuate-sendmail) (bbdb-insinuate-w3) ;; BBDB/PGP stuff (setq bbdb/pgp-method 'mml-pgpmime bbdb/pgp-default-action 'sign bbdb/pgp-quiet t) (defun sy-bbdb-gnus-auto-notes-hook (record) "Runs `bbdb-auto-notes-hook' on the original article. This is so a header doesn't have to be visible for BBDB to notice any changes. Kudos to Robert Fenk for this." (save-excursion (set-buffer (get-buffer gnus-article-buffer)) (set-buffer gnus-original-article-buffer) (goto-char (point-min)) (bbdb-auto-notes-hook record))) (autoload 'gnus-convert-face-to-png "gnus-fun") (defun sy-bbdb-display-cx-face () "Search for face properties and display the faces. This is from Alex Shroeder." (let ((inhibit-read-only t); edit the BBDB buffer (all-records bbdb-records) cface xface record start) (while all-records (setq record (caar all-records) cface (bbdb-record-getprop record 'cface) xface (bbdb-record-getprop record 'face) start (marker-position (nth 2 (car all-records)))) (when cface (set-extent-begin-glyph (make-extent start start) (make-glyph (list (vector 'png :data (gnus-convert-face-to-png cface))))) (insert " ")) (when xface (set-extent-begin-glyph (make-extent start start) (make-glyph (list (vector 'xface :data (concat "X-Face: " xface) :foreground "black" :background "white")))) (insert " ")) (setq all-records (cddr all-records))))) (setq bbdb-always-add-addresses t bbdb-canonicalize-redundant-nets-p t bbdb-canonicalize-net-hook (lambda (addr) (cond ((string-match "\\`\\([^0-9]+\\)\\(-dated-[^@]+\\|-[0-9]+\\|\\+[^@]+\\.[^@]+\\)\\(@.*\\)\\'" addr) (concat (substring addr (match-beginning 1) (match-end 1)) (substring addr (match-beginning 3) (match-end 3)))) (t addr))) bbdb-complete-name-allow-cycling t bbdb-completion-display-record t bbdb-completion-type 'primary-or-name bbdb-default-area-code 7 bbdb-dial-local-prefix nil bbdb-display-layout 'multi-line bbdb-dwim-net-address-allow-redundancy t bbdb-electric-p nil bbdb-new-nets-always-primary 'never bbdb-north-american-phone-numbers-p nil bbdb-notice-hook 'sy-bbdb-gnus-auto-notes-hook bbdb-offer-save 'auto bbdb-pop-up-display-layout 'multi-line bbdb-pop-up-target-lines 7 bbdb-quiet-about-name-mismatches nil bbdb-use-pop-up nil bbdb/gnus-score-default 25 bbdb/gnus-summary-in-bbdb-format-letter "X" bbdb/mail-auto-create-p nil bbdb/news-auto-create-p nil) ;:*======================= ;:* All my email addresses, well the important ones anyway. (let ((emails '("steve@steveyoungs.com" "steve@thereadinglamp.net" "steve@bastard.steveyoungs.com" "steve@sxemacs.org" "steve@emchat.org" "sryoungs@iinet.net.au" "jackalx@gmail.com"))) (setq bbdb-user-mail-names (regexp-opt emails t))) ;:*======================= ;:* Update some stuff automatically (setq bbdb-auto-notes-alist '(("Organization" (".*" company 0 'replace)) ("Newsgroups" ("[^,]+" newsgroups 0)) ("Subject" (".*" last-subj 0 'replace)) ("User-Agent" (".*" mailer 0 'replace)) ("X-Mailer" (".*" mailer 0 'replace)) ("X-Newsreader" (".*" mailer 0 'replace)) ("X-Attribution" (".*" attribution 0 'replace)) ("X-Now-Playing" (".*" music 0 'replace)) ("X-Face" (".+" face 0 'replace)) ("Face" (".+" cface 0 'replace)))) ;:*======================= ;:* mail aliases (autoload 'bbdb-define-all-aliases "bbdb-com" "Hook mail alias feature of BBDB into message-mode." t) ;:*======================= ;:* Hooks (add-hook 'bbdb-notice-hook 'bbdb-auto-notes-hook) (add-hook 'bbdb-change-hook 'bbdb-timestamp-hook) (add-hook 'bbdb-create-hook 'bbdb-creation-date-hook) (add-hook 'bbdb-list-hook 'sy-bbdb-display-cx-face) (add-hook 'message-setup-hook 'bbdb-define-all-aliases) ;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::* (message "bbdb initialised")