annotate lisp/utils/mail-extr.el @ 104:cf808b4c4290 r20-1b4

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