1 ;; 13-bbdb.el --- Big Brother DataBase (BBDB)
3 ;; Copyright (C) 2007 - 2020 Steve Youngs
5 ;; Author: Steve Youngs <steve@sxemacs.org>
6 ;; Maintainer: Steve Youngs <steve@sxemacs.org>
7 ;; Created: <2007-12-02>
8 ;; Time-stamp: <Thursday Apr 9, 2020 18:51:53 steve>
9 ;; Download: <https://downloads.sxemacs.org/SYinits>
10 ;; HTMLised: <https://www.sxemacs.org/SYinits/13-bbdb.html>
11 ;; Git Repo: git clone https://git.sxemacs.org/syinit
12 ;; Keywords: init, compile
14 ;; This file is part of SYinit
16 ;; Redistribution and use in source and binary forms, with or without
17 ;; modification, are permitted provided that the following conditions
20 ;; 1. Redistributions of source code must retain the above copyright
21 ;; notice, this list of conditions and the following disclaimer.
23 ;; 2. Redistributions in binary form must reproduce the above copyright
24 ;; notice, this list of conditions and the following disclaimer in the
25 ;; documentation and/or other materials provided with the distribution.
27 ;; 3. Neither the name of the author nor the names of any contributors
28 ;; may be used to endorse or promote products derived from this
29 ;; software without specific prior written permission.
31 ;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
32 ;; IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
33 ;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
34 ;; DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
35 ;; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
36 ;; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
37 ;; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
38 ;; BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
39 ;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
40 ;; OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
41 ;; IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
50 ;; The HTML version of this file was created with Hrvoje Niksic's
51 ;; htmlize.el which is part of the XEmacs "text-modes" package.
59 ;:*======================
60 ;:* Some standard stuff first
64 ;:*=======================
65 ;:* Make sure gnus stuff is loaded
66 (load-file (expand-file-name ".gnus" (user-home-directory)))
68 (bbdb-initialize 'gnus 'message 'w3 'sendmail)
70 (bbdb-insinuate-message)
72 (bbdb-insinuate-sendmail)
77 bbdb/pgp-method 'mml-pgpmime
78 bbdb/pgp-default-action 'sign
81 (defun sy-bbdb-gnus-auto-notes-hook (record)
82 "Runs `bbdb-auto-notes-hook' on the original article.
83 This is so a header doesn't have to be visible for BBDB to notice
85 Kudos to Robert Fenk <fenk@users.sf.net> for this."
87 (set-buffer (get-buffer gnus-article-buffer))
88 (set-buffer gnus-original-article-buffer)
89 (goto-char (point-min))
90 (bbdb-auto-notes-hook record)))
92 (autoload 'gnus-convert-face-to-png "gnus-fun")
94 ;;; FIXME: Not ideal, it currently puts cface at one end of the name,
95 ;;; and the xface at the other. I'd prefer both glyphs on the same
96 ;;; side (preferrably left)
97 (defun sy-bbdb-display-cx-face ()
98 "Search for face properties and display the faces.
99 This is from Alex Shroeder."
100 (let ((inhibit-read-only t); edit the BBDB buffer
101 (all-records bbdb-records)
102 cface xface record start ext)
104 (setq record (caar all-records)
105 cface (bbdb-record-getprop record 'cface)
106 xface (bbdb-record-getprop record 'face)
107 start (marker-position (nth 2 (car all-records))))
108 (when (or cface xface)
109 (setq ext (extent-at start)))
111 (set-extent-begin-glyph
114 (list (vector 'png :data (gnus-convert-face-to-png cface))))))
116 (set-extent-end-glyph
119 (list (vector 'xface :data (concat "X-Face: " xface)
121 :background "white")))))
122 (setq all-records (cddr all-records)))))
125 bbdb-always-add-addresses t
126 bbdb-canonicalize-redundant-nets-p t
127 bbdb-canonicalize-net-hook
131 "\\`\\([^0-9]+\\)\\(-dated-[^@]+\\|-[0-9]+\\|\\+[^@]+\\.[^@]+\\)\\(@.*\\)\\'"
133 (concat (substring addr (match-beginning 1) (match-end 1))
134 (substring addr (match-beginning 3) (match-end 3))))
136 bbdb-complete-name-allow-cycling t
137 bbdb-completion-display-record t
138 bbdb-completion-type 'primary-or-name
139 bbdb-default-area-code 7
140 bbdb-dial-local-prefix nil
141 bbdb-display-layout 'multi-line
142 bbdb-dwim-net-address-allow-redundancy t
144 bbdb-new-nets-always-primary 'never
145 bbdb-north-american-phone-numbers-p nil
146 bbdb-notice-hook 'sy-bbdb-gnus-auto-notes-hook
147 bbdb-offer-save 'auto
148 bbdb-pop-up-display-layout 'multi-line
149 bbdb-pop-up-target-lines 7
150 bbdb-quiet-about-name-mismatches nil
152 bbdb/gnus-score-default 25
153 bbdb/gnus-summary-in-bbdb-format-letter "X"
154 bbdb/mail-auto-create-p nil
155 bbdb/news-auto-create-p nil)
157 ;:*=======================
158 ;:* All my email addresses, well the important ones anyway.
159 (let ((emails '("steve@steveyoungs.com"
160 "steve@thereadinglamp.net"
161 "steve@bastard.steveyoungs.com"
162 "steve@bastard.no-ip.org"
164 "steve@sywriting.com"
165 "sryoungs@iinet.net.au"
166 "steve.r.youngs@gmail.com"
167 ;; The following aren't mine, but I'm using
168 ;; `bbdb-user-mail-names' in
169 ;; `gnus-ignored-from-addresses. It's just easier.
171 (setq bbdb-user-mail-names (regexp-opt emails t)))
173 ;:*=======================
174 ;:* Update some stuff automatically
175 (setq bbdb-auto-notes-alist
177 (".*" company 0 'replace))
179 ("[^,]+" newsgroups 0))
181 (".*" last-subj 0 'replace))
183 (".*" mailer 0 'replace))
185 (".*" mailer 0 'replace))
187 (".*" mailer 0 'replace))
189 (".*" attribution 0 'replace))
191 (".*" music 0 'replace))
193 (".+" face 0 'replace))
195 (".+" cface 0 'replace))))
197 ;:*=======================
199 (autoload 'bbdb-define-all-aliases "bbdb-com"
200 "Hook mail alias feature of BBDB into message-mode." t)
202 ;:*=======================
204 (add-hook 'bbdb-notice-hook 'bbdb-auto-notes-hook)
205 (add-hook 'bbdb-change-hook 'bbdb-timestamp-hook)
206 (add-hook 'bbdb-create-hook 'bbdb-creation-date-hook)
207 (add-hook 'bbdb-list-hook 'sy-bbdb-display-cx-face)
208 (add-hook 'message-setup-hook 'bbdb-define-all-aliases)
209 ;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*
210 (message "bbdb initialised")