1
;;; Copyright (C) 1998,2000 by Niels Elgaard Larsen <elgaard@diku.dk>
3
;;; $Log: bbdb-ldif.el,v $
4
;;; Revision 1.1 2006/02/04 15:35:15 joerg
7
;;; Revision 1.1 2005/02/13 14:16:03 waider
8
;;; * added new file, with minor abuse to make it work with current BBDB
10
;;; Revision 1.7 2000/03/15 14:16:44 elgaard
11
;;; Fixed problem with concatenation of strings/integers
12
;;; Changed mobiletelephonenumber to cellphone to follow Netscape :-(
13
;;; Added support for pagerphone
15
;;; Revision 1.6 1998/09/08 12:35:27 elgaard
16
;;; Works with xemacs, emacs, emacs-19.34, bbdb-2 and bbdb-1.51
20
;; Can export mail-alias'es and .mailrc aliases to Netscape Mailing List
25
;; Compiles without MEL
28
;; Notes work better now
29
;; added 'bbdb-elided-export-ldif'
32
;; This program is free software; you can redistribute it and/or modify
33
;; it under the terms of the GNU General Public License as published by
34
;; the Free Software Foundation; either version 2 of the License, or
35
;; (at your option) any later version.
37
;; This program is distributed in the hope that it will be useful,
38
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
39
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
40
;; GNU General Public License for more details.
42
;; You should have received a copy of the GNU General Public License
43
;; along with this program; if not, write to the Free Software
44
;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
46
;; Niels Elgaard Larsen, <URL:mailto:elgaard@diku.dk>
49
;; bbdb-import-ldif imports LDIF entries
50
;; bbdb-to-ldif export bbdb to LDIF.
52
;; Both functions are somewhat specialized for Netscape Communicator (and Mozilla)
58
;;; Put (add-hook 'bbdb-load-hook (function (lambda () (require 'bbdb-ldif))))
59
;;; into your .emacs, or autoload it.
62
;; If you use non-ASCII characters recode the output file from emacs:
63
;; "recode ..UTF-8 output.ldif"
64
;; and the input file from Netscape:
65
;; "recode UTF-8.. i2.ldif "
66
;;;;;; Does not work for base-64 encoded text.
70
;; WAIDER MOD FEB 2005
71
;; deprecated functions. I should fix the code rather than do this, but.
72
(defun bbdb-address-street1(addr)
73
(nth 0 (bbdb-address-streets addr)))
74
(defun bbdb-address-street2(addr)
75
(nth 1 (bbdb-address-streets addr)))
76
(defun bbdb-address-street3(addr)
77
(nth 2 (bbdb-address-streets addr)))
79
(if (locate-library "mel") (require 'mel)
80
(message "We try without MEL (base64 operation), multiline fields will not work"
84
(if (fboundp 'split-string) nil
85
(defun split-string (string &optional pattern)
86
"Return a list of substrings of STRING which are separated by PATTERN.
87
If PATTERN is omitted, it defaults to \"[ \\f\\t\\n\\r\\v]+\"."
89
(setq pattern "[ \f\t\n\r\v]+"))
90
;; The FSF version of this function takes care not to cons in case
91
;; of infloop. Maybe we should synch?
92
(let (parts (start 0))
93
(while (string-match pattern string start)
94
(setq parts (cons (substring string start (match-beginning 0)) parts)
96
(nreverse (cons (substring string start) parts))))
99
(if (fboundp 'caadr) nil (defun caadr (foo) (car (car (cdr foo)))))
103
(defvar bbdb-ldif-nsnil "?" "Null name for Netscape")
106
(if (equal st bbdb-ldif-nsnil)
110
(defvar bbdb-elided-export-ldif nil "Set this to a list of some
111
of the symbols '(address phone net notes) to select those fields to be left
112
out when exporting to LDIF format"
115
;(require 'bbdb-snarf)
119
(defvar bbdb-ldif-prefix "xbbdb")
120
(defvar bbdb-ldif-prefixh "xhbbdb")
122
;;;; From bbdb-snarf with bugfix:
123
(defun bbdb-merge-internally-ldif (old-record new-record)
124
"Merge two records. NEW-RECORDS wins over OLD in cases of ties."
125
(if (and (null (bbdb-record-firstname new-record))
126
(bbdb-record-firstname old-record))
127
(bbdb-record-set-firstname new-record (bbdb-record-firstname old-record)))
128
(if (and (null (bbdb-record-lastname new-record))
129
(bbdb-record-lastname old-record))
130
(bbdb-record-set-lastname new-record (bbdb-record-lastname old-record)))
131
(if (and (null (bbdb-record-company new-record))
132
(bbdb-record-company old-record))
133
(bbdb-record-set-company new-record (bbdb-record-company old-record)))
135
(let ((old-nets (bbdb-record-net old-record))
136
(new-nets (bbdb-record-net new-record)))
138
(if (not (member (car old-nets) new-nets))
139
(setq new-nets (append new-nets (list (car old-nets)))))
140
(setq old-nets (cdr old-nets)))
141
(bbdb-record-set-net new-record new-nets))
143
(let ((old-addresses (bbdb-record-addresses old-record))
144
(new-addresses (bbdb-record-addresses new-record)))
146
(if (not (member (car old-addresses) new-addresses))
147
(setq new-addresses (append new-addresses (list (car old-addresses)))))
148
(setq old-addresses (cdr old-addresses)))
149
(bbdb-record-set-addresses new-record new-addresses))
151
(let ((old-phones (bbdb-record-phones old-record))
152
(new-phones (bbdb-record-phones new-record)))
154
(if (not (member (car old-phones) new-phones))
155
(setq new-phones (append new-phones (list (car old-phones)))))
156
(setq old-phones (cdr old-phones)))
157
(bbdb-record-set-phones new-record new-phones))
159
(let ((old-notes (bbdb-ensure-list (bbdb-record-raw-notes old-record)))
160
(new-notes (bbdb-ensure-list (bbdb-record-raw-notes new-record))))
162
(if (not (member (car old-notes) new-notes))
163
(setq new-notes (append new-notes (list (car old-notes)))))
164
(setq old-notes (cdr old-notes)))
165
(bbdb-record-set-raw-notes new-record new-notes))
169
(defun bbdb-ensure-list (foo)
175
(defun bbdb-zulu (date)
176
(if (fboundp 'bbdb-time-convert)
177
(bbdb-time-convert date "%Y%m%d%H%Mz")
178
date ;; bbdb1.51 does not use it anyway.
182
(defun bbdb-unzulu (date)
183
(if (eq (length date) 13)
184
(format "%s-%s-%s" (substring date 0 4) (substring date 4 6) (substring date 6 8))
187
(defun bbdb-ldif-indent (str)
188
(if (> (length str) 70)
189
(concat (substring str 0 65) "\n " (bbdb-ldif-indent (substring str 65)))
193
(defun addnote (nrec nname note)
194
(bbdb-record-set-raw-notes
195
nrec (cons (cons nname note) (bbdb-record-raw-notes nrec) )
199
(defmacro alias-update ()
200
(if (fboundp 'bbdb-define-all-aliases) (list 'bbdb-define-all-aliases))
203
(defmacro alias-setup ()
204
(if (fboundp 'mail-aliases-setup) (list 'mail-aliases-setup))
207
(defmacro domailaliases ()
208
(fboundp 'mail-aliases-setup)
212
(defmacro dodenote (st)
213
(if (fboundp 'base64-decode-string)
214
(list 'base64-decode-string st)
219
(defun addtonote (ton str)
221
((and ton str) (concat ton "\n" str))
222
(str (concat "--bbdb--\n" str))
227
(defun setaddr (nrec afun val)
228
(if (not (bbdb-record-addresses nrec))
229
(let ((addr(make-vector bbdb-address-length "")))
230
(bbdb-record-set-addresses nrec (list addr))
231
(bbdb-address-set-location addr "address")
234
(eval (list afun (car (bbdb-record-addresses nrec)) val))
238
(defun setphone (nrec iloc pno np)
239
(let ((nov (bbdb-parse-phone-number pno))
240
(pv (make-vector bbdb-phone-length ""))
243
(if (and np (equal (car np) (concat bbdb-ldif-prefixh "PhoneLoc")))
247
(if (and nov bbdb-north-american-phone-numbers-p)
249
(bbdb-phone-set-location pv ploc)
250
(bbdb-phone-set-area pv (nth 0 nov))
251
(bbdb-phone-set-exchange pv (nth 1 nov))
252
(bbdb-phone-set-suffix pv (nth 2 nov))
253
(bbdb-phone-set-extension pv (or (nth 3 nov) 0))
255
(setq pv (vector ploc pno))
257
(bbdb-record-set-phones nrec(append (bbdb-record-phones nrec)(list pv)))
261
(defun bbdb-string-fetch (key mls)
262
(let ((tmls (car mls)) res)
263
(while (and (not res) (car tmls))
264
(if (string-match (format "%s= *\\(.+\\)" key) (car tmls))
265
(setq res (match-string 1 (car tmls))))
266
(setq tmls (cdr tmls)))
271
(defun bbdb-ldif-get-phone (atts df)
272
(if (and (cdr atts) (equal (concat bbdb-ldif-prefixh "phoneloc") (caadr atts)))
277
(defun bbdb-import-ldif ()
278
"import LDIF entries for current buffer
279
Mailinglists \(groupOfNames\) are imported as entries in bbdb mail-alias fields."
281
; (message (concat (/(* 100 (point)) (point-max)) " pct\n"))
282
;; (message (concat "\nnew rec at" (point)))
283
(let ((reclist (split-string (buffer-substring 1 (point-max)) "\n[ \t\r]*\n"))
284
(numr 0) maxr (opct 0) pct mailinglists (emptyrec (make-vector bbdb-record-length nil))
286
(setq maxr (length reclist))
289
(if (not (equal "" rec))
291
(atts (mapcar (lambda (at)
292
(if (equal (string-to-char at) ?\ )
293
(cons 'continuation (substring at 1))
294
(let ( (cpos (string-match ":" at)))
296
(let ((cpos2 ( string-match "[^ \t]" at (1+ cpos))))
298
(cons (substring at 0 cpos) (substring at cpos2))
305
(split-string rec "[\n\r]+"))
308
(setq pct (/ (* 100 numr) maxr))
312
(message (concat pct " pct"))
315
(setq numr (1+ numr))
317
(if (member '("objectclass" . "groupOfNames") atts)
321
(let ((attName (downcase (caar atts)))
324
(while (and (cdr atts) (equal (caadr atts) 'continuation))
325
(setq atts (cdr atts))
326
(setq attVal (concat attVal (cdar atts)))
328
(if (equal (string-to-char attVal) ?:)
329
(setq attVal (dodenote (substring attVal (string-match "[^: \t]" attVal)))))
332
((or (equal attName "cn") (equal attName "commonname")) (setq mlcn attVal))
333
((equal attName "member")
334
(setq lmlist (cons (bbdb-split attVal ",") lmlist))
339
(setq atts (cdr atts))
341
(setq mailinglists (cons (cons mlcn lmlist) mailinglists))
344
(new-record (make-vector bbdb-record-length nil)))
346
(if (stringp (car-safe (car-safe atts)))
348
(attName (downcase (caar atts)))
350
(nextAtt (car-safe (cdr-safe atts)))
353
(while (and (cdr atts) (equal (caadr atts) 'continuation))
354
(setq atts (cdr atts))
355
(setq attVal (concat attVal (cdar atts)))
357
(if (equal (string-to-char attVal) ?:)
359
(dodenote (substring attVal (string-match "[^: \t]" attVal))))
362
;((or (equal attName "cn") (equal attName "commonname")) hmm)
363
((or (equal attName "sn") (equal attName "surname")) (bbdb-record-set-lastname new-record attVal))
364
((equal attName "givenname") (bbdb-record-set-firstname new-record attVal))
365
((equal attName "o") (bbdb-record-set-company new-record attVal))
366
((equal attName "locality") (setaddr new-record 'bbdb-address-set-city attVal))
367
((equal attName "postalcode") (setaddr new-record 'bbdb-address-set-zip attVal))
368
((equal attName "st") (setaddr new-record 'bbdb-address-set-state attVal))
369
((equal attName (concat bbdb-ldif-prefixh "mainaddrloc"))
370
(setaddr new-record 'bbdb-address-set-location attVal))
372
;; This is ugly. But is it the only way Netscape understands.
373
((equal attName "postofficebox") (setaddr new-record 'bbdb-address-set-street1 attVal))
374
((equal attName "streetaddress") (setaddr new-record 'bbdb-address-set-street2 attVal))
376
((equal attName "mail")
377
(bbdb-record-set-net new-record (cons attVal (bbdb-record-net new-record))))
379
((equal attName "mailalternateaddress")
380
(bbdb-record-set-net new-record (append (bbdb-record-net new-record)
384
((equal attName "postaladdress")
386
(alines (split-string (concat (bbdb-ldif-renl attVal) "\n")"[\n\r]"))
387
(addr (make-vector bbdb-address-length "")))
388
(if (and (string-match "^bbdb=" (nth 0 alines ))
389
(> (length alines) 6))
391
(bbdb-address-set-location addr (substring (nth 0 alines) 5))
392
(bbdb-address-set-street1 addr (nth 1 alines))
393
(bbdb-address-set-street2 addr (nth 2 alines))
394
(bbdb-address-set-street3 addr (nth 3 alines))
395
(bbdb-address-set-zip addr (nth 4 alines))
396
(bbdb-address-set-city addr (nth 5 alines))
397
(bbdb-address-set-state addr (nth 6 alines))
398
(bbdb-record-set-addresses
400
(append (bbdb-record-addresses new-record) (list addr))
408
((equal attName "homephone")
409
(setphone new-record (bbdb-ldif-get-phone atts "Private") attVal nextAtt) )
410
((equal attName "facsimiletelephonenumber")
411
(setphone new-record (bbdb-ldif-get-phone atts "Fax") attVal nextAtt))
412
((equal attName "pagerphone")
413
(setphone new-record (bbdb-ldif-get-phone atts "pagerphone") attVal nextAtt))
414
((equal attName "cellphone")
415
(setphone new-record (bbdb-ldif-get-phone atts "cellphone") attVal nextAtt))
416
((equal attName "mobiletelephonenumber")
417
(setphone new-record (bbdb-ldif-get-phone atts "cellphone") attVal nextAtt))
418
((equal attName "telephonenumber")
419
(setphone new-record (bbdb-ldif-get-phone atts "Work") attVal nextAtt))
420
((equal attName "xmozillanickname") (bbdb-record-set-aka new-record (list attVal)))
421
((or (equal attName "description") (equal attName "multilinedescription"))
422
(if (equal attName "multilinedescription")
423
(setq attVal (bbdb-ldif-renl attVal)))
424
(let ((thenote (substring attVal 0 (string-match "\n?--bbdb--\n" attVal))))
425
(if (not (equal "" thenote))
426
(addnote new-record 'notes thenote)
431
((equal attName "createTimestamp")
432
(addnote new-record 'creation-date (bbdb-unzulu attVal)))
433
((equal attName "modifyTimestamp")
434
(addnote new-record 'timestamp (bbdb-unzulu attVal)))
435
((eq (string-match bbdb-ldif-prefix attName) 0)
437
(bbdb-ldif-note (make-symbol (substring attName (length bbdb-ldif-prefix)))))
438
(bbdb-record-set-raw-notes new-record
439
(cons (cons bbdb-ldif-note attVal)
440
(bbdb-record-raw-notes new-record)))
446
(setq atts (cdr atts))
449
(if (not (equal new-record emptyrec))
451
(bbdb-record-set-cache new-record (make-vector bbdb-cache-length nil))
453
;; (and (bbdb-record-net new-record)
454
(bbdb-search-simple (tnsnil (bbdb-record-name new-record))
455
(car (bbdb-record-net new-record)))
461
(setq new-record (bbdb-merge-internally-ldif old-record new-record))
462
(bbdb-delete-record-internal old-record)))
464
(bbdb-invoke-hook 'bbdb-create-hook new-record)
465
(bbdb-change-record new-record t)
466
(bbdb-hash-record new-record)
481
(mlcn (car mlist)) (lmlist (cdr mlist)))
485
(mnet (bbdb-string-fetch"mail" lmlist))
486
(mname (bbdb-string-fetch"cn" lmlist))
487
(mcomp (bbdb-string-fetch"o" lmlist))
488
;; (mou (bbdb-string-fetch"ou" lmlist))
489
(therecs (bbdb-records))
493
(if mnet (setq therecs (bbdb-search therecs nil nil mnet nil)))
494
(if mname (setq therecs (bbdb-search therecs mname nil nil nil )))
495
(if mcomp (setq therecs (bbdb-search therecs nil mcomp nil nil nil )))
498
(message (concat "Mailing list member not found: " mname " " mnet)))
499
((= (length therecs) 1)
500
(setq therec (car therecs))
501
(setq mal (assq 'mail-alias (bbdb-record-raw-notes therec)))
504
(setq mal (cons 'mail-alias ""))
505
(bbdb-record-set-raw-notes therec (cons mal (bbdb-record-raw-notes therec))))
506
(bbdb-change-record therec nil)
507
(bbdb-hash-record therec)
509
(if (not (member mlcn (split-string (cdr mal) "[, ]")))
510
(setcdr mal (concat mlcn (if (> (length (cdr-safe mal)) 0) "," "") (cdr mal) )))
512
(t (message "Mailing List member not unique %s, %s" mname mnet))
515
(setq lmlist (cdr lmlist))
517
; (define-mail-alias cn lmlist)
530
(apply 'concat (bbdb-split str "\n\r")))
532
(defun bbdb-ldif-replace-string (str frs tos)
534
(while (string-match frs str start)
536
(concat (substring str 0 (match-beginning 0))
538
(substring str (match-end 0))))
539
(setq start (+ (length tos) (match-beginning 0))))
545
(defun bbase64-encode-string (st)
546
(concat ":" (bbdb-ldif-indent (rmspace st))
550
(defun bbdb-ldif-rmnl (str)
551
(bbdb-ldif-replace-string (bbdb-ldif-replace-string str "\\$" "\\24") "\n" "$")
554
(defun bbdb-ldif-renl (str)
555
(bbdb-ldif-replace-string (bbdb-ldif-replace-string str "\\$" "\n") "\\\\24" "$")
558
(defmacro donote (st)
559
(if (fboundp 'base64-encode-string)
560
(list 'bbase64-encode-string (list 'base64-encode-string st))
561
(list 'bbdb-ldif-rmnl st)
565
(defun base64IfMulti (st)
566
(if (string-match "\n" st)
568
(concat " " (bbdb-ldif-indent st))
572
(defun nsloc (pl) "Guess mapping from userdefined bbdb locations to NS Work/Home/Fax"
574
(pld (and pl (downcase pl)))
575
(fc (and pl (not (equal pl "")) (string-to-char (downcase pl))))
577
(cond ( (not fc) "telephonenumber")
578
((or (= fc ?a) (= fc ?w)) "telephonenumber")
579
( (= fc ?h) "homephone")
580
;; ( (= fc ?m) "mobileTelephoneNumber")
581
( (equal pld "private") "homephone")
582
( (= fc ?m) "cellphone")
583
( (and (= fc ?p) (> (length pld) 1) (= (aref pld 1) ?a)) "pagerphone")
584
( (equal pld "fax") "facsimiletelephonenumber")
585
( t "telephonenumber")
593
(defvar ldifbuffer "*LDIF*" "Name of buffer for LDIF output")
595
(defun bbdb-to-ldif (visible-records) "Converts BBDB to LDIF format. Can be used to export bbdb to Netscape
596
Communicator Address book.\\<bbdb-mode-map>
597
If \"\\[bbdb-apply-next-command-to-all-records]\\[bbdb2ldif]\" is \
598
used instead of simply \"\\[bbdb2ldif]\", then includes only the
599
people currently in the *BBDB* buffer.
600
The result is placed in a buffer name \"*LDIF*\"
601
If MEL is installed Multiline notes/descriptions work with Netscape address book.
602
Mail-aliases from mailrc file or bbdb mail-aliases fields are exported as mainglists
606
(bbdb-do-all-records-p)
610
(target (cons bbdb-define-all-aliases-field "."))
613
(if (not visible-records)
615
(mapcar 'car bbdb-records)
625
(if (not visible-records)
627
(mapcar 'car bbdb-records)
631
(set-buffer (get-buffer-create ldifbuffer))
632
(setq fill-column 1000)
636
(setq record (car ldif-records))
637
(insert "\nxmozillausehtmlmail: FALSE\n")
639
(net (car (bbdb-record-net record)))
640
(rnet (bbdb-record-net record))
642
(insert (format "dn: cn=%s" (tnil (bbdb-record-name record))))
644
(insert (format ",mail=%s" net))
648
(setq tmps (bbdb-record-firstname record)) (insert "givenname: " (tnil tmps) "\n")
649
(setq tmps (bbdb-record-lastname record)) (if tmps (insert "sn: " tmps "\n"))
650
(insert "objectclass: top\nobjectclass: person\n")
651
(setq tmps (bbdb-record-company record)) (if tmps (insert "o: " tmps "\n"))
652
(setq tmps (bbdb-record-name record)) (if tmps (insert "cn: " tmps "\n"))
654
(if net (insert "mail: " net "\n"))
656
(insert "mailAlternateAddress: " (cadr rnet) "\n")
657
(setq rnet (cdr rnet))
661
(phones (bbdb-record-phones record))
662
(addrs (bbdb-record-addresses record))
663
(aka (bbdb-record-aka record))
671
(setq phone (car phones))
672
(if (equal (nsloc (bbdb-phone-location phone))"cellphone")
673
(setq tonote (addtonote tonote (concat "M:" (bbdb-phone-string phone) )))
675
(if (equal (nsloc (bbdb-phone-location phone))"pagerphone")
676
(setq tonote (addtonote tonote (concat "P:" (bbdb-phone-string phone) )))
678
(insert (format "%s: " (nsloc (bbdb-phone-location phone))) (bbdb-phone-string phone) "\n")
679
(insert bbdb-ldif-prefixh "PhoneLoc:" (bbdb-phone-location phone)"\n")
680
(setq phones (cdr phones)))
684
(setq addr (car addrs))
686
(if (= 0 (length (setq tmps (bbdb-address-street1 addr)))) nil (insert "postOfficeBox: " tmps "\n"))
687
(if (= 0 (length (setq tmps (bbdb-address-street2 addr)))) nil (insert "streetaddress: " tmps "\n"))
688
(if (= 0 (length (setq tmps (bbdb-address-street3 addr)))) nil (insert "streetaddress: " tmps "\n" ))
690
; This does not work with Netscape
691
; (if (= 0 (length (setq tmps (bbdb-address-street1 addr)))) nil (insert "homePostalAddress:" tmps ))
692
; (if (= 0 (length (setq tmps (bbdb-address-street2 addr)))) nil (insert "$" tmps))
693
; (if (= 0 (length (setq tmps (bbdb-address-street3 addr)))) nil (insert "$" tmps ))
696
(insert "locality:" (bbdb-address-city addr) "\n")
697
(setq tmps (bbdb-address-state addr))
698
(if (and tmps (not (equal tmps ""))) (insert "st:" tmps "\n"))
699
(if (bbdb-address-zip-string addr)
700
(insert "postalcode:" (bbdb-address-zip-string addr) "\n"))
704
(setq tonote (addtonote tonote (concat (bbdb-address-street1 addr))))
705
(setq tonote (addtonote tonote (concat (bbdb-address-street2 addr))))
706
(setq tonote (addtonote tonote (concat (bbdb-address-street3 addr))))
707
(setq tonote (addtonote tonote (concat (bbdb-address-zip-string addr) " " (bbdb-address-city addr) )))
708
(insert (concat "postalAddress: "
709
(base64IfMulti (concat "bbdb=" (bbdb-address-location addr) "\n"
710
(bbdb-address-street1 addr) "\n"
711
(bbdb-address-street2 addr) "\n"
712
(bbdb-address-street3 addr) "\n"
713
(bbdb-address-zip-string addr) "\n"
714
(bbdb-address-city addr) "\n"
715
(bbdb-address-state addr)
723
(setq addrs (cdr addrs)))
726
(insert (format "%s: %s\n" "xmozillanickname"
727
(mapconcat (function identity) aka ", ")))
729
(let ((notes (bbdb-record-raw-notes record)))
731
(setq notes (list (cons 'notes notes))))
735
((member (caar notes) bbdb-elided-export-ldif) (setq elide t))
736
((eq (car (car notes)) 'creation-date)
737
(insert "createTimestamp: " (bbdb-zulu (cdar notes))"\n")
740
((eq (car (car notes)) 'timestamp)
742
(insert "modifyTimestamp: "(bbdb-zulu (cdar notes))"\n")
744
((eq (car (car notes)) 'notes) (setq elide t))
745
((eq (car (car notes)) 'mail-alias) (setq elide t))
747
;; Netscape cannot display this. So we also put it in the notes field.
748
(setq tonote (addtonote tonote (format "%s:%s" (caar notes) (cdar notes))))
749
(insert (format "%s%s:" bbdb-ldif-prefix (car (car notes))))
752
(if (eq (caar notes) 'notes)
754
(setq tonote (concat (cdar notes) "\n" tonote))
755
(setq tonote (cdar notes)))
757
(insert (base64IfMulti (tnil (cdar notes))) "\n"))
759
(setq notes (cdr notes))
762
(if (and (string-match "\n" tonote) (not (fboundp 'base64-encode-string)))
763
(insert "multilineDescription:" (bbdb-ldif-rmnl tonote ) "\n")
764
(insert "description:" (base64IfMulti tonote ) "\n")
768
(if (bbdb-record-addresses record)
769
(insert bbdb-ldif-prefixh "mainAddrLoc:" (bbdb-address-location (car (bbdb-record-addresses record)))"\n")
773
(setq ldif-records (cdr ldif-records))
776
(if (and (not visible-records) (domailaliases))
780
;; (bbdb-define-all-aliases)
781
(let ((mai 0) mae alist (malen (length mail-aliases)
784
(setq mae (aref mail-aliases mai) )
785
(if (and mae (symbolp mae ))
787
(insert (format "\ndn: cn=%s\n" mae))
788
(insert (format "cn: %s\n" mae))
789
(insert "objectclass: top\n")
790
(insert "objectclass: groupOfNames\n")
791
(setq alist (symbol-value mae ))
795
(let ((trec (bbdb-search-simple nil an))
798
(insert (format "member: cn=%s,mail=%s\n"
799
(tnil (bbdb-record-name trec))
800
(tnil (car (bbdb-record-net trec)))
806
(split-string alist ", ")
817
(set-window-buffer (get-lru-window) ldifbuffer )
819
;;(add-hook 'bbdb-load-hook (lambda () (define-key bbdb-mode-map "L" 'bbdb-to-ldif)))
820
(define-key bbdb-mode-map "L" 'bbdb-to-ldif)