X-Git-Url: https://git.hcoop.net/bpt/emacs.git/blobdiff_plain/8fff8988e612e861e1d9be9e624823013dcb8850..2db38a6f98c2abb42b746064ce97417cccc27e68:/lisp/net/eudcb-bbdb.el diff --git a/lisp/net/eudcb-bbdb.el b/lisp/net/eudcb-bbdb.el index 4a1b865736..0ddfa81a50 100644 --- a/lisp/net/eudcb-bbdb.el +++ b/lisp/net/eudcb-bbdb.el @@ -1,7 +1,7 @@ ;;; eudcb-bbdb.el --- Emacs Unified Directory Client - BBDB Backend ;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, -;; 2005, 2006, 2007 Free Software Foundation, Inc. +;; 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. ;; Author: Oscar Figueiredo ;; Maintainer: Pavel Janík @@ -9,10 +9,10 @@ ;; This file is part of GNU Emacs. -;; GNU Emacs is free software; you can redistribute it and/or modify +;; GNU Emacs 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 3, or (at your option) -;; any later version. +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. ;; GNU Emacs is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -20,9 +20,7 @@ ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License -;; along with GNU Emacs; see the file COPYING. If not, write to the -;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, -;; Boston, MA 02110-1301, USA. +;; along with GNU Emacs. If not, see . ;;; Commentary: ;; This library provides an interface to use BBDB as a backend of @@ -107,8 +105,7 @@ (declare-function bbdb-phone-location "ext:bbdb" t) ; via bbdb-defstruct (declare-function bbdb-phone-string "ext:bbdb" (phone)) (declare-function bbdb-record-phones "ext:bbdb" t) ; via bbdb-defstruct -;; FIXME: bbdb-address-street1/2/3 don't seem to exist in current -;; bbdb, so this code is probably broken. +(declare-function bbdb-address-streets "ext:bbdb" t) ; via bbdb-defstruct (declare-function bbdb-address-city "ext:bbdb" t) ; via bbdb-defstruct (declare-function bbdb-address-state "ext:bbdb" t) ; via bbdb-defstruct (declare-function bbdb-address-zip "ext:bbdb" t) ; via bbdb-defstruct @@ -130,25 +127,24 @@ (defun eudc-bbdb-extract-addresses (record) (let (s c val) - (mapcar (function - (lambda (address) - (setq val (concat (unless (= 0 (length (setq s (bbdb-address-street1 address)))) - (concat s "\n")) - (unless (= 0 (length (setq s (bbdb-address-street2 address)))) - (concat s "\n")) - (unless (= 0 (length (setq s (bbdb-address-street3 address)))) - (concat s "\n")) - (progn - (setq c (bbdb-address-city address)) - (setq s (bbdb-address-state address)) - (if (and (> (length c) 0) (> (length s) 0)) - (concat c ", " s " ") - (concat c " "))) - (bbdb-address-zip address))) - (if eudc-bbdb-use-locations-as-attribute-names - (cons (intern (bbdb-address-location address)) val) - (cons 'addresses (concat (bbdb-address-location address) "\n" val))))) - (bbdb-record-addresses record)))) + (mapcar (lambda (address) + (setq c (bbdb-address-streets address)) + (dotimes (n 3) + (unless (zerop (length (setq s (nth n c)))) + (setq val (concat val s "\n")))) + (setq c (bbdb-address-city address) + s (bbdb-address-state address)) + (setq val (concat val + (if (and (> (length c) 0) (> (length s) 0)) + (concat c ", " s) + c) + " " + (bbdb-address-zip address))) + (if eudc-bbdb-use-locations-as-attribute-names + (cons (intern (bbdb-address-location address)) val) + (cons 'addresses (concat (bbdb-address-location address) + "\n" val)))) + (bbdb-record-addresses record)))) (defun eudc-bbdb-format-record-as-result (record) "Format the BBDB RECORD as a EUDC query result record. @@ -246,5 +242,5 @@ RETURN-ATTRS is a list of attributes to return, defaulting to (provide 'eudcb-bbdb) -;;; arch-tag: 38276208-75de-4dbc-ba6f-8db684c32e0a +;; arch-tag: 38276208-75de-4dbc-ba6f-8db684c32e0a ;;; eudcb-bbdb.el ends here