annotate lisp/utils/mail-extr.el @ 0:376386a54a3c r19-14

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