Initial Commit
[packages] / xemacs-packages / bbdb / utils / bbdb-213-310.el
1 ;;; -*- Mode:Emacs-Lisp -*-
2
3 ;;; The 213 area code (in LA) has been split into 213 and 310.  This code
4 ;;; will map over your Insidious Big Brother Database and convert the area
5 ;;; codes when approriate.  It then displays the records which it has changed.
6 ;;;
7 ;;; This is derived from a list posted by Paul Eggert <eggert@twinsun.com>
8 ;;; on 3 Mar 92 18:24:04 GMT.
9
10 (require 'bbdb)
11
12 (defconst bbdb-310-exchanges
13   '(201 202 203 204 205 206 207 208 209 210 212 214 215 216 217 218 219 220
14     246 247 270 271 273 274 275 276 277 278 279 280 281 282 284 285 286 287
15     288 289 297 301 302 305 306 312 313 314 315 316 317 318 319 320 322 323
16     324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 348 350 352
17     354 355 363 364 370 371 372 373 374 375 376 377 378 379 390 391 392 393
18     394 395 396 397 398 399 401 402 403 404 406 407 408 409 410 412 414 416
19     417 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435
20     436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453
21     454 455 456 457 458 459 470 471 472 473 474 475 476 477 478 479 490 491
22     492 493 494 495 496 497 498 499 501 502 510 512 513 514 515 516 517 518
23     519 521 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539
24     540 541 542 543 544 545 546 547 548 549 550 551 552 553 556 557 558 559
25     568 570 571 572 573 574 575 576 577 578 590 591 592 593 594 595 596 597
26     598 599 601 602 603 604 605 606 607 608 609 615 616 618 630 631 632 633
27     634 635 637 638 639 640 641 642 643 644 645 646 647 648 649 652 657 659
28     670 671 672 673 674 675 676 677 679 690 691 692 693 694 695 696 697 698
29     699 708 715 719 761 762 763 764 767 768 769 781 782 783 784 785 787 788
30     791 792 793 794 795 796 797 798 799 800 801 802 803 804 806 807 809 812
31     813 814 815 816 819 820 821 822 823 824 825 826 827 828 829 830 831 832
32     833 834 835 836 837 838 839 840 841 842 843 854 855 858 859 860 861 862
33     863 864 865 866 867 868 869 885 886 898 899 902 903 904 905 906 907 908
34     914 915 916 917 918 920 921 922 923 924 925 926 927 928 929 940 941 942
35     943 944 945 946 947 948 949 967 970 973 978 980 981 982 983 984 985 986
36     987 988 989)
37   "Those exchanges which have moved from the 213 area code to the new 310.")
38
39 (defun bbdb-convert-213-to-310 ()
40   "Convert phone numbers in the BBDB which are in the 213 area code to the
41 newly-created 310 area code if appropriate."
42   (let ((records (bbdb-records))
43         phones frobbed change-p)
44     (while records
45       (setq phones (bbdb-record-phones (car records))
46             change-p nil)
47       (while phones
48         (if (and (= (bbdb-phone-area (car phones)) 213)
49                  (memq (bbdb-phone-exchange (car phones)) bbdb-310-exchanges))
50             (setq change-p (bbdb-phone-set-area (car phones) 310)))
51         (setq phones (cdr phones)))
52       (if change-p
53           (progn
54             (setq frobbed (cons (car records) frobbed))
55             (bbdb-change-record (car records) nil)))
56       (setq records (cdr records)))
57     (bbdb-display-records frobbed)))