Mercurial > emacs
comparison lisp/mail/mail-extr.el @ 41300:5f6710a130ca
Use backquote/dolist/mapc/when. Docstring fixes.
(mail-extract-address-components): Downcase domain names.
(mail-extr-delete-char): Remove. Use delete-char instead.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Mon, 19 Nov 2001 23:16:21 +0000 |
parents | 5f754d04a4d0 |
children | 503a8e2a9054 |
comparison
equal
deleted
inserted
replaced
41299:77b08a460f84 | 41300:5f6710a130ca |
---|---|
509 (defconst mail-extr-address-syntax-table (make-syntax-table)) | 509 (defconst mail-extr-address-syntax-table (make-syntax-table)) |
510 (defconst mail-extr-address-comment-syntax-table (make-syntax-table)) | 510 (defconst mail-extr-address-comment-syntax-table (make-syntax-table)) |
511 (defconst mail-extr-address-domain-literal-syntax-table (make-syntax-table)) | 511 (defconst mail-extr-address-domain-literal-syntax-table (make-syntax-table)) |
512 (defconst mail-extr-address-text-comment-syntax-table (make-syntax-table)) | 512 (defconst mail-extr-address-text-comment-syntax-table (make-syntax-table)) |
513 (defconst mail-extr-address-text-syntax-table (make-syntax-table)) | 513 (defconst mail-extr-address-text-syntax-table (make-syntax-table)) |
514 (mapcar | 514 (mapc |
515 (function | 515 (lambda (pair) |
516 (lambda (pair) | 516 (let ((syntax-table (symbol-value (car pair)))) |
517 (let ((syntax-table (symbol-value (car pair)))) | 517 (dolist (item (cdr pair)) |
518 (mapcar | 518 (if (eq 2 (length item)) |
519 (function | 519 ;; modifying syntax of a single character |
520 (lambda (item) | 520 (modify-syntax-entry (car item) (car (cdr item)) syntax-table) |
521 (if (eq 2 (length item)) | 521 ;; modifying syntax of a range of characters |
522 ;; modifying syntax of a single character | 522 (let ((char (nth 0 item)) |
523 (modify-syntax-entry (car item) (car (cdr item)) syntax-table) | 523 (bound (nth 1 item)) |
524 ;; modifying syntax of a range of characters | 524 (syntax (nth 2 item))) |
525 (let ((char (nth 0 item)) | 525 (while (<= char bound) |
526 (bound (nth 1 item)) | 526 (modify-syntax-entry char syntax syntax-table) |
527 (syntax (nth 2 item))) | 527 (setq char (1+ char)))))))) |
528 (while (<= char bound) | |
529 (modify-syntax-entry char syntax syntax-table) | |
530 (setq char (1+ char))))))) | |
531 (cdr pair))))) | |
532 '((mail-extr-address-syntax-table | 528 '((mail-extr-address-syntax-table |
533 (?\000 ?\037 "w") ;control characters | 529 (?\000 ?\037 "w") ;control characters |
534 (?\040 " ") ;SPC | 530 (?\040 " ") ;SPC |
535 (?! ?~ "w") ;printable characters | 531 (?! ?~ "w") ;printable characters |
536 (?\177 "w") ;DEL | 532 (?\177 "w") ;DEL |
616 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 612 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
617 ;; | 613 ;; |
618 ;; Utility functions and macros. | 614 ;; Utility functions and macros. |
619 ;; | 615 ;; |
620 | 616 |
621 (defsubst mail-extr-delete-char (n) | |
622 ;; in v19, delete-char is compiled as a function call, but delete-region | |
623 ;; is byte-coded, so it's much much faster. | |
624 (delete-region (point) (+ (point) n))) | |
625 | |
626 (defsubst mail-extr-skip-whitespace-forward () | 617 (defsubst mail-extr-skip-whitespace-forward () |
627 ;; v19 fn skip-syntax-forward is more tasteful, but not byte-coded. | 618 ;; v19 fn skip-syntax-forward is more tasteful, but not byte-coded. |
628 (skip-chars-forward " \t\n\r\240")) | 619 (skip-chars-forward " \t\n\r\240")) |
629 | 620 |
630 (defsubst mail-extr-skip-whitespace-backward () | 621 (defsubst mail-extr-skip-whitespace-backward () |
637 (save-restriction | 628 (save-restriction |
638 (narrow-to-region beg end) | 629 (narrow-to-region beg end) |
639 (goto-char (point-min)) | 630 (goto-char (point-min)) |
640 ;; undo \ quoting | 631 ;; undo \ quoting |
641 (while (search-forward "\\" nil t) | 632 (while (search-forward "\\" nil t) |
642 (mail-extr-delete-char -1) | 633 (delete-char -1) |
643 (or (eobp) | 634 (or (eobp) |
644 (forward-char 1)))))) | 635 (forward-char 1)))))) |
645 | 636 |
646 (defsubst mail-extr-nuke-char-at (pos) | 637 (defsubst mail-extr-nuke-char-at (pos) |
647 (save-excursion | 638 (save-excursion |
648 (goto-char pos) | 639 (goto-char pos) |
649 (mail-extr-delete-char 1) | 640 (delete-char 1) |
650 (insert ?\ ))) | 641 (insert ?\ ))) |
651 | 642 |
652 (put 'mail-extr-nuke-outside-range | 643 (put 'mail-extr-nuke-outside-range |
653 'edebug-form-spec '(symbolp &optional form form atom)) | 644 'edebug-form-spec '(symbolp &optional form form atom)) |
654 | 645 |
655 (defmacro mail-extr-nuke-outside-range (list-symbol | 646 (defmacro mail-extr-nuke-outside-range (list-symbol |
656 beg-symbol end-symbol | 647 beg-symbol end-symbol |
657 &optional no-replace) | 648 &optional no-replace) |
658 ;; LIST-SYMBOL names a variable holding a list of buffer positions | 649 "Delete all elements outside BEG..END in LIST. |
659 ;; BEG-SYMBOL and END-SYMBOL name variables delimiting a range | 650 LIST-SYMBOL names a variable holding a list of buffer positions |
660 ;; Each element of LIST-SYMBOL which lies outside of the range is | 651 BEG-SYMBOL and END-SYMBOL name variables delimiting a range |
661 ;; deleted from the list. | 652 Each element of LIST-SYMBOL which lies outside of the range is |
662 ;; Unless NO-REPLACE is true, at each of the positions in LIST-SYMBOL | 653 deleted from the list. |
663 ;; which lie outside of the range, one character at that position is | 654 Unless NO-REPLACE is true, at each of the positions in LIST-SYMBOL |
664 ;; replaced with a SPC. | 655 which lie outside of the range, one character at that position is |
656 replaced with a SPC." | |
665 (or (memq no-replace '(t nil)) | 657 (or (memq no-replace '(t nil)) |
666 (error "no-replace must be t or nil, evaluable at macroexpand-time")) | 658 (error "no-replace must be t or nil, evaluable at macroexpand-time")) |
667 (` (let ((temp (, list-symbol)) | 659 `(let ((temp ,list-symbol) |
668 ch) | 660 ch) |
669 (while temp | 661 (while temp |
670 (setq ch (car temp)) | 662 (setq ch (car temp)) |
671 (cond ((or (> ch (, end-symbol)) | 663 (when (or (> ch ,end-symbol) |
672 (< ch (, beg-symbol))) | 664 (< ch ,beg-symbol)) |
673 (,@ (if no-replace | 665 ,@(if no-replace |
674 nil | 666 nil |
675 (` ((mail-extr-nuke-char-at ch))))) | 667 `((mail-extr-nuke-char-at ch))) |
676 (setcar temp nil))) | 668 (setcar temp nil)) |
677 (setq temp (cdr temp))) | 669 (setq temp (cdr temp))) |
678 (setq (, list-symbol) (delq nil (, list-symbol)))))) | 670 (setq ,list-symbol (delq nil ,list-symbol)))) |
679 | 671 |
680 (defun mail-extr-demarkerize (marker) | 672 (defun mail-extr-demarkerize (marker) |
681 ;; if arg is a marker, destroys the marker, then returns the old value. | 673 ;; if arg is a marker, destroys the marker, then returns the old value. |
682 ;; otherwise returns the arg. | 674 ;; otherwise returns the arg. |
683 (if (markerp marker) | 675 (if (markerp marker) |
907 (setcdr >-pos (nthcdr 2 >-pos))) | 899 (setcdr >-pos (nthcdr 2 >-pos))) |
908 | 900 |
909 ;; If multiple @s and a :, but no < and >, insert around buffer. | 901 ;; If multiple @s and a :, but no < and >, insert around buffer. |
910 ;; Example: @foo.bar.dom,@xxx.yyy.zzz:mailbox@aaa.bbb.ccc | 902 ;; Example: @foo.bar.dom,@xxx.yyy.zzz:mailbox@aaa.bbb.ccc |
911 ;; This commonly happens on the UUCP "From " line. Ugh. | 903 ;; This commonly happens on the UUCP "From " line. Ugh. |
912 (cond ((and (> (length @-pos) 1) | 904 (when (and (> (length @-pos) 1) |
913 (eq 1 (length colon-pos)) ;TODO: check if between last two @s | 905 (eq 1 (length colon-pos)) ;TODO: check if between last two @s |
914 (not \;-pos) | 906 (not \;-pos) |
915 (not <-pos)) | 907 (not <-pos)) |
916 (goto-char (point-min)) | 908 (goto-char (point-min)) |
917 (mail-extr-delete-char 1) | 909 (delete-char 1) |
918 (setq <-pos (list (point))) | 910 (setq <-pos (list (point))) |
919 (insert ?<))) | 911 (insert ?<)) |
920 | 912 |
921 ;; If < but no >, insert > in rightmost possible position | 913 ;; If < but no >, insert > in rightmost possible position |
922 (cond ((and <-pos | 914 (when (and <-pos (null >-pos)) |
923 (null >-pos)) | 915 (goto-char (point-max)) |
924 (goto-char (point-max)) | 916 (setq >-pos (list (point))) |
925 (setq >-pos (list (point))) | 917 (insert ?>)) |
926 (insert ?>))) | |
927 | 918 |
928 ;; If > but no <, replace > with space. | 919 ;; If > but no <, replace > with space. |
929 (cond ((and >-pos | 920 (when (and >-pos (null <-pos)) |
930 (null <-pos)) | 921 (mail-extr-nuke-char-at (car >-pos)) |
931 (mail-extr-nuke-char-at (car >-pos)) | 922 (setq >-pos nil)) |
932 (setq >-pos nil))) | |
933 | 923 |
934 ;; Turn >-pos and <-pos into non-lists | 924 ;; Turn >-pos and <-pos into non-lists |
935 (setq >-pos (car >-pos) | 925 (setq >-pos (car >-pos) |
936 <-pos (car <-pos)) | 926 <-pos (car <-pos)) |
937 | 927 |
938 ;; Trim other punctuation lists of items outside < > pair to handle | 928 ;; Trim other punctuation lists of items outside < > pair to handle |
939 ;; stupid MTAs. | 929 ;; stupid MTAs. |
940 (cond (<-pos ; don't need to check >-pos also | 930 (when <-pos ; don't need to check >-pos also |
941 ;; handle bozo software that violates RFC 822 by sticking | 931 ;; handle bozo software that violates RFC 822 by sticking |
942 ;; punctuation marks outside of a < > pair | 932 ;; punctuation marks outside of a < > pair |
943 (mail-extr-nuke-outside-range @-pos <-pos >-pos t) | 933 (mail-extr-nuke-outside-range @-pos <-pos >-pos t) |
944 ;; RFC 822 says nothing about these two outside < >, but | 934 ;; RFC 822 says nothing about these two outside < >, but |
945 ;; remove those positions from the lists to make things | 935 ;; remove those positions from the lists to make things |
946 ;; easier. | 936 ;; easier. |
947 (mail-extr-nuke-outside-range !-pos <-pos >-pos t) | 937 (mail-extr-nuke-outside-range !-pos <-pos >-pos t) |
948 (mail-extr-nuke-outside-range %-pos <-pos >-pos t))) | 938 (mail-extr-nuke-outside-range %-pos <-pos >-pos t)) |
949 | 939 |
950 ;; Check for : that indicates GROUP list and for : part of | 940 ;; Check for : that indicates GROUP list and for : part of |
951 ;; ROUTE-ADDR spec. | 941 ;; ROUTE-ADDR spec. |
952 ;; Can't possibly be more than two :. Nuke any extra. | 942 ;; Can't possibly be more than two :. Nuke any extra. |
953 (while colon-pos | 943 (while colon-pos |
980 (> temp group-:-pos)) | 970 (> temp group-:-pos)) |
981 (not group-\;-pos)) | 971 (not group-\;-pos)) |
982 (setq group-\;-pos temp)))) | 972 (setq group-\;-pos temp)))) |
983 | 973 |
984 ;; Nuke unmatched GROUP syntax characters. | 974 ;; Nuke unmatched GROUP syntax characters. |
985 (cond ((and group-:-pos (not group-\;-pos)) | 975 (when (and group-:-pos (not group-\;-pos)) |
986 ;; *** Do I really need to erase it? | 976 ;; *** Do I really need to erase it? |
987 (mail-extr-nuke-char-at group-:-pos) | 977 (mail-extr-nuke-char-at group-:-pos) |
988 (setq group-:-pos nil))) | 978 (setq group-:-pos nil)) |
989 (cond ((and group-\;-pos (not group-:-pos)) | 979 (when (and group-\;-pos (not group-:-pos)) |
990 ;; *** Do I really need to erase it? | 980 ;; *** Do I really need to erase it? |
991 (mail-extr-nuke-char-at group-\;-pos) | 981 (mail-extr-nuke-char-at group-\;-pos) |
992 (setq group-\;-pos nil))) | 982 (setq group-\;-pos nil)) |
993 | 983 |
994 ;; Handle junk like ";@host.company.dom" that sendmail adds. | 984 ;; Handle junk like ";@host.company.dom" that sendmail adds. |
995 ;; **** should I remember comment positions? | 985 ;; **** should I remember comment positions? |
996 (cond | 986 (when group-\;-pos |
997 (group-\;-pos | |
998 ;; this is fine for now | 987 ;; this is fine for now |
999 (mail-extr-nuke-outside-range !-pos group-:-pos group-\;-pos t) | 988 (mail-extr-nuke-outside-range !-pos group-:-pos group-\;-pos t) |
1000 (mail-extr-nuke-outside-range @-pos group-:-pos group-\;-pos t) | 989 (mail-extr-nuke-outside-range @-pos group-:-pos group-\;-pos t) |
1001 (mail-extr-nuke-outside-range %-pos group-:-pos group-\;-pos t) | 990 (mail-extr-nuke-outside-range %-pos group-:-pos group-\;-pos t) |
1002 (mail-extr-nuke-outside-range comma-pos group-:-pos group-\;-pos t) | 991 (mail-extr-nuke-outside-range comma-pos group-:-pos group-\;-pos t) |
1016 ;;(narrow-to-region (point-min) group-\;-pos) | 1005 ;;(narrow-to-region (point-min) group-\;-pos) |
1017 | 1006 |
1018 ;; *** The entire handling of GROUP addresses seems rather lame. | 1007 ;; *** The entire handling of GROUP addresses seems rather lame. |
1019 ;; *** It deserves a complete rethink, except that these addresses | 1008 ;; *** It deserves a complete rethink, except that these addresses |
1020 ;; *** are hardly ever seen. | 1009 ;; *** are hardly ever seen. |
1021 )) | 1010 ) |
1022 | 1011 |
1023 ;; Any commas must be between < and : of ROUTE-ADDR. Nuke any | 1012 ;; Any commas must be between < and : of ROUTE-ADDR. Nuke any |
1024 ;; others. | 1013 ;; others. |
1025 ;; Hell, go ahead an nuke all of the commas. | 1014 ;; Hell, go ahead an nuke all of the commas. |
1026 ;; **** This will cause problems when we start handling commas in | 1015 ;; **** This will cause problems when we start handling commas in |
1030 ;; can only have multiple @s inside < >. The fact that some MTAs | 1019 ;; can only have multiple @s inside < >. The fact that some MTAs |
1031 ;; put de-bracketed ROUTE-ADDRs in the UUCP-style "From " line is | 1020 ;; put de-bracketed ROUTE-ADDRs in the UUCP-style "From " line is |
1032 ;; handled above. | 1021 ;; handled above. |
1033 | 1022 |
1034 ;; Locate PHRASE part of ROUTE-ADDR. | 1023 ;; Locate PHRASE part of ROUTE-ADDR. |
1035 (cond (<-pos | 1024 (when <-pos |
1036 (goto-char <-pos) | 1025 (goto-char <-pos) |
1037 (mail-extr-skip-whitespace-backward) | 1026 (mail-extr-skip-whitespace-backward) |
1038 (setq phrase-end (point)) | 1027 (setq phrase-end (point)) |
1039 (goto-char (or ;;group-:-pos | 1028 (goto-char (or ;;group-:-pos |
1040 (point-min))) | 1029 (point-min))) |
1041 (mail-extr-skip-whitespace-forward) | 1030 (mail-extr-skip-whitespace-forward) |
1042 (if (< (point) phrase-end) | 1031 (if (< (point) phrase-end) |
1043 (setq phrase-beg (point)) | 1032 (setq phrase-beg (point)) |
1044 (setq phrase-end nil)))) | 1033 (setq phrase-end nil))) |
1045 | 1034 |
1046 ;; handle ROUTE-ADDRS with real ROUTEs. | 1035 ;; handle ROUTE-ADDRS with real ROUTEs. |
1047 ;; If there are multiple @s, then we assume ROUTE-ADDR syntax, and | 1036 ;; If there are multiple @s, then we assume ROUTE-ADDR syntax, and |
1048 ;; any % or ! must be semantically meaningless. | 1037 ;; any % or ! must be semantically meaningless. |
1049 ;; TODO: do this processing into canonicalization buffer | 1038 ;; TODO: do this processing into canonicalization buffer |
1050 (cond (route-addr-:-pos | 1039 (when route-addr-:-pos |
1051 (setq !-pos nil | 1040 (setq !-pos nil |
1052 %-pos nil | 1041 %-pos nil |
1053 >-pos (copy-marker >-pos) | 1042 >-pos (copy-marker >-pos) |
1054 route-addr-:-pos (copy-marker route-addr-:-pos)) | 1043 route-addr-:-pos (copy-marker route-addr-:-pos)) |
1055 (goto-char >-pos) | 1044 (goto-char >-pos) |
1056 (insert-before-markers ?X) | 1045 (insert-before-markers ?X) |
1057 (goto-char (car @-pos)) | 1046 (goto-char (car @-pos)) |
1058 (while (setq @-pos (cdr @-pos)) | 1047 (while (setq @-pos (cdr @-pos)) |
1059 (mail-extr-delete-char 1) | 1048 (delete-char 1) |
1060 (setq %-pos (cons (point-marker) %-pos)) | 1049 (setq %-pos (cons (point-marker) %-pos)) |
1061 (insert "%") | 1050 (insert "%") |
1062 (goto-char (1- >-pos)) | 1051 (goto-char (1- >-pos)) |
1063 (save-excursion | 1052 (save-excursion |
1064 (insert-buffer-substring extraction-buffer | 1053 (insert-buffer-substring extraction-buffer |
1065 (car @-pos) route-addr-:-pos) | 1054 (car @-pos) route-addr-:-pos) |
1066 (delete-region (car @-pos) route-addr-:-pos)) | 1055 (delete-region (car @-pos) route-addr-:-pos)) |
1067 (or (cdr @-pos) | 1056 (or (cdr @-pos) |
1068 (setq saved-@-pos (list (point))))) | 1057 (setq saved-@-pos (list (point))))) |
1069 (setq @-pos saved-@-pos) | 1058 (setq @-pos saved-@-pos) |
1070 (goto-char >-pos) | 1059 (goto-char >-pos) |
1071 (mail-extr-delete-char -1) | 1060 (delete-char -1) |
1072 (mail-extr-nuke-char-at route-addr-:-pos) | 1061 (mail-extr-nuke-char-at route-addr-:-pos) |
1073 (mail-extr-demarkerize route-addr-:-pos) | 1062 (mail-extr-demarkerize route-addr-:-pos) |
1074 (setq route-addr-:-pos nil | 1063 (setq route-addr-:-pos nil |
1075 >-pos (mail-extr-demarkerize >-pos) | 1064 >-pos (mail-extr-demarkerize >-pos) |
1076 %-pos (mapcar 'mail-extr-demarkerize %-pos)))) | 1065 %-pos (mapcar 'mail-extr-demarkerize %-pos))) |
1077 | 1066 |
1078 ;; de-listify @-pos | 1067 ;; de-listify @-pos |
1079 (setq @-pos (car @-pos)) | 1068 (setq @-pos (car @-pos)) |
1080 | 1069 |
1081 ;; TODO: remove comments in the middle of an address | 1070 ;; TODO: remove comments in the middle of an address |
1082 | 1071 |
1083 (save-excursion | 1072 (with-current-buffer canonicalization-buffer |
1084 (set-buffer canonicalization-buffer) | |
1085 | |
1086 (widen) | 1073 (widen) |
1087 (erase-buffer) | 1074 (erase-buffer) |
1088 (insert-buffer-substring extraction-buffer) | 1075 (insert-buffer-substring extraction-buffer) |
1089 | 1076 |
1090 (if <-pos | 1077 (if <-pos |
1095 >-pos) | 1082 >-pos) |
1096 (if (and first-real-pos last-real-pos) | 1083 (if (and first-real-pos last-real-pos) |
1097 (narrow-to-region first-real-pos last-real-pos) | 1084 (narrow-to-region first-real-pos last-real-pos) |
1098 ;; ****** Oh no! What if the address is completely empty! | 1085 ;; ****** Oh no! What if the address is completely empty! |
1099 ;; *** Is this correct? | 1086 ;; *** Is this correct? |
1100 (narrow-to-region (point-max) (point-max)) | 1087 (narrow-to-region (point-max) (point-max)))) |
1101 )) | |
1102 | 1088 |
1103 (and @-pos %-pos | 1089 (and @-pos %-pos |
1104 (mail-extr-nuke-outside-range %-pos (point-min) @-pos)) | 1090 (mail-extr-nuke-outside-range %-pos (point-min) @-pos)) |
1105 (and %-pos !-pos | 1091 (and %-pos !-pos |
1106 (mail-extr-nuke-outside-range !-pos (point-min) (car %-pos))) | 1092 (mail-extr-nuke-outside-range !-pos (point-min) (car %-pos))) |
1108 (mail-extr-nuke-outside-range !-pos (point-min) @-pos)) | 1094 (mail-extr-nuke-outside-range !-pos (point-min) @-pos)) |
1109 | 1095 |
1110 ;; Error condition:?? (and %-pos (not @-pos)) | 1096 ;; Error condition:?? (and %-pos (not @-pos)) |
1111 | 1097 |
1112 ;; WARNING: THIS CODE IS DUPLICATED BELOW. | 1098 ;; WARNING: THIS CODE IS DUPLICATED BELOW. |
1113 (cond ((and %-pos | 1099 (when (and %-pos (not @-pos)) |
1114 (not @-pos)) | 1100 (goto-char (car %-pos)) |
1115 (goto-char (car %-pos)) | 1101 (delete-char 1) |
1116 (mail-extr-delete-char 1) | 1102 (setq @-pos (point)) |
1117 (setq @-pos (point)) | 1103 (insert "@") |
1118 (insert "@") | 1104 (setq %-pos (cdr %-pos))) |
1119 (setq %-pos (cdr %-pos)))) | 1105 |
1120 | 1106 (when (and mail-extr-mangle-uucp !-pos) |
1121 (if mail-extr-mangle-uucp | 1107 ;; **** I don't understand this save-restriction and the |
1122 (cond (!-pos | 1108 ;; narrow-to-region inside it. Why did I do that? |
1123 ;; **** I don't understand this save-restriction and the | 1109 (save-restriction |
1124 ;; narrow-to-region inside it. Why did I do that? | 1110 (cond ((and @-pos |
1125 (save-restriction | 1111 mail-extr-@-binds-tighter-than-!) |
1126 (cond ((and @-pos | 1112 (goto-char @-pos) |
1127 mail-extr-@-binds-tighter-than-!) | 1113 (setq %-pos (cons (point) %-pos) |
1128 (goto-char @-pos) | 1114 @-pos nil) |
1129 (setq %-pos (cons (point) %-pos) | 1115 (delete-char 1) |
1130 @-pos nil) | 1116 (insert "%") |
1131 (mail-extr-delete-char 1) | 1117 (setq insert-point (point-max))) |
1132 (insert "%") | 1118 (mail-extr-@-binds-tighter-than-! |
1133 (setq insert-point (point-max))) | 1119 (setq insert-point (point-max))) |
1134 (mail-extr-@-binds-tighter-than-! | 1120 (%-pos |
1135 (setq insert-point (point-max))) | 1121 (setq insert-point (car (last %-pos)) |
1136 (%-pos | 1122 saved-%-pos (mapcar 'mail-extr-markerize %-pos) |
1137 (setq insert-point (car (last %-pos)) | 1123 %-pos nil |
1138 saved-%-pos (mapcar 'mail-extr-markerize %-pos) | 1124 @-pos (mail-extr-markerize @-pos))) |
1139 %-pos nil | 1125 (@-pos |
1140 @-pos (mail-extr-markerize @-pos))) | 1126 (setq insert-point @-pos) |
1141 (@-pos | 1127 (setq @-pos (mail-extr-markerize @-pos))) |
1142 (setq insert-point @-pos) | 1128 (t |
1143 (setq @-pos (mail-extr-markerize @-pos))) | 1129 (setq insert-point (point-max)))) |
1144 (t | 1130 (narrow-to-region (point-min) insert-point) |
1145 (setq insert-point (point-max)))) | 1131 (setq saved-!-pos (car !-pos)) |
1146 (narrow-to-region (point-min) insert-point) | 1132 (while !-pos |
1147 (setq saved-!-pos (car !-pos)) | 1133 (goto-char (point-max)) |
1148 (while !-pos | 1134 (cond ((and (not @-pos) |
1149 (goto-char (point-max)) | 1135 (not (cdr !-pos))) |
1150 (cond ((and (not @-pos) | 1136 (setq @-pos (point)) |
1151 (not (cdr !-pos))) | 1137 (insert-before-markers "@ ")) |
1152 (setq @-pos (point)) | 1138 (t |
1153 (insert-before-markers "@ ")) | 1139 (setq %-pos (cons (point) %-pos)) |
1154 (t | 1140 (insert-before-markers "% "))) |
1155 (setq %-pos (cons (point) %-pos)) | 1141 (backward-char 1) |
1156 (insert-before-markers "% "))) | 1142 (insert-buffer-substring |
1157 (backward-char 1) | 1143 (current-buffer) |
1158 (insert-buffer-substring | 1144 (if (nth 1 !-pos) |
1159 (current-buffer) | 1145 (1+ (nth 1 !-pos)) |
1160 (if (nth 1 !-pos) | 1146 (point-min)) |
1161 (1+ (nth 1 !-pos)) | 1147 (car !-pos)) |
1162 (point-min)) | 1148 (delete-char 1) |
1163 (car !-pos)) | 1149 (or (save-excursion |
1164 (mail-extr-delete-char 1) | 1150 (mail-extr-safe-move-sexp -1) |
1165 (or (save-excursion | 1151 (mail-extr-skip-whitespace-backward) |
1166 (mail-extr-safe-move-sexp -1) | 1152 (eq ?. (preceding-char))) |
1167 (mail-extr-skip-whitespace-backward) | 1153 (insert-before-markers |
1168 (eq ?. (preceding-char))) | 1154 (if (save-excursion |
1169 (insert-before-markers | 1155 (mail-extr-skip-whitespace-backward) |
1170 (if (save-excursion | 1156 (eq ?. (preceding-char))) |
1171 (mail-extr-skip-whitespace-backward) | 1157 "" |
1172 (eq ?. (preceding-char))) | 1158 ".") |
1173 "" | 1159 "uucp")) |
1174 ".") | 1160 (setq !-pos (cdr !-pos)))) |
1175 "uucp")) | 1161 (and saved-%-pos |
1176 (setq !-pos (cdr !-pos)))) | 1162 (setq %-pos (append (mapcar 'mail-extr-demarkerize |
1177 (and saved-%-pos | 1163 saved-%-pos) |
1178 (setq %-pos (append (mapcar 'mail-extr-demarkerize | 1164 %-pos))) |
1179 saved-%-pos) | 1165 (setq @-pos (mail-extr-demarkerize @-pos)) |
1180 %-pos))) | 1166 (narrow-to-region (1+ saved-!-pos) (point-max))) |
1181 (setq @-pos (mail-extr-demarkerize @-pos)) | |
1182 (narrow-to-region (1+ saved-!-pos) (point-max))))) | |
1183 | 1167 |
1184 ;; WARNING: THIS CODE IS DUPLICATED ABOVE. | 1168 ;; WARNING: THIS CODE IS DUPLICATED ABOVE. |
1185 (cond ((and %-pos | 1169 (when (and %-pos (not @-pos)) |
1186 (not @-pos)) | 1170 (goto-char (car %-pos)) |
1187 (goto-char (car %-pos)) | 1171 (delete-char 1) |
1188 (mail-extr-delete-char 1) | 1172 (setq @-pos (point)) |
1189 (setq @-pos (point)) | 1173 (insert "@") |
1190 (insert "@") | 1174 (setq %-pos (cdr %-pos))) |
1191 (setq %-pos (cdr %-pos)))) | 1175 |
1192 | 1176 (when (setq %-pos (nreverse %-pos)) ; implies @-pos valid |
1193 (setq %-pos (nreverse %-pos)) | 1177 (setq temp %-pos) |
1194 (cond (%-pos ; implies @-pos valid | 1178 (catch 'truncated |
1195 (setq temp %-pos) | 1179 (while temp |
1196 (catch 'truncated | 1180 (goto-char (or (nth 1 temp) |
1197 (while temp | 1181 @-pos)) |
1198 (goto-char (or (nth 1 temp) | 1182 (mail-extr-skip-whitespace-backward) |
1199 @-pos)) | 1183 (save-excursion |
1200 (mail-extr-skip-whitespace-backward) | 1184 (mail-extr-safe-move-sexp -1) |
1201 (save-excursion | 1185 (setq domain-pos (point)) |
1202 (mail-extr-safe-move-sexp -1) | 1186 (mail-extr-skip-whitespace-backward) |
1203 (setq domain-pos (point)) | 1187 (setq \.-pos (eq ?. (preceding-char)))) |
1204 (mail-extr-skip-whitespace-backward) | 1188 (when (and \.-pos |
1205 (setq \.-pos (eq ?. (preceding-char)))) | 1189 ;; #### string consing |
1206 (cond ((and \.-pos | 1190 (let ((s (intern-soft |
1207 ;; #### string consing | 1191 (buffer-substring domain-pos (point)) |
1208 (let ((s (intern-soft | 1192 mail-extr-all-top-level-domains))) |
1209 (buffer-substring domain-pos (point)) | 1193 (and s (get s 'domain-name)))) |
1210 mail-extr-all-top-level-domains))) | 1194 (narrow-to-region (point-min) (point)) |
1211 (and s (get s 'domain-name)))) | 1195 (goto-char (car temp)) |
1212 (narrow-to-region (point-min) (point)) | 1196 (delete-char 1) |
1213 (goto-char (car temp)) | 1197 (setq @-pos (point)) |
1214 (mail-extr-delete-char 1) | 1198 (setcdr temp nil) |
1215 (setq @-pos (point)) | 1199 (setq %-pos (delq @-pos %-pos)) |
1216 (setcdr temp nil) | 1200 (insert "@") |
1217 (setq %-pos (delq @-pos %-pos)) | 1201 (throw 'truncated t)) |
1218 (insert "@") | 1202 (setq temp (cdr temp))))) |
1219 (throw 'truncated t))) | |
1220 (setq temp (cdr temp)))))) | |
1221 (setq mbox-beg (point-min) | 1203 (setq mbox-beg (point-min) |
1222 mbox-end (if %-pos (car %-pos) | 1204 mbox-end (if %-pos (car %-pos) |
1223 (or @-pos | 1205 (or @-pos |
1224 (point-max))))) | 1206 (point-max)))) |
1207 | |
1208 (when @-pos | |
1209 ;; Make the domain-name part lowercase since it's case | |
1210 ;; insensitive anyway. | |
1211 (downcase-region (1+ @-pos) (point-max)))) | |
1225 | 1212 |
1226 ;; Done canonicalizing address. | 1213 ;; Done canonicalizing address. |
1227 ;; We are now back in extraction-buffer. | 1214 ;; We are now back in extraction-buffer. |
1228 | 1215 |
1229 ;; Decide what part of the address to search to find the full name. | 1216 ;; Decide what part of the address to search to find the full name. |
1293 (forward-char 1)) | 1280 (forward-char 1)) |
1294 ;; take into account deletions | 1281 ;; take into account deletions |
1295 (setq quote-end (- (point) 2)) | 1282 (setq quote-end (- (point) 2)) |
1296 (save-excursion | 1283 (save-excursion |
1297 (backward-char 1) | 1284 (backward-char 1) |
1298 (mail-extr-delete-char 1) | 1285 (delete-char 1) |
1299 (goto-char quote-beg) | 1286 (goto-char quote-beg) |
1300 (or (eobp) | 1287 (or (eobp) |
1301 (mail-extr-delete-char 1))) | 1288 (delete-char 1))) |
1302 (mail-extr-undo-backslash-quoting quote-beg quote-end) | 1289 (mail-extr-undo-backslash-quoting quote-beg quote-end) |
1303 (or (eq ?\ (char-after (point))) | 1290 (or (eq ?\ (char-after (point))) |
1304 (insert " ")) | 1291 (insert " ")) |
1305 ;; (setq mailbox-name-processed-flag t) | 1292 ;; (setq mailbox-name-processed-flag t) |
1306 (setq \.-ends-name t)) | 1293 (setq \.-ends-name t)) |
1307 ((eq char ?.) | 1294 ((eq char ?.) |
1308 (if (memq (char-after (1+ (point))) '(?_ ?=)) | 1295 (if (memq (char-after (1+ (point))) '(?_ ?=)) |
1309 (progn | 1296 (progn |
1310 (forward-char 1) | 1297 (forward-char 1) |
1311 (mail-extr-delete-char 1) | 1298 (delete-char 1) |
1312 (insert ?\ )) | 1299 (insert ?\ )) |
1313 (if \.-ends-name | 1300 (if \.-ends-name |
1314 (narrow-to-region (point-min) (point)) | 1301 (narrow-to-region (point-min) (point)) |
1315 (mail-extr-delete-char 1) | 1302 (delete-char 1) |
1316 (insert " "))) | 1303 (insert " "))) |
1317 ;; (setq mailbox-name-processed-flag t) | 1304 ;; (setq mailbox-name-processed-flag t) |
1318 ) | 1305 ) |
1319 ((memq (char-syntax char) '(?. ?\\)) | 1306 ((memq (char-syntax char) '(?. ?\\)) |
1320 (mail-extr-delete-char 1) | 1307 (delete-char 1) |
1321 (insert " ") | 1308 (insert " ") |
1322 ;; (setq mailbox-name-processed-flag t) | 1309 ;; (setq mailbox-name-processed-flag t) |
1323 ) | 1310 ) |
1324 (t | 1311 (t |
1325 (setq atom-beg (point)) | 1312 (setq atom-beg (point)) |
1337 ;; *** by periods! | 1324 ;; *** by periods! |
1338 ((looking-at mail-extr-x400-encoded-address-pattern) | 1325 ((looking-at mail-extr-x400-encoded-address-pattern) |
1339 | 1326 |
1340 ;; Copy the contents of the individual fields that | 1327 ;; Copy the contents of the individual fields that |
1341 ;; might hold name data to the beginning. | 1328 ;; might hold name data to the beginning. |
1342 (mapcar | 1329 (mapc |
1343 (function | 1330 (lambda (field-pattern) |
1344 (lambda (field-pattern) | 1331 (when |
1345 (cond | 1332 (save-excursion |
1346 ((save-excursion | 1333 (re-search-forward field-pattern nil t)) |
1347 (re-search-forward field-pattern nil t)) | 1334 (insert-buffer-substring (current-buffer) |
1348 (insert-buffer-substring (current-buffer) | 1335 (match-beginning 1) |
1349 (match-beginning 1) | 1336 (match-end 1)) |
1350 (match-end 1)) | 1337 (insert " "))) |
1351 (insert " "))))) | |
1352 (list mail-extr-x400-encoded-address-given-name-pattern | 1338 (list mail-extr-x400-encoded-address-given-name-pattern |
1353 mail-extr-x400-encoded-address-surname-pattern | 1339 mail-extr-x400-encoded-address-surname-pattern |
1354 mail-extr-x400-encoded-address-full-name-pattern)) | 1340 mail-extr-x400-encoded-address-full-name-pattern)) |
1355 | 1341 |
1356 ;; Discard the rest, since it contains stuff like | 1342 ;; Discard the rest, since it contains stuff like |
1394 ;; If name is "First Last" and userid is "F?L", then assume | 1380 ;; If name is "First Last" and userid is "F?L", then assume |
1395 ;; the middle initial is the second letter in the userid. | 1381 ;; the middle initial is the second letter in the userid. |
1396 ;; Initial code by Jamie Zawinski <jwz@lucid.com> | 1382 ;; Initial code by Jamie Zawinski <jwz@lucid.com> |
1397 ;; *** Make it work when there's a suffix as well. | 1383 ;; *** Make it work when there's a suffix as well. |
1398 (goto-char (point-min)) | 1384 (goto-char (point-min)) |
1399 (cond ((and mail-extr-guess-middle-initial | 1385 (when (and mail-extr-guess-middle-initial |
1400 (not disable-initial-guessing-flag) | 1386 (not disable-initial-guessing-flag) |
1401 (eq 3 (- mbox-end mbox-beg)) | 1387 (eq 3 (- mbox-end mbox-beg)) |
1402 (progn | 1388 (progn |
1403 (goto-char (point-min)) | 1389 (goto-char (point-min)) |
1404 (looking-at mail-extr-two-name-pattern))) | 1390 (looking-at mail-extr-two-name-pattern))) |
1405 (setq fi (char-after (match-beginning 0)) | 1391 (setq fi (char-after (match-beginning 0)) |
1406 li (char-after (match-beginning 3))) | 1392 li (char-after (match-beginning 3))) |
1407 (save-excursion | 1393 (with-current-buffer canonicalization-buffer |
1408 (set-buffer canonicalization-buffer) | 1394 ;; char-equal is ignoring case here, so no need to upcase |
1409 ;; char-equal is ignoring case here, so no need to upcase | 1395 ;; or downcase. |
1410 ;; or downcase. | 1396 (let ((case-fold-search t)) |
1411 (let ((case-fold-search t)) | 1397 (and (char-equal fi (char-after mbox-beg)) |
1412 (and (char-equal fi (char-after mbox-beg)) | 1398 (char-equal li (char-after (1- mbox-end))) |
1413 (char-equal li (char-after (1- mbox-end))) | 1399 (setq mi (char-after (1+ mbox-beg)))))) |
1414 (setq mi (char-after (1+ mbox-beg)))))) | 1400 (when (and mi |
1415 (cond ((and mi | 1401 ;; TODO: use better table than syntax table |
1416 ;; TODO: use better table than syntax table | 1402 (eq ?w (char-syntax mi))) |
1417 (eq ?w (char-syntax mi))) | 1403 (goto-char (match-beginning 3)) |
1418 (goto-char (match-beginning 3)) | 1404 (insert (upcase mi) ". "))) |
1419 (insert (upcase mi) ". "))))) | |
1420 | 1405 |
1421 ;; Nuke name if it is the same as mailbox name. | 1406 ;; Nuke name if it is the same as mailbox name. |
1422 (let ((buffer-length (- (point-max) (point-min))) | 1407 (let ((buffer-length (- (point-max) (point-min))) |
1423 (i 0) | 1408 (i 0) |
1424 (names-match-flag t)) | 1409 (names-match-flag t)) |
1425 (cond ((and (> buffer-length 0) | 1410 (when (and (> buffer-length 0) |
1426 (eq buffer-length (- mbox-end mbox-beg))) | 1411 (eq buffer-length (- mbox-end mbox-beg))) |
1427 (goto-char (point-max)) | 1412 (goto-char (point-max)) |
1428 (insert-buffer-substring canonicalization-buffer | 1413 (insert-buffer-substring canonicalization-buffer |
1429 mbox-beg mbox-end) | 1414 mbox-beg mbox-end) |
1430 (while (and names-match-flag | 1415 (while (and names-match-flag |
1431 (< i buffer-length)) | 1416 (< i buffer-length)) |
1432 (or (eq (downcase (char-after (+ i (point-min)))) | 1417 (or (eq (downcase (char-after (+ i (point-min)))) |
1433 (downcase | 1418 (downcase |
1434 (char-after (+ i buffer-length (point-min))))) | 1419 (char-after (+ i buffer-length (point-min))))) |
1435 (setq names-match-flag nil)) | 1420 (setq names-match-flag nil)) |
1436 (setq i (1+ i))) | 1421 (setq i (1+ i))) |
1437 (delete-region (+ (point-min) buffer-length) (point-max)) | 1422 (delete-region (+ (point-min) buffer-length) (point-max)) |
1438 (if names-match-flag | 1423 (if names-match-flag |
1439 (narrow-to-region (point) (point)))))) | 1424 (narrow-to-region (point) (point))))) |
1440 | 1425 |
1441 ;; Nuke name if it's just one word. | 1426 ;; Nuke name if it's just one word. |
1442 (goto-char (point-min)) | 1427 (goto-char (point-min)) |
1443 (and mail-extr-ignore-single-names | 1428 (and mail-extr-ignore-single-names |
1444 (not (re-search-forward "[- ]" nil t)) | 1429 (not (re-search-forward "[- ]" nil t)) |
1446 | 1431 |
1447 ;; Record the result | 1432 ;; Record the result |
1448 (setq value-list | 1433 (setq value-list |
1449 (cons (list (if (not (= (point-min) (point-max))) | 1434 (cons (list (if (not (= (point-min) (point-max))) |
1450 (buffer-string)) | 1435 (buffer-string)) |
1451 (save-excursion | 1436 (with-current-buffer canonicalization-buffer |
1452 (set-buffer canonicalization-buffer) | |
1453 (if (not (= (point-min) (point-max))) | 1437 (if (not (= (point-min) (point-max))) |
1454 (buffer-string)))) | 1438 (buffer-string)))) |
1455 value-list)) | 1439 value-list)) |
1456 | 1440 |
1457 ;; Unless one address is all we wanted, | 1441 ;; Unless one address is all we wanted, |
1490 (while (not (eobp)) | 1474 (while (not (eobp)) |
1491 ;; Initialize for this iteration of the loop. | 1475 ;; Initialize for this iteration of the loop. |
1492 (skip-chars-forward "^({[\"'`") | 1476 (skip-chars-forward "^({[\"'`") |
1493 (let ((cbeg (point))) | 1477 (let ((cbeg (point))) |
1494 (set-syntax-table mail-extr-address-text-comment-syntax-table) | 1478 (set-syntax-table mail-extr-address-text-comment-syntax-table) |
1495 (cond ((memq (following-char) '(?\' ?\`)) | 1479 (if (memq (following-char) '(?\' ?\`)) |
1496 (search-forward "'" nil 'move | 1480 (search-forward "'" nil 'move |
1497 (if (eq ?\' (following-char)) 2 1))) | 1481 (if (eq ?\' (following-char)) 2 1)) |
1498 (t | 1482 (or (mail-extr-safe-move-sexp 1) |
1499 (or (mail-extr-safe-move-sexp 1) | 1483 (goto-char (point-max)))) |
1500 (goto-char (point-max))))) | |
1501 (set-syntax-table mail-extr-address-text-syntax-table) | 1484 (set-syntax-table mail-extr-address-text-syntax-table) |
1502 (when (eq (char-after cbeg) ?\() | 1485 (when (eq (char-after cbeg) ?\() |
1503 ;; Delete the comment itself. | 1486 ;; Delete the comment itself. |
1504 (delete-region cbeg (point)) | 1487 (delete-region cbeg (point)) |
1505 ;; Canonicalize whitespace where the comment was. | 1488 ;; Canonicalize whitespace where the comment was. |
1520 ;; "Piet.Rypens" <rypens@reks.uia.ac.be> | 1503 ;; "Piet.Rypens" <rypens@reks.uia.ac.be> |
1521 ;;(goto-char (point-min)) | 1504 ;;(goto-char (point-min)) |
1522 ;;(while (re-search-forward mail-extr-bad-dot-pattern nil t) | 1505 ;;(while (re-search-forward mail-extr-bad-dot-pattern nil t) |
1523 ;; (replace-match "\\1 \\2" t)) | 1506 ;; (replace-match "\\1 \\2" t)) |
1524 | 1507 |
1525 (cond ((not (search-forward " " nil t)) | 1508 (unless (search-forward " " nil t) |
1526 (goto-char (point-min)) | 1509 (goto-char (point-min)) |
1527 (cond ((search-forward "_" nil t) | 1510 (cond ((search-forward "_" nil t) |
1528 ;; Handle the *idiotic* use of underlines as spaces. | 1511 ;; Handle the *idiotic* use of underlines as spaces. |
1529 ;; Example: fml@foo.bar.dom (First_M._Last) | 1512 ;; Example: fml@foo.bar.dom (First_M._Last) |
1530 (goto-char (point-min)) | 1513 (goto-char (point-min)) |
1531 (while (search-forward "_" nil t) | 1514 (while (search-forward "_" nil t) |
1532 (replace-match " " t))) | 1515 (replace-match " " t))) |
1533 ((search-forward "." nil t) | 1516 ((search-forward "." nil t) |
1534 ;; Fix . used as space | 1517 ;; Fix . used as space |
1535 ;; Example: danj1@cb.att.com (daniel.jacobson) | 1518 ;; Example: danj1@cb.att.com (daniel.jacobson) |
1536 (goto-char (point-min)) | 1519 (goto-char (point-min)) |
1537 (while (re-search-forward mail-extr-bad-dot-pattern nil t) | 1520 (while (re-search-forward mail-extr-bad-dot-pattern nil t) |
1538 (replace-match "\\1 \\2" t)))))) | 1521 (replace-match "\\1 \\2" t))))) |
1539 | 1522 |
1540 ;; Loop over the words (and other junk) in the name. | 1523 ;; Loop over the words (and other junk) in the name. |
1541 (goto-char (point-min)) | 1524 (goto-char (point-min)) |
1542 (while (not name-done-flag) | 1525 (while (not name-done-flag) |
1543 | 1526 |
1544 (cond (word-found-flag | 1527 (when word-found-flag |
1545 ;; Last time through this loop we skipped over a word. | 1528 ;; Last time through this loop we skipped over a word. |
1546 (setq last-word-beg this-word-beg) | 1529 (setq last-word-beg this-word-beg) |
1547 (setq drop-last-word-if-trailing-flag | 1530 (setq drop-last-word-if-trailing-flag |
1548 drop-this-word-if-trailing-flag) | 1531 drop-this-word-if-trailing-flag) |
1549 (setq word-found-flag nil))) | 1532 (setq word-found-flag nil)) |
1550 | 1533 |
1551 (cond (begin-again-flag | 1534 (when begin-again-flag |
1552 ;; Last time through the loop we found something that | 1535 ;; Last time through the loop we found something that |
1553 ;; indicates we should pretend we are beginning again from | 1536 ;; indicates we should pretend we are beginning again from |
1554 ;; the start. | 1537 ;; the start. |
1555 (setq word-count 0) | 1538 (setq word-count 0) |
1556 (setq last-word-beg nil) | 1539 (setq last-word-beg nil) |
1557 (setq drop-last-word-if-trailing-flag nil) | 1540 (setq drop-last-word-if-trailing-flag nil) |
1558 (setq mixed-case-flag nil) | 1541 (setq mixed-case-flag nil) |
1559 (setq lower-case-flag nil) | 1542 (setq lower-case-flag nil) |
1560 ;; (setq upper-case-flag nil) | 1543 ;; (setq upper-case-flag nil) |
1561 (setq begin-again-flag nil) | 1544 (setq begin-again-flag nil)) |
1562 )) | |
1563 | 1545 |
1564 ;; Initialize for this iteration of the loop. | 1546 ;; Initialize for this iteration of the loop. |
1565 (mail-extr-skip-whitespace-forward) | 1547 (mail-extr-skip-whitespace-forward) |
1566 (if (eq word-count 0) (narrow-to-region (point) (point-max))) | 1548 (if (eq word-count 0) (narrow-to-region (point) (point-max))) |
1567 (setq this-word-beg (point)) | 1549 (setq this-word-beg (point)) |
1623 (setq cbeg (point)) | 1605 (setq cbeg (point)) |
1624 (set-syntax-table mail-extr-address-text-comment-syntax-table) | 1606 (set-syntax-table mail-extr-address-text-comment-syntax-table) |
1625 (cond ((memq (following-char) '(?\' ?\`)) | 1607 (cond ((memq (following-char) '(?\' ?\`)) |
1626 (or (search-forward "'" nil t | 1608 (or (search-forward "'" nil t |
1627 (if (eq ?\' (following-char)) 2 1)) | 1609 (if (eq ?\' (following-char)) 2 1)) |
1628 (mail-extr-delete-char 1))) | 1610 (delete-char 1))) |
1629 (t | 1611 (t |
1630 (or (mail-extr-safe-move-sexp 1) | 1612 (or (mail-extr-safe-move-sexp 1) |
1631 (goto-char (point-max))))) | 1613 (goto-char (point-max))))) |
1632 (set-syntax-table mail-extr-address-text-syntax-table) | 1614 (set-syntax-table mail-extr-address-text-syntax-table) |
1633 (setq cend (point)) | 1615 (setq cend (point)) |
1716 ;; Handle & substitution, when & is last and is not first. | 1698 ;; Handle & substitution, when & is last and is not first. |
1717 ((and (> word-count 0) | 1699 ((and (> word-count 0) |
1718 (eq ?\ (preceding-char)) | 1700 (eq ?\ (preceding-char)) |
1719 (eq (following-char) ?&) | 1701 (eq (following-char) ?&) |
1720 (eq (1+ (point)) (point-max))) | 1702 (eq (1+ (point)) (point-max))) |
1721 (mail-extr-delete-char 1) | 1703 (delete-char 1) |
1722 (capitalize-region | 1704 (capitalize-region |
1723 (point) | 1705 (point) |
1724 (progn | 1706 (progn |
1725 (insert-buffer-substring canonicalization-buffer | 1707 (insert-buffer-substring canonicalization-buffer |
1726 mbox-beg mbox-end) | 1708 mbox-beg mbox-end) |
1799 ;; We simply refuse to believe that any last name is PARC or ADOC. | 1781 ;; We simply refuse to believe that any last name is PARC or ADOC. |
1800 ;; If it looks like that is the last name, that there is no meaningful | 1782 ;; If it looks like that is the last name, that there is no meaningful |
1801 ;; here at all. Actually I guess it would be best to map patterns | 1783 ;; here at all. Actually I guess it would be best to map patterns |
1802 ;; like foo.hoser@xerox.com into foo@hoser.xerox.com, but I don't | 1784 ;; like foo.hoser@xerox.com into foo@hoser.xerox.com, but I don't |
1803 ;; actually know that that is what's going on. | 1785 ;; actually know that that is what's going on. |
1804 (cond ((not suffix-flag) | 1786 (unless suffix-flag |
1805 (goto-char (point-min)) | 1787 (goto-char (point-min)) |
1806 (let ((case-fold-search t)) | 1788 (let ((case-fold-search t)) |
1807 (if (looking-at "[-A-Za-z_]+[. ]\\(PARC\\|ADOC\\)\\'") | 1789 (if (looking-at "[-A-Za-z_]+[. ]\\(PARC\\|ADOC\\)\\'") |
1808 (erase-buffer))))) | 1790 (erase-buffer)))) |
1809 | 1791 |
1810 ;; If last name first put it at end (but before suffix) | 1792 ;; If last name first put it at end (but before suffix) |
1811 (cond (last-name-comma-flag | 1793 (when last-name-comma-flag |
1812 (goto-char (point-min)) | 1794 (goto-char (point-min)) |
1813 (search-forward ",") | 1795 (search-forward ",") |
1814 (setq name-end (1- (point))) | 1796 (setq name-end (1- (point))) |
1815 (goto-char (or suffix-flag (point-max))) | 1797 (goto-char (or suffix-flag (point-max))) |
1816 (or (eq ?\ (preceding-char)) | 1798 (or (eq ?\ (preceding-char)) |
1817 (insert ?\ )) | 1799 (insert ?\ )) |
1818 (insert-buffer-substring (current-buffer) (point-min) name-end) | 1800 (insert-buffer-substring (current-buffer) (point-min) name-end) |
1819 (goto-char name-end) | 1801 (goto-char name-end) |
1820 (skip-chars-forward "\t ,") | 1802 (skip-chars-forward "\t ,") |
1821 (narrow-to-region (point) (point-max)))) | 1803 (narrow-to-region (point) (point-max))) |
1822 | 1804 |
1823 ;; Delete leading and trailing junk characters. | 1805 ;; Delete leading and trailing junk characters. |
1824 ;; *** This is probably completely unneeded now. | 1806 ;; *** This is probably completely unneeded now. |
1825 ;;(goto-char (point-max)) | 1807 ;;(goto-char (point-max)) |
1826 ;;(skip-chars-backward mail-extr-non-end-name-chars) | 1808 ;;(skip-chars-backward mail-extr-non-end-name-chars) |
1849 ;; a U.S. FIPS that specifies a different set of two-letter country | 1831 ;; a U.S. FIPS that specifies a different set of two-letter country |
1850 ;; abbreviations. | 1832 ;; abbreviations. |
1851 | 1833 |
1852 (defconst mail-extr-all-top-level-domains | 1834 (defconst mail-extr-all-top-level-domains |
1853 (let ((ob (make-vector 739 0))) | 1835 (let ((ob (make-vector 739 0))) |
1854 (mapcar | 1836 (mapc |
1855 (function | 1837 (lambda (x) |
1856 (lambda (x) | 1838 (put (intern (downcase (car x)) ob) |
1857 (put (intern (downcase (car x)) ob) | 1839 'domain-name |
1858 'domain-name | 1840 (if (nth 2 x) |
1859 (if (nth 2 x) | 1841 (format (nth 2 x) (nth 1 x)) |
1860 (format (nth 2 x) (nth 1 x)) | 1842 (nth 1 x)))) |
1861 (nth 1 x))))) | |
1862 '( | 1843 '( |
1863 ;; ISO 3166 codes: | 1844 ;; ISO 3166 codes: |
1864 ("ad" "Andorra") | 1845 ("ad" "Andorra") |
1865 ("ae" "United Arab Emirates") | 1846 ("ae" "United Arab Emirates") |
1866 ("af" "Afghanistan") | 1847 ("af" "Afghanistan") |