Mercurial > emacs
annotate lisp/mail/uce.el @ 22423:76aa8f3934bf
(c-mode-menu): Use (mark t), not (mark), in enable-expressions.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Wed, 10 Jun 1998 18:54:27 +0000 |
parents | a517da228cb9 |
children | 198054d3498c |
rev | line source |
---|---|
17450 | 1 ;;; uce.el --- facilitate reply to unsolicited commercial email |
2 | |
22416
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
3 ;; Copyright (C) 1996, 1998 Free Software Foundation, Inc. |
17450 | 4 |
22416
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
5 ;; Author: stanislav shalunov <shalunov@mccme.ru> |
17450 | 6 ;; Created: 10 Dec 1996 |
7 ;; Keywords: uce, unsolicited commercial email | |
8 | |
9 ;; This file is part of GNU Emacs. | |
10 | |
11 ;; This program is free software; you can redistribute it and/or | |
12 ;; modify it under the terms of the GNU General Public License as | |
13 ;; published by the Free Software Foundation; either version 2, or (at | |
14 ;; your option) any later version. | |
15 | |
16 ;; This program is distributed in the hope that it will be useful, but | |
17 ;; without any warranty; without even the implied warranty of | |
18 ;; merchantability or fitness for a particular purpose. See the GNU | |
19 ;; General Public License for more details. | |
20 | |
21 ;; You should have received a copy of the GNU General Public License | |
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
24 ;; Boston, MA 02111-1307, USA. | |
25 | |
26 ;;; Commentary: | |
27 | |
28 ;; Code in this file provides semi-automatic means of replying to | |
22416
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
29 ;; UCE's you might get. It works currently only with Rmail and Gnus. |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
30 ;; If you would like to make it work with other mail readers, |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
31 ;; Rmail-specific section is marked below. If you want to play with |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
32 ;; code, please let me know about your changes so I can incorporate |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
33 ;; them. I'd appreciate it. |
17450 | 34 |
35 ;; Function uce-reply-to-uce, if called when current message in RMAIL | |
36 ;; buffer is a UCE, will setup *mail* buffer in the following way: it | |
37 ;; scans full headers of message for 1) normal return address of | |
38 ;; sender (From, Reply-To lines); and puts these addresses into To: | |
39 ;; header, it also puts abuse@offenders.host address there 2) mailhub | |
40 ;; that first saw this message; and puts address of its postmaster | |
41 ;; into To: header 3) finally, it looks at Message-Id and adds | |
42 ;; posmaster of that host to the list of addresses. | |
43 | |
44 ;; Then, we add "Errors-To: nobody@localhost" header, so that if some | |
45 ;; of these addresses are not actually correct, we will never see | |
46 ;; bounced mail. Also, mail-self-blind and mail-archive-file-name | |
47 ;; take no effect: the ideology is that we don't want to save junk or | |
48 ;; replies to junk. | |
49 | |
50 ;; Then we put template into buffer (customizable message that | |
51 ;; explains what has happened), customizable signature, and the | |
52 ;; original message with full headers and envelope for postmasters. | |
53 ;; Then buffer is left for editing. | |
54 | |
55 ;; The reason that function uce-reply-to-uce is Rmail dependant is | |
56 ;; that we want full headers of the original message, nothing | |
57 ;; stripped. If we use normal means of inserting of the original | |
58 ;; message into *mail* buffer headers like Received: (not really | |
59 ;; headers, but envelope lines) will be stripped while they bear | |
60 ;; valuable for us and postmasters information. I do wish that there | |
61 ;; would be some way to write this function in some portable way, but | |
62 ;; I am not aware of any. | |
63 | |
64 ;;; Change log: | |
65 | |
66 ;; Dec 10, 1996 -- posted draft version to gnu.sources.emacs | |
67 | |
68 ;; Dec 11, 1996 -- fixed some typos, and Francesco Potorti` | |
69 ;; <F.Potorti@cnuce.cnr.it> pointed out that my use of defvar was | |
70 ;; weird, suggested fix, and added let form. | |
71 | |
72 ;; Dec 17, 1996 -- made scanning for host names little bit more clever | |
73 ;; (obviously bogus stuff like localhost is now ignored). | |
74 | |
22416
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
75 ;; Nov 11, 1997 -- incorporated changes from Mikael Djurfeldt |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
76 ;; <mdj@nada.kth.se> to make uce.el work with Gnus. Changed the text |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
77 ;; of message that is sent. |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
78 |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
79 ;; Dec 3, 1997 -- changes from Gareth Jones <gdj1@gdjones.demon.co.uk> |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
80 ;; handling Received headers following some line like `From:'. |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
81 |
17450 | 82 ;;; Setup: |
83 | |
84 ;; put in your ~./emacs the following line: | |
85 | |
86 ;; (autoload 'uce-reply-to-uce "uce" "Reply to UCEs" t nil) | |
87 | |
22416
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
88 ;; If you want to use it with Gnus also use |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
89 |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
90 ;; (setq uce-mail-reader 'gnus) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
91 |
17450 | 92 ;; store this file (uce.el) somewhere in load-path and byte-compile it. |
93 | |
94 ;;; Variables: | |
95 | |
96 ;; uce-message-text is template that will be inserted into buffer. It | |
97 ;; has reasonable default. If you want to write some scarier one, | |
98 ;; please do so and send it to me. Please keep it polite. | |
99 | |
100 ;; uce-signature behaves just like mail-signature. If nil, nothing is | |
101 ;; inserted, if t, file ~/.signature is used, if a string, its | |
102 ;; contents are inserted into buffer. | |
103 | |
104 ;; uce-uce-separator is line that separates your message from the UCE | |
105 ;; that you enclose. | |
106 | |
107 ;; uce-subject-line will be used as subject of outgoing message. If | |
108 ;; nil, left blank. | |
109 | |
110 ;;; Code: | |
111 | |
112 (require 'sendmail) | |
22416
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
113 ;; Those sections of code which are dependent upon |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
114 ;; RMAIL are only evaluated if we have received a message with RMAIL... |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
115 ;;(require 'rmail) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
116 |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
117 (defvar uce-mail-reader 'rmail |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
118 "A symbol indicating which mail reader you are using. |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
119 Choose from: gnus, rmail.") |
17450 | 120 |
20962 | 121 (defgroup uce nil |
122 "Facilitate reply to unsolicited commercial email." | |
123 :prefix "uce-" | |
124 :group 'mail) | |
125 | |
126 (defcustom uce-setup-hook nil | |
17450 | 127 "Hook to run after UCE rant message is composed. |
20962 | 128 This hook is run after mail-setup-hook, which is run as well." |
129 :type 'hook | |
130 :group 'uce) | |
17450 | 131 |
20962 | 132 (defcustom uce-message-text |
17450 | 133 "Recently, I have received an Unsolicited Commercial E-mail from you. |
134 I do not like UCE's and I would like to inform you that sending | |
135 unsolicited messages to someone while he or she may have to pay for | |
136 reading your message may be illegal. Anyway, it is highly annoying | |
137 and not welcome by anyone. It is rude, after all. | |
138 | |
139 If you think that this is a good way to advertise your products or | |
140 services you are mistaken. Spamming will only make people hate you, not | |
141 buy from you. | |
142 | |
143 If you have any list of people you send unsolicited commercial emails to, | |
144 REMOVE me from such list immediately. I suggest that you make this list | |
145 just empty. | |
146 | |
22416
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
147 ---------------------------------------------------- |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
148 |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
149 If you are not an administrator of any site and still have received |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
150 this message then your email address is being abused by some spammer. |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
151 They fake your address in From: or Reply-To: header. In this case, |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
152 you might want to show this message to your system administrator, and |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
153 ask him/her to investigate this matter. |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
154 |
17450 | 155 Note to the postmaster(s): I append the text of UCE in question to |
22416
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
156 this message; I would like to hear from you about action(s) taken. |
17450 | 157 This message has been sent to postmasters at the host that is |
22416
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
158 mentioned as original sender's host (I do realize that it may be |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
159 faked, but I think that if your domain name is being abused this way |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
160 you might want to learn about it, and take actions) and to the |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
161 postmaster whose host was used as mail relay for this message. If |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
162 message was sent not by your user, could you please compare time when |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
163 this message was sent (use time in Received: field of the envelope |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
164 rather than Date: field) with your sendmail logs and see what host was |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
165 using your sendmail at this moment of time. |
17450 | 166 |
167 Thank you." | |
168 | |
169 "This is the text that uce-reply-to-uce command will put in reply buffer. | |
170 Some of spamming programs in use will be set up to read all incoming | |
171 to spam address email, and will remove people who put the word `remove' | |
172 on beginning of some line from the spamming list. So, when you set it | |
173 up, it might be a good idea to actually use this feature. | |
174 | |
20962 | 175 Value nil means insert no text by default, lets you type it in." |
176 :type 'string | |
177 :group 'uce) | |
17450 | 178 |
20962 | 179 (defcustom uce-uce-separator |
17450 | 180 "----- original unsolicited commercial email follows -----" |
181 "Line that will begin quoting of the UCE. | |
20962 | 182 Value nil means use no separator." |
183 :type '(choice (const nil) string) | |
184 :group 'uce) | |
17450 | 185 |
20962 | 186 (defcustom uce-signature mail-signature |
17450 | 187 "Text to put as your signature after the note to UCE sender. |
188 Value nil means none, t means insert ~/.signature file (if it happens | |
189 to exist), if this variable is a string this string will be inserted | |
20962 | 190 as your signature." |
191 :type '(choice (const nil) (const t) string) | |
192 :group 'uce) | |
17450 | 193 |
20962 | 194 (defcustom uce-default-headers |
17450 | 195 "Errors-To: nobody@localhost\nPrecedence: bulk\n" |
196 "Additional headers to use when responding to a UCE with \\[uce-reply-to-uce]. | |
20962 | 197 These are mostly meant for headers that prevent delivery errors reporting." |
198 :type 'string | |
199 :group 'uce) | |
17450 | 200 |
20962 | 201 (defcustom uce-subject-line |
17450 | 202 "Spam alert: unsolicited commercial e-mail" |
20962 | 203 "Subject of the message that will be sent in response to a UCE." |
204 :type 'string | |
205 :group 'uce) | |
17450 | 206 |
207 (defun uce-reply-to-uce (&optional ignored) | |
208 "Send reply to UCE in Rmail. | |
209 UCE stands for unsolicited commercial email. Function will set up reply | |
210 buffer with default To: to the sender, his postmaster, his abuse@ | |
211 address, and postmaster of the mail relay used." | |
22416
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
212 (interactive) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
213 (let ((message-buffer |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
214 (cond ((eq uce-mail-reader 'gnus) "*Article*") |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
215 ((eq uce-mail-reader 'rmail) "RMAIL") |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
216 (t (error |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
217 "Variable uce-mail-reader set to unrecognized value"))))) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
218 (or (get-buffer message-buffer) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
219 (error (concat "No buffer " message-buffer ", cannot find UCE"))) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
220 (switch-to-buffer message-buffer) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
221 (let ((to (mail-strip-quoted-names (mail-fetch-field "from" t))) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
222 (reply-to (mail-fetch-field "reply-to")) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
223 temp) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
224 ;; Initial setting of the list of recipients of our message; that's |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
225 ;; what they are pretending to be. |
17450 | 226 (if to |
22416
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
227 (setq to (format "%s" (mail-strip-quoted-names to))) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
228 (setq to "")) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
229 (if reply-to |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
230 (setq to (format "%s, %s" to (mail-strip-quoted-names reply-to)))) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
231 (let (first-at-sign end-of-hostname sender-host) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
232 (setq first-at-sign (string-match "@" to) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
233 end-of-hostname (string-match "[ ,>]" to first-at-sign) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
234 sender-host (substring to first-at-sign end-of-hostname)) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
235 (if (string-match "\\." sender-host) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
236 (setq to (format "%s, postmaster%s, abuse%s" |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
237 to sender-host sender-host)))) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
238 (setq mail-send-actions nil) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
239 (setq mail-reply-buffer nil) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
240 (cond ((eq uce-mail-reader 'gnus) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
241 (article-hide-headers -1) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
242 (copy-region-as-kill (point-min) (point-max)) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
243 (article-hide-headers)) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
244 ((eq uce-mail-reader 'rmail) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
245 (save-excursion |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
246 (save-restriction |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
247 (widen) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
248 (rmail-maybe-set-message-counters) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
249 (copy-region-as-kill (rmail-msgbeg rmail-current-message) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
250 (rmail-msgend rmail-current-message)))))) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
251 (switch-to-buffer "*mail*") |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
252 (erase-buffer) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
253 (setq temp (point)) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
254 (yank) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
255 (goto-char temp) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
256 (if (eq uce-mail-reader 'rmail) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
257 (progn |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
258 (forward-line 2) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
259 (while (looking-at "Summary-Line:\\|Mail-From:") |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
260 (forward-line 1)) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
261 (delete-region temp (point)))) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
262 ;; Now find the mail hub that first accepted this message. |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
263 ;; This should try to find the last Received: header. |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
264 ;; Sometimes there may be other headers inbetween Received: headers. |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
265 (cond ((eq uce-mail-reader 'gnus) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
266 ;; Does Gnus always have Lines: in the end? |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
267 (re-search-forward "^Lines:") |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
268 (beginning-of-line)) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
269 ((eq uce-mail-reader 'rmail) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
270 (beginning-of-buffer) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
271 (search-forward "*** EOOH ***\n") |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
272 (beginning-of-line) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
273 (forward-line -1))) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
274 (re-search-backward "^Received:") |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
275 (beginning-of-line) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
276 ;; Is this always good? It's the only thing I saw when I checked |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
277 ;; a few messages. |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
278 (let ((eol (save-excursion (end-of-line) (point)))) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
279 ;;(if (not (re-search-forward ": \\(from\\|by\\) " eol t)) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
280 (if (not (re-search-forward "\\(from\\|by\\) " eol t)) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
281 (progn |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
282 (goto-char eol) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
283 (if (looking-at "[ \t\n]+\\(from\\|by\\) ") |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
284 (goto-char (match-end 0)) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
285 (error "Failed to extract hub address"))))) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
286 (setq temp (point)) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
287 (search-forward " ") |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
288 (forward-char -1) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
289 ;; And add its postmaster to the list of addresses. |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
290 (if (string-match "\\." (buffer-substring temp (point))) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
291 (setq to (format "%s, postmaster@%s" |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
292 to (buffer-substring temp (point))))) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
293 ;; Also look at the message-id, it helps *very* often. |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
294 (if (and (search-forward "\nMessage-Id: " nil t) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
295 ;; Not all Message-Id:'s have an `@' sign. |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
296 (let ((bol (point)) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
297 eol) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
298 (end-of-line) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
299 (setq eol (point)) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
300 (goto-char bol) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
301 (search-forward "@" eol t))) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
302 (progn |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
303 (setq temp (point)) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
304 (search-forward ">") |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
305 (forward-char -1) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
306 (if (string-match "\\." (buffer-substring temp (point))) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
307 (setq to (format "%s, postmaster@%s" |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
308 to (buffer-substring temp (point))))))) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
309 (cond ((eq uce-mail-reader 'gnus) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
310 ;; Does Gnus always have Lines: in the end? |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
311 (re-search-forward "^Lines:") |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
312 (beginning-of-line)) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
313 ((eq uce-mail-reader 'rmail) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
314 (search-forward "\n*** EOOH ***\n") |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
315 (forward-line -1))) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
316 (setq temp (point)) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
317 (search-forward "\n\n" nil t) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
318 (if (eq uce-mail-reader 'gnus) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
319 (forward-line -1)) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
320 (delete-region temp (point)) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
321 ;; End of Rmail dependent section. |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
322 (auto-save-mode auto-save-default) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
323 (mail-mode) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
324 (goto-char (point-min)) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
325 (insert "To: ") |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
326 (save-excursion |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
327 (if to |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
328 (let ((fill-prefix "\t") |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
329 (address-start (point))) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
330 (insert to "\n") |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
331 (fill-region-as-paragraph address-start (point))) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
332 (newline)) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
333 (insert "Subject: " uce-subject-line "\n") |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
334 (if uce-default-headers |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
335 (insert uce-default-headers)) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
336 (if mail-default-headers |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
337 (insert mail-default-headers)) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
338 (if mail-default-reply-to |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
339 (insert "Reply-to: " mail-default-reply-to "\n")) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
340 (insert mail-header-separator "\n") |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
341 ;; Insert all our text. Then go back to the place where we started. |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
342 (if to (setq to (point))) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
343 ;; Text of ranting. |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
344 (if uce-message-text |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
345 (insert uce-message-text)) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
346 ;; Signature. |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
347 (cond ((eq uce-signature t) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
348 (if (file-exists-p "~/.signature") |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
349 (progn |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
350 (insert "\n\n-- \n") |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
351 (insert-file "~/.signature") |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
352 ;; Function insert-file leaves point where it was, |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
353 ;; while we want to place signature in the ``middle'' |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
354 ;; of the message. |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
355 (exchange-point-and-mark)))) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
356 (uce-signature |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
357 (insert "\n\n-- \n" uce-signature))) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
358 ;; And text of the original message. |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
359 (if uce-uce-separator |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
360 (insert "\n\n" uce-uce-separator "\n")) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
361 ;; If message doesn't end with a newline, insert it. |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
362 (goto-char (point-max)) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
363 (or (bolp) (newline))) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
364 ;; And go back to the beginning of text. |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
365 (if to (goto-char to)) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
366 (or to (set-buffer-modified-p nil)) |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
367 ;; Run hooks before we leave buffer for editing. Reasonable usage |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
368 ;; might be to set up special key bindings, replace standart |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
369 ;; functions in mail-mode, etc. |
a517da228cb9
(uce-message-text): Change the text of message that is sent.
Richard M. Stallman <rms@gnu.org>
parents:
21918
diff
changeset
|
370 (run-hooks 'mail-setup-hook 'uce-setup-hook)))) |
17450 | 371 |
372 (defun uce-insert-ranting (&optional ignored) | |
373 "Insert text of the usual reply to UCE into current buffer." | |
374 (interactive "P") | |
375 (insert uce-message-text)) | |
376 | |
377 (provide 'uce) | |
378 | |
379 ;;; uce.el ends here |