summaryrefslogtreecommitdiff
path: root/bits/bbdb-obsolete.el
blob: 1dac1c36dfb6fe01e2a603f3bb3c66b654c26ce7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
;;; bbdb-obsolete-net.el -- Handle obsolete-net addresses.

;; Copyright (C) 2001 Colin Rafferty

;; Author: Colin Rafferty <colin@xemacs.org>
;; Keywords: bbdb, net, obsolete

;; 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, 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.

;; A copy of the GNU General Public License can be obtained from this
;; program's author (send electronic mail to colin@xemacs.org) or from
;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.

;; Send bug reports to colin@xemacs.org

;;; Commentary:

;; My ~/.bbdb is seven years old.  People change jobs, change ISPs,
;; and change nyms.  Their email addresses change.

;; While I no longer want to send someone email at an old address, I
;; still have old messages with the old addresses, and I want to match
;; up.

;; Move the old addresses into the field `obsolete-net', and:

;; (setq 'bbdb-obsolete-net-canonicalize-net-hook 'bbdb-canonicalize-net-hook)

;; If you already have a `bbdb-obsolete-net-canonicalize-net-hook',
;; then call `bbdb-canonicalize-net-hook' from within your function.

;;; Code:

(require 'bbdb-com)

(defgroup bbdb-obsolete-net nil
  "Customizations for setting up obsolete network addresses."
  :group 'bbdb)

(defcustom bbdb-obsolete-net-field 'obsolete-net
  "*Field in which to add the obsolete net addresses."
  :group 'bbdb-obsolete-net
  :type 'symbol)

;;;###autoload
(defun bbdb-obsolete-net-canonicalize-net-hook (addr)
  "Return user's current net address given obsolete ADDR.

Return ADDR if it is not obsolete anywhere, or there is no net address
in the matching record.  The field is set in `bbdb-obsolete-net-field'."
  (let* ((notes (cons bbdb-obsolete-net-field (concat "\\<" (regexp-quote addr) "\\>")))
         (records (bbdb-search (bbdb-records) nil nil nil notes)))
    (or (and (not (null records)) (car (bbdb-record-net (car records)))) addr)))

(provide 'bbdb-obsolete-net)

;;; bbdb-obsolete-net.el ends here