Mercurial > emacs
comparison lisp/net/eudc-export.el @ 42570:78a4068d960a
Remove unnecessary whitespaces.
author | Pavel Janík <Pavel@Janik.cz> |
---|---|
date | Sun, 06 Jan 2002 15:08:06 +0000 |
parents | 7a94f1c588c4 |
children | fcac9cd201ad |
comparison
equal
deleted
inserted
replaced
42569:df3f717a3933 | 42570:78a4068d960a |
---|---|
42 RECORD is an alist of (KEY . VALUE) where KEY is a directory attribute name | 42 RECORD is an alist of (KEY . VALUE) where KEY is a directory attribute name |
43 symbol and VALUE is the corresponding value for the record. | 43 symbol and VALUE is the corresponding value for the record. |
44 If SILENT is non-nil then the created BBDB record is not displayed." | 44 If SILENT is non-nil then the created BBDB record is not displayed." |
45 ;; This function runs in a special context where lisp symbols corresponding | 45 ;; This function runs in a special context where lisp symbols corresponding |
46 ;; to field names in record are bound to the corresponding values | 46 ;; to field names in record are bound to the corresponding values |
47 (eval | 47 (eval |
48 `(let* (,@(mapcar '(lambda (c) | 48 `(let* (,@(mapcar '(lambda (c) |
49 (list (car c) (if (listp (cdr c)) | 49 (list (car c) (if (listp (cdr c)) |
50 (list 'quote (cdr c)) | 50 (list 'quote (cdr c)) |
51 (cdr c)))) | 51 (cdr c)))) |
52 record) | 52 record) |
84 '(name company net address phone notes))) | 84 '(name company net address phone notes))) |
85 (setq value (eudc-parse-spec (cdr mapping) record nil))) | 85 (setq value (eudc-parse-spec (cdr mapping) record nil))) |
86 (cons (car mapping) value)))) | 86 (cons (car mapping) value)))) |
87 conversion-alist))) | 87 conversion-alist))) |
88 (setq bbdb-notes (delq nil bbdb-notes)) | 88 (setq bbdb-notes (delq nil bbdb-notes)) |
89 (setq bbdb-record (bbdb-create-internal bbdb-name | 89 (setq bbdb-record (bbdb-create-internal bbdb-name |
90 bbdb-company | 90 bbdb-company |
91 bbdb-net | 91 bbdb-net |
92 bbdb-address | 92 bbdb-address |
93 bbdb-phones | 93 bbdb-phones |
94 bbdb-notes)) | 94 bbdb-notes)) |
95 (or silent | 95 (or silent |
96 (bbdb-display-records (list bbdb-record)))))) | 96 (bbdb-display-records (list bbdb-record)))))) |
97 | 97 |
98 (defun eudc-parse-spec (spec record recurse) | 98 (defun eudc-parse-spec (spec record recurse) |
99 "Parse the conversion SPEC using RECORD. | 99 "Parse the conversion SPEC using RECORD. |
100 If RECURSE is non-nil then SPEC may be a list of atomic specs." | 100 If RECURSE is non-nil then SPEC may be a list of atomic specs." |
101 (cond | 101 (cond |
102 ((or (stringp spec) | 102 ((or (stringp spec) |
103 (symbolp spec) | 103 (symbolp spec) |
104 (and (listp spec) | 104 (and (listp spec) |
105 (symbolp (car spec)) | 105 (symbolp (car spec)) |
106 (fboundp (car spec)))) | 106 (fboundp (car spec)))) |
147 ((string-match "\\([0-9]+\\)[ \t]+\\(.*\\)" last1) | 147 ((string-match "\\([0-9]+\\)[ \t]+\\(.*\\)" last1) |
148 (setq city (match-string 2 last1) | 148 (setq city (match-string 2 last1) |
149 zip (string-to-number (match-string 1 last1)))) | 149 zip (string-to-number (match-string 1 last1)))) |
150 (t | 150 (t |
151 (error "Cannot parse the address")))) | 151 (error "Cannot parse the address")))) |
152 (vector location | 152 (vector location |
153 (or (nth 0 addr-components) "") | 153 (or (nth 0 addr-components) "") |
154 (or (nth 1 addr-components) "") | 154 (or (nth 1 addr-components) "") |
155 (or (nth 2 addr-components) "") | 155 (or (nth 2 addr-components) "") |
156 (or city "") | 156 (or city "") |
157 (or state "") | 157 (or state "") |
160 (defun eudc-bbdbify-phone (phone location) | 160 (defun eudc-bbdbify-phone (phone location) |
161 "Parse PHONE into a vector compatible with BBDB. | 161 "Parse PHONE into a vector compatible with BBDB. |
162 PHONE is either a string supposedly containing a phone number or | 162 PHONE is either a string supposedly containing a phone number or |
163 a list of such strings which are concatenated. | 163 a list of such strings which are concatenated. |
164 LOCATION is used as the phone location for BBDB." | 164 LOCATION is used as the phone location for BBDB." |
165 (cond | 165 (cond |
166 ((stringp phone) | 166 ((stringp phone) |
167 (let (phone-list) | 167 (let (phone-list) |
168 (condition-case err | 168 (condition-case err |
169 (setq phone-list (bbdb-parse-phone-number phone)) | 169 (setq phone-list (bbdb-parse-phone-number phone)) |
170 (error | 170 (error |
178 (apply 'vector location phone-list))) | 178 (apply 'vector location phone-list))) |
179 ((listp phone) | 179 ((listp phone) |
180 (vector location (mapconcat 'identity phone ", "))) | 180 (vector location (mapconcat 'identity phone ", "))) |
181 (t | 181 (t |
182 (error "Invalid phone specification")))) | 182 (error "Invalid phone specification")))) |
183 | 183 |
184 (defun eudc-batch-export-records-to-bbdb () | 184 (defun eudc-batch-export-records-to-bbdb () |
185 "Insert all the records returned by a directory query into BBDB." | 185 "Insert all the records returned by a directory query into BBDB." |
186 (interactive) | 186 (interactive) |
187 (goto-char (point-min)) | 187 (goto-char (point-min)) |
188 (let ((nbrec 0) | 188 (let ((nbrec 0) |