annotate lisp/utils/mail-extr.el @ 38:1a767b41a199 r19-15b102

Import from CVS: tag r19-15b102
author cvs
date Mon, 13 Aug 2007 08:54:01 +0200
parents ec9a17fef872
children 131b0175ea99
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; mail-extr.el --- extract full name and address from RFC 822 mail header.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;; Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; Author: Joe Wells <jbw@cs.bu.edu>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; Maintainer: Chuck Thompson <cthomp@xemacs.org>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;; Version: 1.8
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;; Keywords: mail
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;; This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;; under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; XEmacs is distributed in the hope that it will be useful, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;; General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;; You should have received a copy of the GNU General Public License
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 6
diff changeset
23 ;; along with XEmacs; see the file COPYING. If not, write to the
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 6
diff changeset
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 6
diff changeset
25 ;; Boston, MA 02111-1307, USA.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;;; Synched up with: Not synched with FSF but close to 19.28.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;;; Commentary:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;; The entry point of this code is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;; mail-extract-address-components: (address)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 ;; Given an RFC-822 ADDRESS, extract full name and canonical address.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 ;; Returns a list of the form (FULL-NAME CANONICAL-ADDRESS).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 ;; If no name can be extracted, FULL-NAME will be nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 ;; ADDRESS may be a string or a buffer. If it is a buffer, the visible
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 ;; (narrowed) portion of the buffer will be interpreted as the address.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 ;; (This feature exists so that the clever caller might be able to avoid
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 ;; consing a string.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 ;; If ADDRESS contains more than one RFC-822 address, only the first is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 ;; returned.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 ;; This code is more correct (and more heuristic) parser than the code in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 ;; rfc822.el. And despite its size, it's fairly fast.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 ;; There are two main benefits:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 ;; 1. Higher probability of getting the correct full name for a human than
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 ;; any other package we know of. (On the other hand, it will cheerfully
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 ;; mangle non-human names/comments.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 ;; 2. Address part is put in a canonical form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 ;; The interface is not yet carved in stone; please give us suggestions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 ;; We have an extensive test-case collection of funny addresses if you want to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 ;; work with the code. Developing this code requires frequent testing to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 ;; make sure you're not breaking functionality. The test cases aren't included
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 ;; because they are over 100K.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 ;; If you find an address that mail-extr fails on, please send it to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 ;; maintainer along with what you think the correct results should be. We do
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 ;; not consider it a bug if mail-extr mangles a comment that does not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 ;; correspond to a real human full name, although we would prefer that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 ;; mail-extr would return the comment as-is.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 ;; Features:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 ;; * Full name handling:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 ;; * knows where full names can be found in an address.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 ;; * avoids using empty comments and quoted text.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 ;; * extracts full names from mailbox names.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 ;; * recognizes common formats for comments after a full name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 ;; * puts a period and a space after each initial.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 ;; * understands & referring to the mailbox name, capitalized.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 ;; * strips name prefixes like "Prof.", etc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 ;; * understands what characters can occur in names (not just letters).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 ;; * figures out middle initial from mailbox name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 ;; * removes funny nicknames.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 ;; * keeps suffixes such as Jr., Sr., III, etc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 ;; * reorders "Last, First" type names.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 ;; * Address handling:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 ;; * parses rfc822 quoted text, comments, and domain literals.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 ;; * parses rfc822 multi-line headers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 ;; * does something reasonable with rfc822 GROUP addresses.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 ;; * handles many rfc822 noncompliant and garbage addresses.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 ;; * canonicalizes addresses (after stripping comments/phrases outside <>).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 ;; * converts ! addresses into .UUCP and %-style addresses.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 ;; * converts rfc822 ROUTE addresses to %-style addresses.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 ;; * truncates %-style addresses at leftmost fully qualified domain name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 ;; * handles local relative precedence of ! vs. % and @ (untested).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 ;; It does almost no string creation. It primarily uses the built-in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 ;; parsing routines with the appropriate syntax tables. This should
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 ;; result in greater speed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 ;; TODO:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 ;; * handle all test cases. (This will take forever.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 ;; * software to pick the correct header to use (eg., "Senders-Name:").
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 ;; * multiple addresses in the "From:" header (almost all of the necessary
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 ;; code is there).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 ;; * flag to not treat `,' as an address separator. (This is useful when
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 ;; there is a "From:" header but no "Sender:" header, because then there
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 ;; is only allowed to be one address.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 ;; * mailbox name does not necessarily contain full name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 ;; * fixing capitalization when it's all upper or lowercase. (Hard!)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 ;; * some of the domain literal handling is missing. (But I've never even
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 ;; seen one of these in a mail address, so maybe no big deal.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 ;; * arrange to have syntax tables byte-compiled.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 ;; * speed hacks.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 ;; * delete unused variables.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 ;; * arrange for testing with different relative precedences of ! vs. @
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 ;; and %.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 ;; * insert documentation strings!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 ;; * handle X.400-gatewayed addresses according to RFC 1148.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 ;;; Change Log:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 ;; Thu Feb 17 17:57:33 1994 Jamie Zawinski (jwz@netscape.com)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 ;; * merged with jbw's latest version
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 ;; Wed Feb 9 21:56:27 1994 Jamie Zawinski (jwz@netscape.com)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 ;; * high-bit chars in comments weren't treated as word syntax
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 ;; Sat Feb 5 03:13:40 1994 Jamie Zawinski (jwz@netscape.com)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 ;; * call replace-match with fixed-case arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 ;; Thu Dec 16 21:56:45 1993 Jamie Zawinski (jwz@netscape.com)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 ;; * some more cleanup, doc, added provide
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 ;; Tue Mar 23 21:23:18 1993 Joe Wells (jbw at csd.bu.edu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 ;; * Made mail-full-name-prefixes a user-customizable variable.
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
143 ;; Allow passing the address as a buffer as well as a string.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 ;; Allow [ and ] as name characters (Finnish character set).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 ;; Mon Mar 22 21:20:56 1993 Joe Wells (jbw at bigbird.bu.edu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 ;; * Handle "null" addresses. Handle = used for spacing in mailbox
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 ;; name. Fix bug in handling of ROUTE-ADDR-type addresses that are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 ;; missing their brackets. Handle uppercase "JR". Extract full
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 ;; names from X.400 addresses encoded in RFC-822. Fix bug in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 ;; handling of multiple addresses where first has trailing comment.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 ;; Handle more kinds of telephone extension lead-ins.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 ;; Mon Mar 22 20:16:57 1993 Joe Wells (jbw at bigbird.bu.edu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 ;; * Handle HZ encoding for embedding GB encoded chinese characters.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 ;; Mon Mar 22 00:46:12 1993 Joe Wells (jbw at bigbird.bu.edu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 ;; * Fixed too broad matching of ham radio call signs. Fixed bug in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 ;; handling an unmatched ' in a name string. Enhanced recognition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 ;; of when . in the mailbox name terminates the name portion.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 ;; Narrowed conversion of . to space to only the necessary
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 ;; situation. Deal with VMS's stupid date stamps. Handle a unique
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 ;; way of introducing an alternate address. Fixed spacing bug I
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 ;; introduced in switching last name order. Fixed bug in handling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 ;; address with ! and % but no @. Narrowed the cases in which
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 ;; certain trailing words are discarded.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 ;; Sun Mar 21 21:41:06 1993 Joe Wells (jbw at bigbird.bu.edu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 ;; * Fixed bugs in handling GROUP addresses. Certain words in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 ;; middle of a name no longer terminate it. Handle LISTSERV list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 ;; names. Ignore comment field containing mailbox name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 ;; Sun Mar 21 14:39:38 1993 Joe Wells (jbw at bigbird.bu.edu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 ;; * Moved variant-method code back into main function. Handle
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 ;; underscores as spaces in comments. Handle leading nickname. Add
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 ;; flag to ignore single-word names. Other changes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 ;; Mon Feb 1 22:23:31 1993 Joe Wells (jbw at bigbird.bu.edu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 ;; * Added in changes by Rod Whitby and Jamie Zawinski. This
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 ;; includes the flag mail-extr-guess-middle-initial and the fix for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 ;; handling multiple addresses correctly.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 ;; Mon Apr 6 23:59:09 1992 Joe Wells (jbw at bigbird.bu.edu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 ;; * Cleaned up some more. Release version 1.0 to world.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 ;; Sun Apr 5 19:39:08 1992 Joe Wells (jbw at bigbird.bu.edu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 ;; * Cleaned up full name extraction extensively.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 ;; Sun Feb 2 14:45:24 1992 Joe Wells (jbw at bigbird.bu.edu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 ;; * Total rewrite. Integrated mail-canonicalize-address into
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 ;; mail-extract-address-components. Now handles GROUP addresses more
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 ;; or less correctly. Better handling of lots of different cases.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 ;; Fri Jun 14 19:39:50 1991
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 ;; * Created.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 ;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 ;; User configuration variable definitions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (defvar mail-extr-guess-middle-initial nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 "*Whether to try to guess middle initial from mail address.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 If true, then when we see an address like \"John Smith <jqs@host.com>\"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 we will assume that \"John Q. Smith\" is the fellow's name.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 (defvar mail-extr-ignore-single-names t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 "*Whether to ignore a name that is just a single word.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 If true, then when we see an address like \"Idiot <dumb@stupid.com>\"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 we will act as though we couldn't find a full name in the address.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 ;; Matches a leading title that is not part of the name (does not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 ;; contribute to uniquely identifying the person).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 (defvar mail-extr-full-name-prefixes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 (purecopy
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 "\\(Prof\\|D[Rr]\\|Mrs?\\|Rev\\|Rabbi\\|SysOp\\|LCDR\\)\\.?[ \t\n]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 "*Matches prefixes to the full name that identify a person's position.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 These are stripped from the full name because they do not contribute to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 uniquely identifying the person.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (defvar mail-extr-@-binds-tighter-than-! nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 "*Whether the local mail transport agent looks at ! before @.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (defvar mail-extr-mangle-uucp nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 "*Whether to throw away information in UUCP addresses
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 by translating things like \"foo!bar!baz@host\" into \"baz@bar.UUCP\".")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239
38
1a767b41a199 Import from CVS: tag r19-15b102
cvs
parents: 30
diff changeset
240 (defvar mail-extr-mailbox-match-case-fold t
1a767b41a199 Import from CVS: tag r19-15b102
cvs
parents: 30
diff changeset
241 "*Non-nil if mailbox and name matching should ignore case.")
1a767b41a199 Import from CVS: tag r19-15b102
cvs
parents: 30
diff changeset
242
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 ;;----------------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 ;; what orderings are meaningful?????
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 ;;(defvar mail-operator-precedence-list '(?! ?% ?@))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 ;; Right operand of a % or a @ must be a domain name, period. No other
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 ;; operators allowed. Left operand of a @ is an address relative to that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 ;; site.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 ;; Left operand of a ! must be a domain name. Right operand is an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 ;; arbitrary address.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 ;;----------------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 ;; Constant definitions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 ;; Codes in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 ;; Names in ISO 8859-1 Name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 ;; ISO 10XXX ISO 8859-2 in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 ;; ISO 6937 ISO 10646 RFC Swedish
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 ;; etc. Hex Oct 1345 TeX Split ASCII Description
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 ;; --------- ---------- ---- --- ----- ----- -------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 ;; %a E4 344 a: \"a ae { latin small a + diaeresis ä
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 ;; %o F6 366 o: \"o oe | latin small o + diaeresis ö
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 ;; @a E5 345 aa \oa aa } latin small a + ring above å
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 ;; %u FC 374 u: \"u ue ~ latin small u + diaeresis ü
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 ;; /e E9 351 e' \'e ` latin small e + acute é
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 ;; %A C4 304 A: \"A AE [ latin capital a + diaeresis Ä
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 ;; %O D6 326 O: \"O OE \ latin capital o + diaeresis Ö
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 ;; @A C5 305 AA \oA AA ] latin capital a + ring above Å
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 ;; %U DC 334 U: \"U UE ^ latin capital u + diaeresis Ü
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 ;; /E C9 311 E' \'E @ latin capital e + acute É
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 ;; NOTE: @a and @A are not in ISO 8859-2 (the codes mentioned above invoke
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 ;; /l and /L). Some of this data was retrieved from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 ;; listserv@jhuvm.hcf.jhu.edu.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 ;; Any character that can occur in a name, not counting characters that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 ;; separate parts of a multipart name (hyphen and period).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 ;; Yes, there are weird people with digits in their names.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 ;; You will also notice the consideration for the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 ;; Swedish/Finnish/Norwegian character set.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 ;; #### (go to \376 instead of \377 to work around bug in search.c...)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 (defconst mail-extr-all-letters-but-separators
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 (purecopy "][A-Za-z{|}'~0-9`\200-\376"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 ;; Any character that can occur in a name in an RFC822 address including
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 ;; the separator (hyphen and possibly period) for multipart names.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 ;; #### should . be in here?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 (defconst mail-extr-all-letters
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 (purecopy (concat mail-extr-all-letters-but-separators "---")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 ;; Any character that can start a name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 ;; Keep this set as minimal as possible.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 (defconst mail-extr-first-letters (purecopy "A-Za-z"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 ;; Any character that can end a name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 ;; Keep this set as minimal as possible.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 (defconst mail-extr-last-letters (purecopy "[A-Za-z`'."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 (defconst mail-extr-leading-garbage
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 (purecopy (format "[^%s]+" mail-extr-first-letters)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 ;; (defconst mail-extr-non-name-chars
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 ;; (purecopy (concat "^" mail-extr-all-letters ".")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 ;; (defconst mail-extr-non-begin-name-chars
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 ;; (purecopy (concat "^" mail-extr-first-letters)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 ;; (defconst mail-extr-non-end-name-chars
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 ;; (purecopy (concat "^" mail-extr-last-letters)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 ;; Matches an initial not followed by both a period and a space.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 ;; (defconst mail-extr-bad-initials-pattern
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 ;; (purecopy
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 ;; (format "\\(\\([^%s]\\|\\`\\)[%s]\\)\\(\\.\\([^ ]\\)\\| \\|\\([^%s .]\\)\\|\\'\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 ;; mail-extr-all-letters mail-extr-first-letters mail-extr-all-letters)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 ;; Matches periods used instead of spaces. Must not match the period
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 ;; following an initial.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 (defconst mail-extr-bad-dot-pattern
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 (purecopy
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 (format "\\([%s][%s]\\)\\.+\\([%s]\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 mail-extr-all-letters
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 mail-extr-last-letters
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 mail-extr-first-letters)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 ;; Matches an embedded or leading nickname that should be removed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 ;; (defconst mail-extr-nickname-pattern
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 ;; (purecopy
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 ;; (format "\\([ .]\\|\\`\\)[\"'`\[\(]\\([ .%s]+\\)[\]\"'\)] "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 ;; mail-extr-all-letters)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 ;; Matches the occurrence of a generational name suffix, and the last
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 ;; character of the preceding name. This is important because we want to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 ;; keep such suffixes: they help to uniquely identify the person.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 ;; *** Perhaps this should be a user-customizable variable. However, the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 ;; *** regular expression is fairly tricky to alter, so maybe not.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 (defconst mail-extr-full-name-suffix-pattern
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 (purecopy
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 (format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 "\\(,? ?\\([JjSs][Rr]\\.?\\|V?I+V?\\)\\)\\([^%s]\\([^%s]\\|\\'\\)\\|\\'\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 mail-extr-all-letters mail-extr-all-letters)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 (defconst mail-extr-roman-numeral-pattern (purecopy "V?I+V?\\b"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 ;; Matches a trailing uppercase (with other characters possible) acronym.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 ;; Must not match a trailing uppercase last name or trailing initial
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 (defconst mail-extr-weird-acronym-pattern
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 (purecopy "\\([A-Z]+[-_/]\\|[A-Z][A-Z][A-Z]?\\b\\)"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 ;; Matches a mixed-case or lowercase name (not an initial).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 ;; #### Match Latin1 lower case letters here too?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 ;; (defconst mail-extr-mixed-case-name-pattern
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 ;; (purecopy
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 ;; (format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 ;; "\\b\\([a-z][%s]*[%s]\\|[%s][%s]*[a-z][%s]*[%s]\\|[%s][%s]*[a-z]\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 ;; mail-extr-all-letters mail-extr-last-letters
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 ;; mail-extr-first-letters mail-extr-all-letters mail-extr-all-letters
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 ;; mail-extr-last-letters mail-extr-first-letters mail-extr-all-letters)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 ;; Matches a trailing alternative address.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 ;; #### Match Latin1 letters here too?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 ;; #### Match _ before @ here too?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 (defconst mail-extr-alternative-address-pattern
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 (purecopy "\\(aka *\\)?[a-zA-Z.]+[!@][a-zA-Z.]"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 ;; Matches a variety of trailing comments not including comma-delimited
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 ;; comments.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 (defconst mail-extr-trailing-comment-start-pattern
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 (purecopy " [-{]\\|--\\|[+@#></\;]"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 ;; Matches a name (not an initial).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 ;; This doesn't force a word boundary at the end because sometimes a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 ;; comment is separated by a `-' with no preceding space.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 (defconst mail-extr-name-pattern
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 (purecopy (format "\\b[%s][%s]*[%s]"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 mail-extr-first-letters
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 mail-extr-all-letters
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 mail-extr-last-letters)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 (defconst mail-extr-initial-pattern
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 (purecopy (format "\\b[%s]\\([. ]\\|\\b\\)" mail-extr-first-letters)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 ;; Matches a single name before a comma.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 ;; (defconst mail-extr-last-name-first-pattern
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 ;; (purecopy (concat "\\`" mail-extr-name-pattern ",")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 ;; Matches telephone extensions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 (defconst mail-extr-telephone-extension-pattern
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 (purecopy
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 "\\(\\([Ee]xt\\|\\|[Tt]ph\\|[Tt]el\\|[Xx]\\).?\\)? *\\+?[0-9][- 0-9]+"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 ;; Matches ham radio call signs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 ;; Help from: Mat Maessen N2NJZ <maessm@rpi.edu>, Mark Feit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 ;; <mark@era.com>, Michael Covington <mcovingt@ai.uga.edu>.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 ;; Examples: DX504 DX515 K5MRU K8DHK KA9WGN KA9WGN KD3FU KD6EUI KD6HBW
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 ;; KE9TV KF0NV N1API N3FU N3GZE N3IGS N4KCC N7IKQ N9HHU W4YHF W6ANK WA2SUH
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 ;; WB7VZI N2NJZ NR3G KJ4KK AB4UM AL7NI KH6OH WN3KBT N4TMI W1A N0NZO
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 (defconst mail-extr-ham-call-sign-pattern
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 (purecopy "\\b\\(DX[0-9]+\\|[AKNW][A-Z]?[0-9][A-Z][A-Z]?[A-Z]?\\)"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 ;; Possible trailing suffixes: "\\(/\\(KT\\|A[AEG]\\|[R0-9]\\)\\)?"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 ;; /KT == Temporary Technician (has CSC but not "real" license)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 ;; /AA == Temporary Advanced
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 ;; /AE == Temporary Extra
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 ;; /AG == Temporary General
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 ;; /R == repeater
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 ;; /# == stations operating out of home district
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 ;; I don't include these in the regexp above because I can't imagine
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 ;; anyone putting them with their name in an e-mail address.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 ;; Matches normal single-part name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 (defconst mail-extr-normal-name-pattern
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 (purecopy (format "\\b[%s][%s]+[%s]"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 mail-extr-first-letters
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 mail-extr-all-letters-but-separators
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 mail-extr-last-letters)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 ;; Matches a single word name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 ;; (defconst mail-extr-one-name-pattern
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 ;; (purecopy (concat "\\`" mail-extr-normal-name-pattern "\\'")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 ;; Matches normal two names with missing middle initial
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 ;; The first name is not allowed to have a hyphen because this can cause
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 ;; false matches where the "middle initial" is actually the first letter
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 ;; of the second part of the first name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 (defconst mail-extr-two-name-pattern
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 (purecopy
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 (concat "\\`\\(" mail-extr-normal-name-pattern
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 "\\|" mail-extr-initial-pattern
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 "\\) +\\(" mail-extr-name-pattern "\\)\\(,\\|\\'\\)")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 (defconst mail-extr-listserv-list-name-pattern
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 (purecopy "Multiple recipients of list \\([-A-Z]+\\)"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 (defconst mail-extr-stupid-vms-date-stamp-pattern
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 (purecopy
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 "[0-9][0-9]-[JFMASOND][aepuco][nbrylgptvc]-[0-9][0-9][0-9][0-9] [0-9]+ *"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 ;;; HZ -- GB (PRC Chinese character encoding) in ASCII embedding protocol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 ;; In ASCII mode, a byte is interpreted as an ASCII character, unless a '~' is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 ;; encountered. The character '~' is an escape character. By convention, it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 ;; must be immediately followed ONLY by '~', '{' or '\n' (<LF>), with the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 ;; following special meaning.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 ;; o The escape sequence '~~' is interpreted as a '~'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 ;; o The escape-to-GB sequence '~{' switches the mode from ASCII to GB.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 ;; o The escape sequence '~\n' is a line-continuation marker to be consumed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 ;; with no output produced.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 ;; In GB mode, characters are interpreted two bytes at a time as (pure) GB
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 ;; codes until the escape-from-GB code '~}' is read. This code switches the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 ;; mode from GB back to ASCII. (Note that the escape-from-GB code '~}'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 ;; ($7E7D) is outside the defined GB range.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 (defconst mail-extr-hz-embedded-gb-encoded-chinese-pattern
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 (purecopy "~{\\([^~].\\|~[^\}]\\)+~}"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 ;; The leading optional lowercase letters are for a bastardized version of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 ;; the encoding, as is the optional nature of the final slash.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 (defconst mail-extr-x400-encoded-address-pattern
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 (purecopy "[a-z]?[a-z]?\\(/[A-Za-z]+\\(\\.[A-Za-z]+\\)?=[^/]+\\)+/?\\'"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 (defconst mail-extr-x400-encoded-address-field-pattern-format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 (purecopy "/%s=\\([^/]+\\)\\(/\\|\\'\\)"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 (defconst mail-extr-x400-encoded-address-surname-pattern
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 ;; S stands for Surname (family name).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 (purecopy
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 (format mail-extr-x400-encoded-address-field-pattern-format "[Ss]")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 (defconst mail-extr-x400-encoded-address-given-name-pattern
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 ;; G stands for Given name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 (purecopy
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 (format mail-extr-x400-encoded-address-field-pattern-format "[Gg]")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 (defconst mail-extr-x400-encoded-address-full-name-pattern
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 ;; PN stands for Personal Name. When used it represents the combination
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 ;; of the G and S fields.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 ;; "The one system I used having this field asked it with the prompt
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 ;; `Personal Name'. But they mapped it into G and S on outgoing real
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 ;; X.400 addresses. As they mapped G and S into PN on incoming..."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 (purecopy
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 (format mail-extr-x400-encoded-address-field-pattern-format "[Pp][Nn]")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 ;; Syntax tables used for quick parsing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 (defconst mail-extr-address-syntax-table (make-syntax-table))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 (defconst mail-extr-address-comment-syntax-table (make-syntax-table))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 (defconst mail-extr-address-domain-literal-syntax-table (make-syntax-table))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 (defconst mail-extr-address-text-comment-syntax-table (make-syntax-table))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 (defconst mail-extr-address-text-syntax-table (make-syntax-table))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 (lambda (pair)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 (let ((syntax-table (symbol-value (car pair))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 (lambda (item)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 (if (eq 2 (length item))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 ;; modifying syntax of a single character
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 (modify-syntax-entry (car item) (car (cdr item)) syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 ;; modifying syntax of a range of characters
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 (let ((char (nth 0 item))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 (bound (nth 1 item))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 (syntax (nth 2 item)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 (while (<= char bound)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 (modify-syntax-entry char syntax syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 (setq char (1+ char)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 (cdr pair)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 '((mail-extr-address-syntax-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 (?\000 ?\037 "w") ;control characters
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 (?\040 " ") ;SPC
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 (?! ?~ "w") ;printable characters
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 (?\177 "w") ;DEL
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 (?\200 ?\377 "w") ;high-bit-on characters
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 (?\240 " ") ;nobreakspace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 (?\t " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 (?\r " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 (?\n " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 (?\( ".")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 (?\) ".")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 (?< ".")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 (?> ".")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 (?@ ".")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 (?, ".")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 (?\; ".")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 (?: ".")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 (?\\ "\\")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 (?\" "\"")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 (?. ".")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 (?\[ ".")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 (?\] ".")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 ;; % and ! aren't RFC822 characters, but it is convenient to pretend
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 (?% ".")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 (?! ".") ;; this needs to be word-constituent when not in .UUCP mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 (mail-extr-address-comment-syntax-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 (?\000 ?\377 "w")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 (?\040 " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 (?\240 " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 (?\t " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 (?\r " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 (?\n " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 (?\( "\(\)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 (?\) "\)\(")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 (?\\ "\\"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 (mail-extr-address-domain-literal-syntax-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 (?\000 ?\377 "w")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 (?\040 " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 (?\240 " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 (?\t " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 (?\r " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 (?\n " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 (?\[ "\(\]") ;??????
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 (?\] "\)\[") ;??????
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 (?\\ "\\"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 (mail-extr-address-text-comment-syntax-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 (?\000 ?\377 "w")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 (?\040 " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 (?\240 " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 (?\t " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 (?\r " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 (?\n " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 (?\( "\(\)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 (?\) "\)\(")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 (?\[ "\(\]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 (?\] "\)\[")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 (?\{ "\(\}")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 (?\} "\)\{")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 (?\\ "\\")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 (?\" "\"")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 ;; (?\' "\)\`")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 ;; (?\` "\(\'")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 (mail-extr-address-text-syntax-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 (?\000 ?\177 ".")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 (?\200 ?\377 "w")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 (?\040 " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 (?\t " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 (?\r " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 (?\n " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 (?A ?Z "w")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 (?a ?z "w")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 (?- "w")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 (?\} "w")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 (?\{ "w")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 (?| "w")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 (?\' "w")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 (?~ "w")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 (?0 ?9 "w"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 ;; Utility functions and macros.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 (defmacro mail-extr-delete-char (n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 ;; in v19, delete-char is compiled as a function call, but delete-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 ;; is byte-coded, so it's much much faster.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 (list 'delete-region '(point) (list '+ '(point) n)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 (defmacro mail-extr-skip-whitespace-forward ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 ;; v19 fn skip-syntax-forward is more tasteful, but not byte-coded.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 '(skip-chars-forward " \t\n\r\240"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 (defmacro mail-extr-skip-whitespace-backward ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 ;; v19 fn skip-syntax-backward is more tasteful, but not byte-coded.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 '(skip-chars-backward " \t\n\r\240"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 (defmacro mail-extr-undo-backslash-quoting (beg end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 (`(save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 (narrow-to-region (, beg) (, end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 ;; undo \ quoting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 (while (search-forward "\\" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 (mail-extr-delete-char -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 (or (eobp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 (forward-char 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 )))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 (defmacro mail-extr-nuke-char-at (pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 (` (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 (goto-char (, pos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 (mail-extr-delete-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 (insert ?\ ))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 (put 'mail-extr-nuke-outside-range
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 'edebug-form-spec '(symbolp &optional form form atom))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 (defmacro mail-extr-nuke-outside-range (list-symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 beg-symbol end-symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 &optional no-replace)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 ;; LIST-SYMBOL names a variable holding a list of buffer positions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 ;; BEG-SYMBOL and END-SYMBOL name variables delimiting a range
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 ;; Each element of LIST-SYMBOL which lies outside of the range is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 ;; deleted from the list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 ;; Unless NO-REPLACE is true, at each of the positions in LIST-SYMBOL
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 ;; which lie outside of the range, one character at that position is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 ;; replaced with a SPC.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 (or (memq no-replace '(t nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 (error "no-replace must be t or nil, evalable at macroexpand-time."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 (` (let ((temp (, list-symbol))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 ch)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 (while temp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 (setq ch (car temp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 (cond ((or (> ch (, end-symbol))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 (< ch (, beg-symbol)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661 (,@ (if no-replace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 (` ((mail-extr-nuke-char-at ch)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 (setcar temp nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 (setq temp (cdr temp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 (setq (, list-symbol) (delq nil (, list-symbol))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 (defun mail-extr-demarkerize (marker)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 ;; if arg is a marker, destroys the marker, then returns the old value.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 ;; otherwise returns the arg.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 (if (markerp marker)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 (let ((temp (marker-position marker)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 (set-marker marker nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 temp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675 marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 (defun mail-extr-markerize (pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 ;; coerces pos to a marker if non-nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 (if (or (markerp pos) (null pos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 pos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 (copy-marker pos)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 (defmacro mail-extr-last (list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684 ;; Returns last element of LIST.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 ;; Could be a subst.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 (` (let ((list (, list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 (while (not (null (cdr list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 (setq list (cdr list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689 (car list))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 (defmacro mail-extr-safe-move-sexp (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692 ;; Safely skip over one balanced sexp, if there is one. Return t if success.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 (` (condition-case error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 (goto-char (scan-sexps (point) (, arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697 (error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698 ;; #### kludge kludge kludge kludge kludge kludge kludge !!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 (if (string-equal (nth 1 error) "Unbalanced parentheses")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701 (while t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702 (signal (car error) (cdr error))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 (or (fboundp 'buffer-disable-undo) ;; v18 compat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 (fset 'buffer-disable-undo 'buffer-flush-undo))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 ;; The main function to grind addresses
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 (defvar disable-initial-guessing-flag) ; dynamic assignment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 (defvar cbeg) ; dynamic assignment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 (defvar cend) ; dynamic assignment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718 (defun mail-extract-address-components (address)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719 "Given an RFC-822 ADDRESS, extract full name and canonical address.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720 Returns a list of the form (FULL-NAME CANONICAL-ADDRESS).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 If no name can be extracted, FULL-NAME will be nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722 ADDRESS may be a string or a buffer. If it is a buffer, the visible
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723 (narrowed) portion of the buffer will be interpreted as the address.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 (This feature exists so that the clever caller might be able to avoid
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725 consing a string.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726 If ADDRESS contains more than one RFC-822 address, only the first is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 returned. Some day this function may be extended to extract multiple
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728 addresses, or perhaps return the position at which parsing stopped."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729 (let ((canonicalization-buffer (get-buffer-create " *canonical address*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 (extraction-buffer (get-buffer-create " *extract address components*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 ;; multiple-addresses
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 <-pos >-pos @-pos colon-pos comma-pos !-pos %-pos \;-pos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 group-colon-pos group-\;-pos route-addr-colon-pos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735 record-pos-symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736 first-real-pos last-real-pos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737 phrase-beg phrase-end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 cbeg cend ; dynamically set from -voodoo
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 quote-beg quote-end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 atom-beg atom-end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 mbox-beg mbox-end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 \.-ends-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743 temp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744 ;; name-suffix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745 fi mi li ; first, middle, last initial
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746 saved-%-pos saved-!-pos saved-@-pos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747 domain-pos \.-pos insert-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748 ;; mailbox-name-processed-flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 disable-initial-guessing-flag ; dynamically set from -voodoo
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 (set-buffer extraction-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754 (fundamental-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755 (kill-all-local-variables)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 (buffer-disable-undo extraction-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757 (set-syntax-table mail-extr-address-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760 (setq case-fold-search nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762 ;; Insert extra space at beginning to allow later replacement with <
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763 ;; without having to move markers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764 (insert ?\ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766 ;; Insert the address itself.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 (cond ((stringp address)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768 (insert address))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769 ((bufferp address)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
770 (insert-buffer-substring address))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
771 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772 (error "Illegal address: %s" address)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774 ;; stolen from rfc822.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775 ;; Unfold multiple lines.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777 (while (re-search-forward "\\([^\\]\\(\\\\\\\\\\)*\\)\n[ \t]" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778 (replace-match "\\1 " t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 ;; first pass grabs useful information about address
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 (while (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783 (mail-extr-skip-whitespace-forward)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784 (not (eobp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785 (setq char (char-after (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786 (or first-real-pos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787 (if (not (eq char ?\())
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788 (setq first-real-pos (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790 ;; comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 ((eq char ?\()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792 (set-syntax-table mail-extr-address-comment-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793 ;; only record the first non-empty comment's position
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794 (if (and (not cbeg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796 (forward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797 (mail-extr-skip-whitespace-forward)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798 (not (eq ?\) (char-after (point))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799 (setq cbeg (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800 ;; TODO: don't record if unbalanced
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801 (or (mail-extr-safe-move-sexp 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802 (forward-char 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803 (set-syntax-table mail-extr-address-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804 (if (and cbeg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805 (not cend))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806 (setq cend (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807 ;; quoted text
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808 ((eq char ?\")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809 ;; only record the first non-empty quote's position
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810 (if (and (not quote-beg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812 (forward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813 (mail-extr-skip-whitespace-forward)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814 (not (eq ?\" (char-after (point))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
815 (setq quote-beg (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
816 ;; TODO: don't record if unbalanced
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817 (or (mail-extr-safe-move-sexp 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818 (forward-char 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819 (if (and quote-beg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
820 (not quote-end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821 (setq quote-end (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
822 ;; domain literals
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
823 ((eq char ?\[)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
824 (set-syntax-table mail-extr-address-domain-literal-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
825 (or (mail-extr-safe-move-sexp 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826 (forward-char 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827 (set-syntax-table mail-extr-address-syntax-table))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828 ;; commas delimit addresses when outside < > pairs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829 ((and (eq char ?,)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830 (or (and (null <-pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831 ;; Handle ROUTE-ADDR address that is missing its <.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832 (not (eq ?@ (char-after (1+ (point))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
833 (and >-pos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834 ;; handle weird munged addresses
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835 ;; BUG FIX: This test was reversed. Thanks to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836 ;; brilliant Rod Whitby <rwhitby@research.canon.oz.au>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837 ;; for discovering this!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838 (< (mail-extr-last <-pos) (car >-pos)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839 ;; It'd be great if some day this worked, but for now, punt.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840 ;; (setq multiple-addresses t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841 ;; ;; *** Why do I want this:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842 ;; (mail-extr-delete-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843 ;; (narrow-to-region (point-min) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844 (delete-region (point) (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845 (setq char ?\() ; HAVE I NO SHAME??
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847 ;; record the position of various interesting chars, determine
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848 ;; legality later.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849 ((setq record-pos-symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850 (cdr (assq char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 '((?< . <-pos) (?> . >-pos) (?@ . @-pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852 (?: . colon-pos) (?, . comma-pos) (?! . !-pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853 (?% . %-pos) (?\; . \;-pos)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854 (set record-pos-symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855 (cons (point) (symbol-value record-pos-symbol)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856 (forward-char 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857 ((eq char ?.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858 (forward-char 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
859 ((memq char '(
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860 ;; comment terminator illegal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
861 ?\)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
862 ;; domain literal terminator illegal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
863 ?\]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
864 ;; \ allowed only within quoted strings,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
865 ;; domain literals, and comments
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
866 ?\\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
867 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
868 (mail-extr-nuke-char-at (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
869 (forward-char 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
870 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
871 (forward-word 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
872 (or (eq char ?\()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
873 ;; At the end of first address of a multiple address header.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874 (and (eq char ?,)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
875 (eobp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876 (setq last-real-pos (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878 ;; Use only the leftmost <, if any. Replace all others with spaces.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
879 (while (cdr <-pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880 (mail-extr-nuke-char-at (car <-pos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881 (setq <-pos (cdr <-pos)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
882
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
883 ;; Use only the rightmost >, if any. Replace all others with spaces.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
884 (while (cdr >-pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885 (mail-extr-nuke-char-at (nth 1 >-pos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
886 (setcdr >-pos (nthcdr 2 >-pos)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
887
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
888 ;; If multiple @s and a :, but no < and >, insert around buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
889 ;; Example: @foo.bar.dom,@xxx.yyy.zzz:mailbox@aaa.bbb.ccc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890 ;; This commonly happens on the UUCP "From " line. Ugh.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891 (cond ((and (> (length @-pos) 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
892 (eq 1 (length colon-pos)) ;TODO: check if between last two @s
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
893 (not \;-pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
894 (not <-pos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
895 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
896 (mail-extr-delete-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
897 (setq <-pos (list (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
898 (insert ?<)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
899
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
900 ;; If < but no >, insert > in rightmost possible position
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
901 (cond ((and <-pos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
902 (null >-pos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
903 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
904 (setq >-pos (list (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
905 (insert ?>)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
906
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
907 ;; If > but no <, replace > with space.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
908 (cond ((and >-pos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
909 (null <-pos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
910 (mail-extr-nuke-char-at (car >-pos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
911 (setq >-pos nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
912
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
913 ;; Turn >-pos and <-pos into non-lists
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
914 (setq >-pos (car >-pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
915 <-pos (car <-pos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
916
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
917 ;; Trim other punctuation lists of items outside < > pair to handle
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
918 ;; stupid MTAs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
919 (cond (<-pos ; don't need to check >-pos also
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
920 ;; handle bozo software that violates RFC 822 by sticking
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
921 ;; punctuation marks outside of a < > pair
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
922 (mail-extr-nuke-outside-range @-pos <-pos >-pos t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
923 ;; RFC 822 says nothing about these two outside < >, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
924 ;; remove those positions from the lists to make things
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
925 ;; easier.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
926 (mail-extr-nuke-outside-range !-pos <-pos >-pos t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
927 (mail-extr-nuke-outside-range %-pos <-pos >-pos t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
928
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
929 ;; Check for : that indicates GROUP list and for : part of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
930 ;; ROUTE-ADDR spec.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
931 ;; Can't possibly be more than two :. Nuke any extra.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
932 (while colon-pos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
933 (setq temp (car colon-pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
934 colon-pos (cdr colon-pos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
935 (cond ((and <-pos >-pos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
936 (> temp <-pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
937 (< temp >-pos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
938 (if (or route-addr-colon-pos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
939 (< (length @-pos) 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
940 (> temp (car @-pos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
941 (< temp (nth 1 @-pos)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
942 (mail-extr-nuke-char-at temp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
943 (setq route-addr-colon-pos temp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
944 ((or (not <-pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
945 (and <-pos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
946 (< temp <-pos)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
947 (setq group-colon-pos temp))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
948
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
949 ;; Nuke any ; that is in or to the left of a < > pair or to the left
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
950 ;; of a GROUP starting :. Also, there may only be one ;.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
951 (while \;-pos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
952 (setq temp (car \;-pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
953 \;-pos (cdr \;-pos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
954 (cond ((and <-pos >-pos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
955 (> temp <-pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
956 (< temp >-pos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
957 (mail-extr-nuke-char-at temp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
958 ((and (or (not group-colon-pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
959 (> temp group-colon-pos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
960 (not group-\;-pos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
961 (setq group-\;-pos temp))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
962
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
963 ;; Nuke unmatched GROUP syntax characters.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
964 (cond ((and group-colon-pos (not group-\;-pos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
965 ;; *** Do I really need to erase it?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
966 (mail-extr-nuke-char-at group-colon-pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
967 (setq group-colon-pos nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
968 (cond ((and group-\;-pos (not group-colon-pos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
969 ;; *** Do I really need to erase it?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
970 (mail-extr-nuke-char-at group-\;-pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
971 (setq group-\;-pos nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
972
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
973 ;; Handle junk like ";@host.company.dom" that sendmail adds.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
974 ;; **** should I remember comment positions?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
975 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
976 (group-\;-pos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
977 ;; this is fine for now
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
978 (mail-extr-nuke-outside-range !-pos group-colon-pos group-\;-pos t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
979 (mail-extr-nuke-outside-range @-pos group-colon-pos group-\;-pos t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
980 (mail-extr-nuke-outside-range %-pos group-colon-pos group-\;-pos t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
981 (mail-extr-nuke-outside-range comma-pos group-colon-pos group-\;-pos t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
982 (and last-real-pos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
983 (> last-real-pos (1+ group-\;-pos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
984 (setq last-real-pos (1+ group-\;-pos)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
985 ;; *** This may be wrong:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
986 (and cend
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
987 (> cend group-\;-pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
988 (setq cend nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
989 cbeg nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
990 (and quote-end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
991 (> quote-end group-\;-pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
992 (setq quote-end nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
993 quote-beg nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
994 ;; This was both wrong and unnecessary:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
995 ;;(narrow-to-region (point-min) group-\;-pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
996
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
997 ;; *** The entire handling of GROUP addresses seems rather lame.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
998 ;; *** It deserves a complete rethink, except that these addresses
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
999 ;; *** are hardly ever seen.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1000 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1001
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1002 ;; Any commas must be between < and : of ROUTE-ADDR. Nuke any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1003 ;; others.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1004 ;; Hell, go ahead an nuke all of the commas.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1005 ;; **** This will cause problems when we start handling commas in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1006 ;; the PHRASE part .... no it won't ... yes it will ... ?????
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1007 (mail-extr-nuke-outside-range comma-pos 1 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1008
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1009 ;; can only have multiple @s inside < >. The fact that some MTAs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1010 ;; put de-bracketed ROUTE-ADDRs in the UUCP-style "From " line is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1011 ;; handled above.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1012
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1013 ;; Locate PHRASE part of ROUTE-ADDR.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1014 (cond (<-pos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1015 (goto-char <-pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1016 (mail-extr-skip-whitespace-backward)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1017 (setq phrase-end (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1018 (goto-char (or ;;group-colon-pos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1019 (point-min)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1020 (mail-extr-skip-whitespace-forward)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1021 (if (< (point) phrase-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1022 (setq phrase-beg (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1023 (setq phrase-end nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1024
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1025 ;; handle ROUTE-ADDRS with real ROUTEs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1026 ;; If there are multiple @s, then we assume ROUTE-ADDR syntax, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1027 ;; any % or ! must be semantically meaningless.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1028 ;; TODO: do this processing into canonicalization buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1029 (cond (route-addr-colon-pos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1030 (setq !-pos nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1031 %-pos nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1032 >-pos (copy-marker >-pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1033 route-addr-colon-pos (copy-marker route-addr-colon-pos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1034 (goto-char >-pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1035 (insert-before-markers ?X)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1036 (goto-char (car @-pos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1037 (while (setq @-pos (cdr @-pos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1038 (mail-extr-delete-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1039 (setq %-pos (cons (point-marker) %-pos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1040 (insert "%")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1041 (goto-char (1- >-pos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1042 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1043 (insert-buffer-substring extraction-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1044 (car @-pos) route-addr-colon-pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1045 (delete-region (car @-pos) route-addr-colon-pos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1046 (or (cdr @-pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1047 (setq saved-@-pos (list (point)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1048 (setq @-pos saved-@-pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1049 (goto-char >-pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1050 (mail-extr-delete-char -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1051 (mail-extr-nuke-char-at route-addr-colon-pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1052 (mail-extr-demarkerize route-addr-colon-pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1053 (setq route-addr-colon-pos nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1054 >-pos (mail-extr-demarkerize >-pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1055 %-pos (mapcar 'mail-extr-demarkerize %-pos))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1056
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1057 ;; de-listify @-pos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1058 (setq @-pos (car @-pos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1059
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1060 ;; TODO: remove comments in the middle of an address
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1061
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1062 (set-buffer canonicalization-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1063 (fundamental-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1064 (kill-all-local-variables)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1065 (buffer-disable-undo canonicalization-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1066 (set-syntax-table mail-extr-address-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1067 (setq case-fold-search nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1068
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1069 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1070 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1071 (insert-buffer-substring extraction-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1072
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1073 (if <-pos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1074 (narrow-to-region (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1075 (goto-char (1+ <-pos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1076 (mail-extr-skip-whitespace-forward)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1077 (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1078 >-pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1079 (if (and first-real-pos last-real-pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1080 (narrow-to-region first-real-pos last-real-pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1081 ;; ****** Oh no! What if the address is completely empty!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1082 ;; *** Is this correct?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1083 (narrow-to-region (point-max) (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1084 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1085
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1086 (and @-pos %-pos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1087 (mail-extr-nuke-outside-range %-pos (point-min) @-pos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1088 (and %-pos !-pos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1089 (mail-extr-nuke-outside-range !-pos (point-min) (car %-pos)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1090 (and @-pos !-pos (not %-pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1091 (mail-extr-nuke-outside-range !-pos (point-min) @-pos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1092
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1093 ;; Error condition:?? (and %-pos (not @-pos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1094
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1095 ;; WARNING: THIS CODE IS DUPLICATED BELOW.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1096 (cond ((and %-pos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1097 (not @-pos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1098 (goto-char (car %-pos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1099 (mail-extr-delete-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1100 (setq @-pos (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1101 (insert "@")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1102 (setq %-pos (cdr %-pos))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1103
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1104 (if mail-extr-mangle-uucp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1105 (cond (!-pos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1106 ;; **** I don't understand this save-restriction and the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1107 ;; narrow-to-region inside it. Why did I do that?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1108 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1109 (cond ((and @-pos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1110 mail-extr-@-binds-tighter-than-!)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1111 (goto-char @-pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1112 (setq %-pos (cons (point) %-pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1113 @-pos nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1114 (mail-extr-delete-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1115 (insert "%")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1116 (setq insert-point (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1117 (mail-extr-@-binds-tighter-than-!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1118 (setq insert-point (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1119 (%-pos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1120 (setq insert-point (mail-extr-last %-pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1121 saved-%-pos (mapcar 'mail-extr-markerize %-pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1122 %-pos nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1123 @-pos (mail-extr-markerize @-pos)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1124 (@-pos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1125 (setq insert-point @-pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1126 (setq @-pos (mail-extr-markerize @-pos)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1127 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1128 (setq insert-point (point-max))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1129 (narrow-to-region (point-min) insert-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1130 (setq saved-!-pos (car !-pos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1131 (while !-pos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1132 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1133 (cond ((and (not @-pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1134 (not (cdr !-pos)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1135 (setq @-pos (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1136 (insert-before-markers "@ "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1137 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1138 (setq %-pos (cons (point) %-pos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1139 (insert-before-markers "% ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1140 (backward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1141 (insert-buffer-substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1142 (current-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1143 (if (nth 1 !-pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1144 (1+ (nth 1 !-pos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1145 (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1146 (car !-pos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1147 (mail-extr-delete-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1148 (or (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1149 (mail-extr-safe-move-sexp -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1150 (mail-extr-skip-whitespace-backward)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1151 (eq ?. (preceding-char)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1152 (insert-before-markers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1153 (if (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1154 (mail-extr-skip-whitespace-backward)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1155 (eq ?. (preceding-char)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1156 ""
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1157 ".")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1158 "uucp"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1159 (setq !-pos (cdr !-pos))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1160 (and saved-%-pos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1161 (setq %-pos (append (mapcar 'mail-extr-demarkerize
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1162 saved-%-pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1163 %-pos)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1164 (setq @-pos (mail-extr-demarkerize @-pos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1165 (narrow-to-region (1+ saved-!-pos) (point-max)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1166
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1167 ;; WARNING: THIS CODE IS DUPLICATED ABOVE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1168 (cond ((and %-pos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1169 (not @-pos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1170 (goto-char (car %-pos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1171 (mail-extr-delete-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1172 (setq @-pos (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1173 (insert "@")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1174 (setq %-pos (cdr %-pos))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1175
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1176 (setq %-pos (nreverse %-pos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1177 ;; RFC 1034 doesn't approve of this, oh well:
6
27bc7f280385 Import from CVS: tag r19-15b4
cvs
parents: 2
diff changeset
1178 ;; Neither do we, sb/lmi
27bc7f280385 Import from CVS: tag r19-15b4
cvs
parents: 2
diff changeset
1179 ;; (downcase-region (or (car %-pos) @-pos (point-max)) (point-max))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1180 (cond (%-pos ; implies @-pos valid
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1181 (setq temp %-pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1182 (catch 'truncated
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1183 (while temp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1184 (goto-char (or (nth 1 temp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1185 @-pos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1186 (mail-extr-skip-whitespace-backward)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1187 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1188 (mail-extr-safe-move-sexp -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1189 (setq domain-pos (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1190 (mail-extr-skip-whitespace-backward)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1191 (setq \.-pos (eq ?. (preceding-char))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1192 (cond ((and \.-pos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1193 ;; #### string consing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1194 (let ((s (intern-soft
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1195 (buffer-substring domain-pos (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1196 all-top-level-domains)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1197 (and s (get s 'domain-name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1198 (narrow-to-region (point-min) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1199 (goto-char (car temp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1200 (mail-extr-delete-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1201 (setq @-pos (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1202 (setcdr temp nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1203 (setq %-pos (delq @-pos %-pos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1204 (insert "@")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1205 (throw 'truncated t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1206 (setq temp (cdr temp))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1207 (setq mbox-beg (point-min)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1208 mbox-end (if %-pos (car %-pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1209 (or @-pos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1210 (point-max))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1211
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1212 ;; Done canonicalizing address.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1213
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1214 (set-buffer extraction-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1215
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1216 ;; Decide what part of the address to search to find the full name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1217 (cond (
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1218 ;; Example: "First M. Last" <fml@foo.bar.dom>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1219 (and phrase-beg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1220 (eq quote-beg phrase-beg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1221 (<= quote-end phrase-end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1222 (narrow-to-region (1+ quote-beg) (1- quote-end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1223 (mail-extr-undo-backslash-quoting (point-min) (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1224
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1225 ;; Example: First Last <fml@foo.bar.dom>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1226 (phrase-beg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1227 (narrow-to-region phrase-beg phrase-end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1228
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1229 ;; Example: fml@foo.bar.dom (First M. Last)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1230 (cbeg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1231 (narrow-to-region (1+ cbeg) (1- cend))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1232 (mail-extr-undo-backslash-quoting (point-min) (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1233
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1234 ;; Deal with spacing problems
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1235 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1236 ; (cond ((not (search-forward " " nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1237 ; (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1238 ; (cond ((search-forward "_" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1239 ; ;; Handle the *idiotic* use of underlines as spaces.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1240 ; ;; Example: fml@foo.bar.dom (First_M._Last)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1241 ; (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1242 ; (while (search-forward "_" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1243 ; (replace-match " " t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1244 ; ((search-forward "." nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1245 ; ;; Fix . used as space
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1246 ; ;; Example: danj1@cb.att.com (daniel.jacobson)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1247 ; (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1248 ; (while (re-search-forward mail-extr-bad-dot-pattern nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1249 ; (replace-match "\\1 \\2" t))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1250 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1251
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1252 ;; Otherwise we try to get the name from the mailbox portion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1253 ;; of the address.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1254 ;; Example: First_M_Last@foo.bar.dom
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1255 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1256 ;; *** Work in canon buffer instead? No, can't. Hmm.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1257 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1258 (narrow-to-region (point) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1259 (insert-buffer-substring canonicalization-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1260 mbox-beg mbox-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1261 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1262
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1263 ;; Example: First_Last.XXX@foo.bar.dom
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1264 (setq \.-ends-name (re-search-forward "[_0-9]" nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1265
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1266 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1267
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1268 (if (not mail-extr-mangle-uucp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1269 (modify-syntax-entry ?! "w" (syntax-table)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1270
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1271 (while (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1272 (mail-extr-skip-whitespace-forward)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1273 (not (eobp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1274 (setq char (char-after (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1275 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1276 ((eq char ?\")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1277 (setq quote-beg (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1278 (or (mail-extr-safe-move-sexp 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1279 ;; TODO: handle this error condition!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1280 (forward-char 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1281 ;; take into account deletions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1282 (setq quote-end (- (point) 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1283 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1284 (backward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1285 (mail-extr-delete-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1286 (goto-char quote-beg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1287 (mail-extr-delete-char 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1288 (mail-extr-undo-backslash-quoting quote-beg quote-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1289 (or (eq ?\ (char-after (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1290 (insert " "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1291 ;; (setq mailbox-name-processed-flag t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1292 (setq \.-ends-name t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1293 ((eq char ?.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1294 (if (memq (char-after (1+ (point))) '(?_ ?=))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1295 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1296 (forward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1297 (mail-extr-delete-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1298 (insert ?\ ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1299 (if \.-ends-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1300 (narrow-to-region (point-min) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1301 (mail-extr-delete-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1302 (insert " ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1303 ;; (setq mailbox-name-processed-flag t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1304 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1305 ((memq (char-syntax char) '(?. ?\\))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1306 (mail-extr-delete-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1307 (insert " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1308 ;; (setq mailbox-name-processed-flag t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1309 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1310 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1311 (setq atom-beg (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1312 (forward-word 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1313 (setq atom-end (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1314 (goto-char atom-beg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1315 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1316 (narrow-to-region atom-beg atom-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1317 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1318
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1319 ;; Handle X.400 addresses encoded in RFC-822.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1320 ;; *** Shit! This has to handle the case where it is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1321 ;; *** embedded in a quote too!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1322 ;; *** Shit! The input is being broken up into atoms
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1323 ;; *** by periods!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1324 ((looking-at mail-extr-x400-encoded-address-pattern)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1325
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1326 ;; Copy the contents of the individual fields that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1327 ;; might hold name data to the beginning.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1328 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1329 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1330 (lambda (field-pattern)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1331 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1332 ((save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1333 (re-search-forward field-pattern nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1334 (insert-buffer-substring (current-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1335 (match-beginning 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1336 (match-end 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1337 (insert " ")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1338 (list mail-extr-x400-encoded-address-given-name-pattern
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1339 mail-extr-x400-encoded-address-surname-pattern
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1340 mail-extr-x400-encoded-address-full-name-pattern))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1341
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1342 ;; Discard the rest, since it contains stuff like
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1343 ;; routing information, not part of a name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1344 (mail-extr-skip-whitespace-backward)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1345 (delete-region (point) (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1346
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1347 ;; Handle periods used for spacing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1348 (while (re-search-forward mail-extr-bad-dot-pattern nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1349 (replace-match "\\1 \\2" t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1350
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1351 ;; (setq mailbox-name-processed-flag t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1352 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1353
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1354 ;; Handle normal addresses.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1355 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1356 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1357 ;; Handle _ and = used for spacing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1358 (while (re-search-forward "\\([^_=]+\\)[_=]" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1359 (replace-match "\\1 " t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1360 ;; (setq mailbox-name-processed-flag t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1361 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1362 (goto-char (point-max))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1363
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1364 ;; undo the dirty deed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1365 (if (not mail-extr-mangle-uucp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1366 (modify-syntax-entry ?! "." (syntax-table)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1367 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1368 ;; If we derived the name from the mailbox part of the address,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1369 ;; and we only got one word out of it, don't treat that as a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1370 ;; name. "foo@bar" --> (nil "foo@bar"), not ("foo" "foo@bar")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1371 ;; (if (not mailbox-name-processed-flag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1372 ;; (delete-region (point-min) (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1373 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1374
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1375 (set-syntax-table mail-extr-address-text-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1376
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1377 (mail-extr-voodoo mbox-beg mbox-end canonicalization-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1378 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1379
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1380 ;; If name is "First Last" and userid is "F?L", then assume
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1381 ;; the middle initial is the second letter in the userid.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1382 ;; Initial code by Jamie Zawinski <jwz@netscape.com>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1383 ;; *** Make it work when there's a suffix as well.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1384 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1385 (cond ((and mail-extr-guess-middle-initial
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1386 (not disable-initial-guessing-flag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1387 (eq 3 (- mbox-end mbox-beg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1388 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1389 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1390 (looking-at mail-extr-two-name-pattern)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1391 (setq fi (char-after (match-beginning 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1392 li (char-after (match-beginning 3)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1393 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1394 (set-buffer canonicalization-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1395 ;; char-equal is ignoring case here, so no need to upcase
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1396 ;; or downcase.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1397 (let ((case-fold-search t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1398 (and (char-equal fi (char-after mbox-beg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1399 (char-equal li (char-after (1- mbox-end)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1400 (setq mi (char-after (1+ mbox-beg))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1401 (cond ((and mi
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1402 ;; TODO: use better table than syntax table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1403 (eq ?w (char-syntax mi)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1404 (goto-char (match-beginning 3))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1405 (insert (upcase mi) ". ")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1406
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1407 ;; Nuke name if it is the same as mailbox name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1408 (let ((buffer-length (- (point-max) (point-min)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1409 (i 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1410 (names-match-flag t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1411 (cond ((and (> buffer-length 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1412 (eq buffer-length (- mbox-end mbox-beg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1413 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1414 (insert-buffer-substring canonicalization-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1415 mbox-beg mbox-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1416 (while (and names-match-flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1417 (< i buffer-length))
38
1a767b41a199 Import from CVS: tag r19-15b102
cvs
parents: 30
diff changeset
1418 (or (eq (let ((c (char-after (+ i (point-min)))))
1a767b41a199 Import from CVS: tag r19-15b102
cvs
parents: 30
diff changeset
1419 (if mail-extr-mailbox-match-case-fold
1a767b41a199 Import from CVS: tag r19-15b102
cvs
parents: 30
diff changeset
1420 (downcase c)
1a767b41a199 Import from CVS: tag r19-15b102
cvs
parents: 30
diff changeset
1421 c))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1422 (downcase
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1423 (char-after (+ i buffer-length (point-min)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1424 (setq names-match-flag nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1425 (setq i (1+ i)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1426 (delete-region (+ (point-min) buffer-length) (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1427 (if names-match-flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1428 (narrow-to-region (point) (point))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1429
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1430 ;; Nuke name if it's just one word.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1431 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1432 (and mail-extr-ignore-single-names
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1433 (not (re-search-forward "[- ]" nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1434 (narrow-to-region (point) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1435
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1436 ;; Result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1437 (list (if (not (= (point-min) (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1438 (buffer-string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1439 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1440 (set-buffer canonicalization-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1441 (if (not (= (point-min) (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1442 (buffer-string))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1443 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1444
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1445 (defun mail-extr-voodoo (mbox-beg mbox-end canonicalization-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1446 (let ((word-count 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1447 (case-fold-search nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1448 mixed-case-flag lower-case-flag ;;upper-case-flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1449 suffix-flag last-name-comma-flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1450 ;;cbeg cend
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1451 initial
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1452 begin-again-flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1453 drop-this-word-if-trailing-flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1454 drop-last-word-if-trailing-flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1455 word-found-flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1456 this-word-beg last-word-beg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1457 name-beg name-end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1458 name-done-flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1459 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1460 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1461 (set-syntax-table mail-extr-address-text-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1462
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1463 ;; This was moved above.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1464 ;; Fix . used as space
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1465 ;; But it belongs here because it occurs not only as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1466 ;; rypens@reks.uia.ac.be (Piet.Rypens)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1467 ;; but also as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1468 ;; "Piet.Rypens" <rypens@reks.uia.ac.be>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1469 ;;(goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1470 ;;(while (re-search-forward mail-extr-bad-dot-pattern nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1471 ;; (replace-match "\\1 \\2" t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1472
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1473 (cond ((not (search-forward " " nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1474 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1475 (cond ((search-forward "_" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1476 ;; Handle the *idiotic* use of underlines as spaces.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1477 ;; Example: fml@foo.bar.dom (First_M._Last)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1478 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1479 (while (search-forward "_" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1480 (replace-match " " t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1481 ((search-forward "." nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1482 ;; Fix . used as space
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1483 ;; Example: danj1@cb.att.com (daniel.jacobson)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1484 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1485 (while (re-search-forward mail-extr-bad-dot-pattern nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1486 (replace-match "\\1 \\2" t))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1487
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1488
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1489 ;; Loop over the words (and other junk) in the name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1490 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1491 (while (not name-done-flag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1492
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1493 (cond (word-found-flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1494 ;; Last time through this loop we skipped over a word.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1495 (setq last-word-beg this-word-beg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1496 (setq drop-last-word-if-trailing-flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1497 drop-this-word-if-trailing-flag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1498 (setq word-found-flag nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1499
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1500 (cond (begin-again-flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1501 ;; Last time through the loop we found something that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1502 ;; indicates we should pretend we are beginning again from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1503 ;; the start.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1504 (setq word-count 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1505 (setq last-word-beg nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1506 (setq drop-last-word-if-trailing-flag nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1507 (setq mixed-case-flag nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1508 (setq lower-case-flag nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1509 ;; (setq upper-case-flag nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1510 (setq begin-again-flag nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1511 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1512
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1513 ;; Initialize for this iteration of the loop.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1514 (mail-extr-skip-whitespace-forward)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1515 (if (eq word-count 0) (narrow-to-region (point) (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1516 (setq this-word-beg (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1517 (setq drop-this-word-if-trailing-flag nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1518
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1519 ;; Decide what to do based on what we are looking at.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1520 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1521
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1522 ;; Delete title
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1523 ((and (eq word-count 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1524 (looking-at mail-extr-full-name-prefixes))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1525 (goto-char (match-end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1526 (narrow-to-region (point) (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1527
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1528 ;; Stop after name suffix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1529 ((and (>= word-count 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1530 (looking-at mail-extr-full-name-suffix-pattern))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1531 (mail-extr-skip-whitespace-backward)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1532 (setq suffix-flag (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1533 (if (eq ?, (following-char))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1534 (forward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1535 (insert ?,))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1536 ;; Enforce at least one space after comma
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1537 (or (eq ?\ (following-char))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1538 (insert ?\ ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1539 (mail-extr-skip-whitespace-forward)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1540 (cond ((memq (following-char) '(?j ?J ?s ?S))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1541 (capitalize-word 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1542 (if (eq (following-char) ?.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1543 (forward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1544 (insert ?.)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1545 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1546 (upcase-word 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1547 (setq word-found-flag t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1548 (setq name-done-flag t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1549
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1550 ;; Handle SCA names
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1551 ((looking-at "MKA \\(.+\\)") ; "Mundanely Known As"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1552 (goto-char (match-beginning 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1553 (narrow-to-region (point) (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1554 (setq begin-again-flag t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1555
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1556 ;; Check for initial last name followed by comma
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1557 ((and (eq ?, (following-char))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1558 (eq word-count 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1559 (forward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1560 (setq last-name-comma-flag t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1561 (or (eq ?\ (following-char))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1562 (insert ?\ )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1563
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1564 ;; Stop before trailing comma-separated comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1565 ;; THIS CASE MUST BE AFTER THE PRECEDING CASES.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1566 ;; *** This case is redundant???
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1567 ;;((eq ?, (following-char))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1568 ;; (setq name-done-flag t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1569
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1570 ;; Delete parenthesized/quoted comment/nickname
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1571 ((memq (following-char) '(?\( ?\{ ?\[ ?\" ?\' ?\`))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1572 (setq cbeg (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1573 (set-syntax-table mail-extr-address-text-comment-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1574 (cond ((memq (following-char) '(?\' ?\`))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1575 (or (search-forward "'" nil t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1576 (if (eq ?\' (following-char)) 2 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1577 (mail-extr-delete-char 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1578 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1579 (or (mail-extr-safe-move-sexp 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1580 (goto-char (point-max)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1581 (set-syntax-table mail-extr-address-text-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1582 (setq cend (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1583 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1584 ;; Handle case of entire name being quoted
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1585 ((and (eq word-count 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1586 (looking-at " *\\'")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1587 (>= (- cend cbeg) 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1588 (narrow-to-region (1+ cbeg) (1- cend))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1589 (goto-char (point-min)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1590 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1591 ;; Handle case of quoted initial
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1592 (if (and (or (= 3 (- cend cbeg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1593 (and (= 4 (- cend cbeg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1594 (eq ?. (char-after (+ 2 cbeg)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1595 (not (looking-at " *\\'")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1596 (setq initial (char-after (1+ cbeg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1597 (setq initial nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1598 (delete-region cbeg cend)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1599 (if initial
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1600 (insert initial ". ")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1601
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1602 ;; Handle & substitution
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1603 ((and (or (bobp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1604 (eq ?\ (preceding-char)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1605 (looking-at "&\\( \\|\\'\\)"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1606 (mail-extr-delete-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1607 (capitalize-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1608 (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1609 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1610 (insert-buffer-substring canonicalization-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1611 mbox-beg mbox-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1612 (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1613 (setq disable-initial-guessing-flag t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1614 (setq word-found-flag t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1615
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1616 ;; Handle *Stupid* VMS date stamps
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1617 ((looking-at mail-extr-stupid-vms-date-stamp-pattern)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1618 (replace-match "" t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1619
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1620 ;; Handle Chinese characters.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1621 ((looking-at mail-extr-hz-embedded-gb-encoded-chinese-pattern)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1622 (goto-char (match-end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1623 (setq word-found-flag t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1624
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1625 ;; Skip initial garbage characters.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1626 ;; THIS CASE MUST BE AFTER THE PRECEDING CASES.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1627 ((and (eq word-count 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1628 (looking-at mail-extr-leading-garbage))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1629 (goto-char (match-end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1630 ;; *** Skip backward over these???
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1631 ;; (skip-chars-backward "& \"")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1632 (narrow-to-region (point) (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1633
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1634 ;; Various stopping points
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1635 ((or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1636
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1637 ;; Stop before ALL CAPS acronyms, if preceded by mixed-case
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1638 ;; words. Example: XT-DEM.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1639 (and (>= word-count 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1640 mixed-case-flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1641 (looking-at mail-extr-weird-acronym-pattern)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1642 (not (looking-at mail-extr-roman-numeral-pattern)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1643
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1644 ;; Stop before trailing alternative address
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1645 (looking-at mail-extr-alternative-address-pattern)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1646
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1647 ;; Stop before trailing comment not introduced by comma
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1648 ;; THIS CASE MUST BE AFTER AN EARLIER CASE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1649 (looking-at mail-extr-trailing-comment-start-pattern)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1650
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1651 ;; Stop before telephone numbers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1652 (looking-at mail-extr-telephone-extension-pattern))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1653 (setq name-done-flag t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1654
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1655 ;; Delete ham radio call signs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1656 ((looking-at mail-extr-ham-call-sign-pattern)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1657 (delete-region (match-beginning 0) (match-end 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1658
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1659 ;; Fixup initials
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1660 ((looking-at mail-extr-initial-pattern)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1661 (or (eq (following-char) (upcase (following-char)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1662 (setq lower-case-flag t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1663 (forward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1664 (if (eq ?. (following-char))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1665 (forward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1666 (insert ?.))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1667 (or (eq ?\ (following-char))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1668 (insert ?\ ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1669 (setq word-found-flag t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1670
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1671 ;; Handle BITNET LISTSERV list names.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1672 ((and (eq word-count 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1673 (looking-at mail-extr-listserv-list-name-pattern))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1674 (narrow-to-region (match-beginning 1) (match-end 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1675 (setq word-found-flag t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1676 (setq name-done-flag t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1677
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1678 ;; Regular name words
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1679 ((looking-at mail-extr-name-pattern)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1680 (setq name-beg (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1681 (setq name-end (match-end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1682
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1683 ;; Certain words will be dropped if they are at the end.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1684 (and (>= word-count 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1685 (not lower-case-flag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1686 (or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1687 ;; A trailing 4-or-more letter lowercase words preceded by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1688 ;; mixed case or uppercase words will be dropped.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1689 (looking-at "[a-z][a-z][a-z][a-z]+[ \t]*\\'")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1690 ;; Drop a trailing word which is terminated with a period.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1691 (eq ?. (char-after (1- name-end))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1692 (setq drop-this-word-if-trailing-flag t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1693
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1694 ;; Set the flags that indicate whether we have seen a lowercase
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1695 ;; word, a mixed case word, and an uppercase word.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1696 (if (re-search-forward "[a-z]" name-end t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1697 (if (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1698 (goto-char name-beg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1699 (re-search-forward "[A-Z]" name-end t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1700 (setq mixed-case-flag t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1701 (setq lower-case-flag t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1702 ;; (setq upper-case-flag t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1703 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1704
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1705 (goto-char name-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1706 (setq word-found-flag t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1707
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1708 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1709 (setq name-done-flag t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1710 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1711
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1712 ;; Count any word that we skipped over.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1713 (if word-found-flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1714 (setq word-count (1+ word-count))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1715
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1716 ;; If the last thing in the name is 2 or more periods, or one or more
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1717 ;; other sentence terminators (but not a single period) then keep them
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 28
diff changeset
1718 ;; and the preceding word. This is for the benefit of whole sentences
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1719 ;; in the name field: it's better behavior than dropping the last word
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1720 ;; of the sentence...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1721 (if (and (not suffix-flag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1722 (looking-at "\\(\\.+\\|[?!;:.][?!;:.]+\\|[?!;:][?!;:.]*\\)\\'"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1723 (goto-char (setq suffix-flag (point-max))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1724
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1725 ;; Drop everything after point and certain trailing words.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1726 (narrow-to-region (point-min)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1727 (or (and drop-last-word-if-trailing-flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1728 last-word-beg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1729 (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1730
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1731 ;; Xerox's mailers SUCK!!!!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1732 ;; We simply refuse to believe that any last name is PARC or ADOC.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1733 ;; If it looks like that is the last name, that there is no meaningful
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1734 ;; here at all. Actually I guess it would be best to map patterns
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1735 ;; like foo.hoser@xerox.com into foo@hoser.xerox.com, but I don't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1736 ;; actually know that that is what's going on.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1737 (cond ((not suffix-flag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1738 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1739 (let ((case-fold-search t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1740 (if (looking-at "[-A-Za-z_]+[. ]\\(PARC\\|ADOC\\)\\'")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1741 (erase-buffer)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1742
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1743 ;; If last name first put it at end (but before suffix)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1744 (cond (last-name-comma-flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1745 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1746 (search-forward ",")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1747 (setq name-end (1- (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1748 (goto-char (or suffix-flag (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1749 (or (eq ?\ (preceding-char))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1750 (insert ?\ ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1751 (insert-buffer-substring (current-buffer) (point-min) name-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1752 (goto-char name-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1753 (skip-chars-forward "\t ,")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1754 (narrow-to-region (point) (point-max))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1755
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1756 ;; Delete leading and trailing junk characters.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1757 ;; *** This is probably completly unneeded now.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1758 ;;(goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1759 ;;(skip-chars-backward mail-extr-non-end-name-chars)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1760 ;;(if (eq ?. (following-char))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1761 ;; (forward-char 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1762 ;;(narrow-to-region (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1763 ;; (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1764 ;; (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1765 ;; (skip-chars-forward mail-extr-non-begin-name-chars)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1766 ;; (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1767
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1768 ;; Compress whitespace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1769 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1770 (while (re-search-forward "[ \t\n]+" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1771 (replace-match (if (eobp) "" " ") t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1772 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1773
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1774
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1775
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1776 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1777 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1778 ;; Table of top-level domain names.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1779 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1780 ;; This is used during address canonicalization; be careful of format changes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1781 ;; Keep in mind that the country abbreviations follow ISO-3166. There is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1782 ;; a U.S. FIPS that specifies a different set of two-letter country
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1783 ;; abbreviations.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1784
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1785 (defconst all-top-level-domains
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1786 (let ((ob (make-vector 509 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1787 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1788 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1789 (lambda (x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1790 (put (intern (downcase (car x)) ob)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1791 'domain-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1792 (if (nth 2 x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1793 (format (nth 2 x) (nth 1 x))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1794 (nth 1 x)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1795 '(("ag" "Antigua")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1796 ("ar" "Argentina" "Argentine Republic")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1797 ("arpa" t "Advanced Projects Research Agency")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1798 ("at" "Austria" "The Republic of %s")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1799 ("au" "Australia")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1800 ("bb" "Barbados")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1801 ("be" "Belgium" "The Kingdom of %s")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1802 ("bg" "Bulgaria")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1803 ("bitnet" t "Because It's Time NET")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1804 ("bo" "Bolivia" "Republic of %s")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1805 ("br" "Brazil" "The Federative Republic of %s")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1806 ("bs" "Bahamas")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1807 ("bz" "Belize")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1808 ("ca" "Canada")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1809 ("ch" "Switzerland" "The Swiss Confederation")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1810 ("cl" "Chile" "The Republic of %s")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1811 ("cn" "China" "The People's Republic of %s")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1812 ("co" "Columbia")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1813 ("com" t "Commercial")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1814 ("cr" "Costa Rica" "The Republic of %s")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1815 ("cs" "Czechoslovakia")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1816 ("de" "Germany")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1817 ("dk" "Denmark")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1818 ("dm" "Dominica")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1819 ("do" "Dominican Republic" "The %s")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1820 ("ec" "Ecuador" "The Republic of %s")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1821 ("edu" t "Educational")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1822 ("eg" "Egypt" "The Arab Republic of %s")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1823 ("es" "Spain" "The Kingdom of %s")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1824 ("fi" "Finland" "The Republic of %s")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1825 ("fj" "Fiji")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1826 ("fr" "France")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1827 ("gov" t "Government (U.S.A.)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1828 ("gr" "Greece" "The Hellenic Republic (%s)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1829 ("hk" "Hong Kong")
28
1917ad0d78d7 Import from CVS: tag r19-15b97
cvs
parents: 16
diff changeset
1830 ("hr" "Croatia" "The Republic of %s")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1831 ("hu" "Hungary" "The Hungarian People's Republic") ;???
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1832 ("ie" "Ireland")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1833 ("il" "Israel" "The State of %s")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1834 ("in" "India" "The Republic of %s")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1835 ("int" t "(something British, don't know what)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1836 ("is" "Iceland" "The Republic of %s")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1837 ("it" "Italy" "The Italian Republic")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1838 ("jm" "Jamaica")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1839 ("jp" "Japan")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1840 ("kn" "St. Kitts and Nevis")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1841 ("kr" "South Korea")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1842 ("lc" "St. Lucia")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1843 ("lk" "Sri Lanka" "The Democratic Socialist Republic of %s")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1844 ("mil" t "Military (U.S.A.)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1845 ("mx" "Mexico" "The United Mexican States")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1846 ("my" "Malaysia" "%s (changed to Myanmar?)") ;???
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1847 ("na" "Namibia")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1848 ("nato" t "North Atlantic Treaty Organization")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1849 ("net" t "Network")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1850 ("ni" "Nicaragua" "The Republic of %s")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1851 ("nl" "Netherlands" "The Kingdom of the %s")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1852 ("no" "Norway" "The Kingdom of %s")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1853 ("nz" "New Zealand")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1854 ("org" t "Organization")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1855 ("pe" "Peru")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1856 ("pg" "Papua New Guinea")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1857 ("ph" "Philippines" "The Republic of the %s")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1858 ("pl" "Poland")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1859 ("pr" "Puerto Rico")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1860 ("pt" "Portugal" "The Portugese Republic")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1861 ("py" "Paraguay")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1862 ("se" "Sweden" "The Kingdom of %s")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1863 ("sg" "Singapore" "The Republic of %s")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1864 ("sr" "Suriname")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1865 ("su" "Soviet Union")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1866 ("th" "Thailand" "The Kingdom of %s")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1867 ("tn" "Tunisia")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1868 ("tr" "Turkey" "The Republic of %s")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1869 ("tt" "Trinidad and Tobago")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1870 ("tw" "Taiwan")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1871 ("uk" "United Kingdom" "The %s of Great Britain")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1872 ("unter-dom" t "(something German)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1873 ("us" "U.S.A." "The United States of America")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1874 ("uucp" t "Unix to Unix CoPy")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1875 ("uy" "Uruguay" "The Eastern Republic of %s")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1876 ("vc" "St. Vincent and the Grenadines")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1877 ("ve" "Venezuela" "The Republic of %s")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1878 ("yu" "Yugoslavia" "The Socialist Federal Republic of %s")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1879 ;; Also said to be Zambia ... (why not Zaire???)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1880 ("za" "South Africa" "The Republic of %s (or Zambia? Zaire?)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1881 ("zw" "Zimbabwe" "Republic of %s")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1882 ;; fipnet
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1883 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1884 ob))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1885
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1886 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1887 (defun what-domain (x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1888 "Prompts for a mail domain, and prints the country it corresponds to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1889 in the minibuffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1890 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1891 (let ((completion-ignore-case t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1892 (list (completing-read "Domain: " all-top-level-domains nil t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1893 (or (setq x (intern-soft (downcase x) all-top-level-domains))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1894 (error "no such domain"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1895 (message "%s: %s" (upcase (symbol-name x)) (get x 'domain-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1896
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1897
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1898 ;(let ((all nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1899 ; (mapatoms #'(lambda (x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1900 ; (if (and (boundp x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1901 ; (string-match "^mail-extr-" (symbol-name x)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1902 ; (setq all (cons x all)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1903 ; (setq all (sort all #'string-lessp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1904 ; (cons 'setq
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1905 ; (apply 'nconc (mapcar #'(lambda (x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1906 ; (list x (symbol-value x)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1907 ; all))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1908
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1909
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1910 (provide 'mail-extr)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1911
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1912 ;;; mail-extr.el ends here