annotate lisp/gnus/message.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 ;;; message.el --- composing mail and news messages
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 ;; Copyright (C) 1996 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;; Author: Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; Keywords: mail, news
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;; This file is part of GNU Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;; GNU Emacs is free software; you can redistribute it and/or modify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;; it under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;; GNU Emacs is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; GNU General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;; You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;; Boston, MA 02111-1307, USA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;;; Commentary:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;; This mode provides mail-sending facilities from within Emacs. It
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;; consists mainly of large chunks of code from the sendmail.el,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;; gnus-msg.el and rnewspost.el files.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 (eval-when-compile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 (require 'cl))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 (require 'mailheader)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 (require 'rmail)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 (require 'nnheader)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 (require 'timezone)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 (require 'easymenu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 (if (string-match "XEmacs\\|Lucid" emacs-version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 (require 'mail-abbrevs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 (require 'mailabbrev))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 (defvar message-directory "~/Mail/"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 "*Directory from which all other mail file variables are derived.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 (defvar message-max-buffers 10
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 "*How many buffers to keep before starting to kill them off.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 (defvar message-send-rename-function nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 "Function called to rename the buffer after sending it.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 (defvar message-fcc-handler-function 'rmail-output
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 "*A function called to save outgoing articles.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 This function will be called with the name of the file to store the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 article in. The default function is `rmail-output' which saves in Unix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 mailbox format.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 (defvar message-courtesy-message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 "The following message is a courtesy copy of an article\nthat has been posted as well.\n\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 "*This is inserted at the start of a mailed copy of a posted message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 If this variable is nil, no such courtesy message will be added.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 (defvar message-ignored-bounced-headers "^\\(Received\\|Return-Path\\):"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 "*Regexp that matches headers to be removed in resent bounced mail.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 (defvar message-from-style 'default
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 "*Specifies how \"From\" headers look.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 If `nil', they contain just the return address like:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 king@grassland.com
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 If `parens', they look like:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 king@grassland.com (Elvis Parsley)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 If `angles', they look like:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 Elvis Parsley <king@grassland.com>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 Otherwise, most addresses look like `angles', but they look like
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 `parens' if `angles' would need quoting and `parens' would not.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 (defvar message-syntax-checks nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 "Controls what syntax checks should not be performed on outgoing posts.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 To disable checking of long signatures, for instance, add
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 `(signature . disabled)' to this list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 Don't touch this variable unless you really know what you're doing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 Checks include subject-cmsg multiple-headers sendsys message-id from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 long-lines control-chars size new-text redirected-followup signature
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 approved sender empty empty-headers message-id from subject.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 (defvar message-required-news-headers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 '(From Newsgroups Subject Date Message-ID
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 (optional . Organization) Lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 (optional . X-Newsreader))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 "*Headers to be generated or prompted for when posting an article.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 RFC977 and RFC1036 require From, Date, Newsgroups, Subject,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 Message-ID. Organization, Lines, In-Reply-To, Expires, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 X-Newsreader are optional. If don't you want message to insert some
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 header, remove it from this list.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (defvar message-required-mail-headers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 '(From Subject Date (optional . In-Reply-To) Message-ID Lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 (optional . X-Mailer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 "*Headers to be generated or prompted for when mailing a message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 RFC822 required that From, Date, To, Subject and Message-ID be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 included. Organization, Lines and X-Mailer are optional.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 (defvar message-deletable-headers '(Message-ID Date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 "*Headers to be deleted if they already exist and were generated by message previously.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 (defvar message-ignored-news-headers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 "^NNTP-Posting-Host:\\|^Xref:\\|^Bcc:\\|^Gcc:\\|^Fcc:"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 "*Regexp of headers to be removed unconditionally before posting.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 (defvar message-ignored-mail-headers "^Gcc:\\|^Fcc:"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 "*Regexp of headers to be removed unconditionally before mailing.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 (defvar message-ignored-supersedes-headers "^Path:\\|^Date\\|^NNTP-Posting-Host:\\|^Xref:\\|^Lines:\\|^Received:\\|^X-From-Line:\\|Return-Path:\\|^Supersedes:"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 "*Header lines matching this regexp will be deleted before posting.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 It's best to delete old Path and Date headers before posting to avoid
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 any confusion.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 (defvar message-signature-separator "^-- *$"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 "Regexp matching the signature separator.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 (defvar message-interactive nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 "Non-nil means when sending a message wait for and display errors.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 nil means let mailer mail back a message to report errors.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 (defvar message-generate-new-buffers t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 "*Non-nil means that a new message buffer will be created whenever `mail-setup' is called.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 If this is a function, call that function with three parameters: The type,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 the to address and the group name. (Any of these may be nil.) The function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 should return the new buffer name.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 (defvar message-kill-buffer-on-exit nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 "*Non-nil means that the message buffer will be killed after sending a message.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (defvar gnus-local-organization)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 (defvar message-user-organization
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (or (and (boundp 'gnus-local-organization)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 gnus-local-organization)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 (getenv "ORGANIZATION")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 "*String to be used as an Organization header.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 If t, use `message-user-organization-file'.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 (defvar message-user-organization-file "/usr/lib/news/organization"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 "*Local news organization file.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 (defvar message-autosave-directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 (concat (file-name-as-directory message-directory) "drafts/")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 "*Directory where message autosaves buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 If nil, message won't autosave.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 (defvar message-forward-start-separator
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 "------- Start of forwarded message -------\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 "*Delimiter inserted before forwarded messages.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 (defvar message-forward-end-separator
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 "------- End of forwarded message -------\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 "*Delimiter inserted after forwarded messages.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 (defvar message-signature-before-forwarded-message t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 "*If non-nil, put the signature before any included forwarded message.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 (defvar message-included-forward-headers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^Cc:\\|^Posted-To:\\|^Mail-Copies-To:\\|^Apparently-To:\\|^Gnus-Warning:\\|^Resent-\\|^Message-ID:\\|^References:"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 "*Regexp matching headers to be included in forwarded messages.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 (defvar message-ignored-resent-headers "^Return-receipt"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 "*All headers that match this regexp will be deleted when resending a message.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (defvar message-ignored-cited-headers "."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 "Delete these headers from the messages you yank.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 ;; Useful to set in site-init.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 (defvar message-send-mail-function 'message-send-mail-with-sendmail
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 "Function to call to send the current buffer as mail.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 The headers should be delimited by a line whose contents match the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 variable `mail-header-separator'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 Legal values include `message-send-mail-with-mh' and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 `message-send-mail-with-sendmail', which is the default.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (defvar message-send-news-function 'message-send-news
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 "Function to call to send the current buffer as news.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 The headers should be delimited by a line whose contents match the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 variable `mail-header-separator'.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 (defvar message-reply-to-function nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 "Function that should return a list of headers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 This function should pick out addresses from the To, Cc, and From headers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 and respond with new To and Cc headers.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 (defvar message-wide-reply-to-function nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 "Function that should return a list of headers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 This function should pick out addresses from the To, Cc, and From headers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 and respond with new To and Cc headers.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 (defvar message-followup-to-function nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 "Function that should return a list of headers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 This function should pick out addresses from the To, Cc, and From headers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 and respond with new To and Cc headers.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (defvar message-use-followup-to 'ask
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 "*Specifies what to do with Followup-To header.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 If nil, ignore the header. If it is t, use its value, but query before
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 using the \"poster\" value. If it is the symbol `ask', query the user
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 whether to ignore the \"poster\" value. If it is the symbol `use',
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 always use the value.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 (defvar gnus-post-method)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 (defvar gnus-select-method)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 (defvar message-post-method
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 (cond ((and (boundp 'gnus-post-method)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 gnus-post-method)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 gnus-post-method)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 ((boundp 'gnus-select-method)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 gnus-select-method)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 (t '(nnspool "")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 "Method used to post news.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 (defvar message-generate-headers-first nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 "*If non-nil, generate all possible headers before composing.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 (defvar message-setup-hook nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 "Normal hook, run each time a new outgoing message is initialized.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 The function `message-setup' runs this hook.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 (defvar message-signature-setup-hook nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 "Normal hook, run each time a new outgoing message is initialized.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 It is run after the headers have been inserted and before
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 the signature is inserted.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 (defvar message-mode-hook nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 "Hook run in message mode buffers.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 (defvar message-header-hook nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 "Hook run in a message mode buffer narrowed to the headers.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 (defvar message-header-setup-hook nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 "Hook called narrowed to the headers when setting up a message buffer.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 (defvar message-citation-line-function 'message-insert-citation-line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 "*Function called to insert the \"Whomever writes:\" line.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 (defvar message-yank-prefix "> "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 "*Prefix inserted on the lines of yanked messages.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 nil means use indentation.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 (defvar message-indentation-spaces 3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 "*Number of spaces to insert at the beginning of each cited line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 Used by `message-yank-original' via `message-yank-cite'.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 (defvar message-cite-function 'message-cite-original
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 "*Function for citing an original message.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 (defvar message-indent-citation-function 'message-indent-citation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 "*Function for modifying a citation just inserted in the mail buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 This can also be a list of functions. Each function can find the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 citation between (point) and (mark t). And each function should leave
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 point and mark around the citation text as modified.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 (defvar message-abbrevs-loaded nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 (defvar message-signature t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 "*String to be inserted at the end of the message buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 If t, the `message-signature-file' file will be inserted instead.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 If a function, the result from the function will be used instead.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 If a form, the result from the form will be used instead.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 (defvar message-signature-file "~/.signature"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 "*File containing the text inserted at end of message. buffer.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 (defvar message-distribution-function nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 "*Function called to return a Distribution header.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 (defvar message-expires 14
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 "*Number of days before your article expires.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 (defvar message-user-path nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 "If nil, use the NNTP server name in the Path header.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 If stringp, use this; if non-nil, use no host name (user name only).")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 (defvar message-reply-buffer nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 (defvar message-reply-headers nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 (defvar message-newsreader nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 (defvar message-mailer nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 (defvar message-sent-message-via nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 (defvar message-checksum nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 (defvar message-send-actions nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 "A list of actions to be performed upon successful sending of a message.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 (defvar message-exit-actions nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 "A list of actions to be performed upon exiting after sending a message.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 (defvar message-kill-actions nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 "A list of actions to be performed before killing a message buffer.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 (defvar message-postpone-actions nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 "A list of actions to be performed after postponing a message.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 (defvar message-default-headers nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 "*A string containing header lines to be inserted in outgoing messages.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 It is inserted before you edit the message, so you can edit or delete
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 these lines.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 (defvar message-default-mail-headers nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 "*A string of header lines to be inserted in outgoing mails.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 (defvar message-default-news-headers nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 "*A string of header lines to be inserted in outgoing news articles.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 ;; Note: could use /usr/ucb/mail instead of sendmail;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 ;; options -t, and -v if not interactive.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 (defvar message-mailer-swallows-blank-line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 (if (and (string-match "sparc-sun-sunos\\(\\'\\|[^5]\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 system-configuration)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 (file-readable-p "/etc/sendmail.cf")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 (let ((buffer (get-buffer-create " *temp*")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 (insert-file-contents "/etc/sendmail.cf")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 (let ((case-fold-search nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 (re-search-forward "^OR\\>" nil t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 (kill-buffer buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 ;; According to RFC822, "The field-name must be composed of printable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 ;; ASCII characters (i.e. characters that have decimal values between
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 ;; 33 and 126, except colon)", i.e. any chars except ctl chars,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 ;; space, or colon.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 '(looking-at "[ \t]\\|[][!\"#$%&'()*+,-./0-9;<=>?@A-Z\\\\^_`a-z{|}~]+:"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 "Set this non-nil if the system's mailer runs the header and body together.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 \(This problem exists on Sunos 4 when sendmail is run in remote mode.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 The value should be an expression to test whether the problem will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 actually occur.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 (defvar message-mode-syntax-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 (let ((table (copy-syntax-table text-mode-syntax-table)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 (modify-syntax-entry ?% ". " table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 "Syntax table used while in Message mode.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 (defvar message-font-lock-keywords
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 (let* ((cite-prefix "A-Za-z") (cite-suffix (concat cite-prefix "0-9_.@-")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 (list '("^To:" . font-lock-function-name-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 '("^[GBF]?[Cc][Cc]:\\|^Reply-To:" . font-lock-keyword-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 '("^\\(Subject:\\)[ \t]*\\(.+\\)?"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 (1 font-lock-comment-face) (2 font-lock-type-face nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 (list (concat "^\\(" (regexp-quote mail-header-separator) "\\)$")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 1 'font-lock-comment-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 (cons (concat "^[ \t]*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 "\\([" cite-prefix "]+[" cite-suffix "]*\\)?"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 "[>|}].*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 'font-lock-reference-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 '("^\\(X-[A-Za-z0-9-]+\\|In-reply-to\\):.*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 . font-lock-string-face)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 "Additional expressions to highlight in Message mode.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 (defvar message-face-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 '((bold . bold-region)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 (underline . underline-region)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 (default . (lambda (b e)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 (unbold-region b e)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 (ununderline-region b e))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 "Alist of mail and news faces for facemenu.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 The cdr of ech entry is a function for applying the face to a region.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 (defvar message-send-hook nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 "Hook run before sending messages.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 (defvar message-sent-hook nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 "Hook run after sending messages.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 ;;; Internal variables.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 (defvar message-buffer-list nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 ;;; Regexp matching the delimiter of messages in UNIX mail format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 ;;; (UNIX From lines), minus the initial ^.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 (defvar message-unix-mail-delimiter
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 (let ((time-zone-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 (concat "\\([A-Z]?[A-Z]?[A-Z][A-Z]\\( DST\\)?"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 "\\|[-+]?[0-9][0-9][0-9][0-9]"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 "\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 "\\) *")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 "From "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 ;; Username, perhaps with a quoted section that can contain spaces.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 "\\("
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 "[^ \n]*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 "\\(\\|\".*\"[^ \n]*\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 "\\|<[^<>\n]+>"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 "\\) ?"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 ;; The time the message was sent.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 "\\([^ \n]*\\) *" ; day of the week
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 "\\([^ ]*\\) *" ; month
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 "\\([0-9]*\\) *" ; day of month
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 "\\([0-9:]*\\) *" ; time of day
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 ;; Perhaps a time zone, specified by an abbreviation, or by a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 ;; numeric offset.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 time-zone-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 ;; The year.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 " [0-9][0-9]\\([0-9]*\\) *"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 ;; On some systems the time zone can appear after the year, too.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 time-zone-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 ;; Old uucp cruft.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 "\\(remote from .*\\)?"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 "\n")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 (defvar message-unsent-separator
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 (concat "^ *---+ +Unsent message follows +---+ *$\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 "^ *---+ +Returned message +---+ *$\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 "^Start of returned message$\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 "^ *---+ +Original message +---+ *$\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 "^ *--+ +begin message +--+ *$\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 "^ *---+ +Original message follows +---+ *$\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 "^|? *---+ +Message text follows: +---+ *|?$")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 "A regexp that matches the separator before the text of a failed message.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 (defvar message-header-format-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 `((Newsgroups)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 (To . message-fill-address)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 (Cc . message-fill-address)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 (Subject)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 (In-Reply-To)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 (Fcc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 (Bcc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 (Date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 (Organization)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 (Distribution)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 (Lines)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 (Expires)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 (Message-ID)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 (References . message-fill-header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 (X-Mailer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 (X-Newsreader))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 "Alist used for formatting headers.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 (eval-and-compile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 (autoload 'message-setup-toolbar "messagexmas")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 (autoload 'mh-send-letter "mh-comp"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 ;;; Utility functions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 (defun message-point-at-bol ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 "Return point at the beginning of the line."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 (let ((p (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 (goto-char p))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 (defun message-point-at-eol ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 "Return point at the end of the line."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 (let ((p (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 (goto-char p))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 ;; Delete the current line (and the next N lines.);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 (defmacro message-delete-line (&optional n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 `(delete-region (progn (beginning-of-line) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 (progn (forward-line ,(or n 1)) (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 (defun message-tokenize-header (header &optional separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 "Split HEADER into a list of header elements.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 \",\" is used as the separator."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 (let ((regexp (format "[%s]+" (or separator ",")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 (beg 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 quoted elems)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 (message-set-work-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 (insert header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 (while (not (eobp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 (forward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 (cond ((and (> (point) beg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 (or (eobp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 (and (looking-at regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 (not quoted))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 (push (buffer-substring beg (point)) elems)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 (setq beg (match-end 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 ((= (following-char) ?\")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 (setq quoted (not quoted)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 (nreverse elems))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 (defun message-fetch-field (header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 "The same as `mail-fetch-field', only remove all newlines."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 (let ((value (mail-fetch-field header)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 (when value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 (nnheader-replace-chars-in-string value ?\n ? ))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 (defun message-fetch-reply-field (header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 "Fetch FIELD from the message we're replying to."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 (when (and message-reply-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 (buffer-name message-reply-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 (set-buffer message-reply-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 (message-fetch-field header))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 (defun message-set-work-buffer ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 (if (get-buffer " *message work*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 (set-buffer " *message work*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 (erase-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 (set-buffer (get-buffer-create " *message work*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 (kill-all-local-variables)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 (buffer-disable-undo (current-buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 (defun message-functionp (form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 "Return non-nil if FORM is funcallable."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 (or (and (symbolp form) (fboundp form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 (and (listp form) (eq (car form) 'lambda))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 (defun message-strip-subject-re (subject)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 "Remove \"Re:\" from subject lines."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 (if (string-match "^[Rr][Ee]: *" subject)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 (substring subject (match-end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 subject))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 (defun message-remove-header (header &optional is-regexp first reverse)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 "Remove HEADER in the narrowed buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 If REGEXP, HEADER is a regular expression.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 If FIRST, only remove the first instance of the header.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 Return the number of headers removed."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 (let ((regexp (if is-regexp header (concat "^" header ":")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 (number 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 (case-fold-search t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 last)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 (while (and (not (eobp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 (not last))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 (if (if reverse
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 (not (looking-at regexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 (looking-at regexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 (incf number)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 (when first
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 (setq last t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 (delete-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 ;; There might be a continuation header, so we have to search
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 ;; until we find a new non-continuation line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 (if (re-search-forward "^[^ \t]" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 (goto-char (match-beginning 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 (point-max)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 (if (re-search-forward "^[^ \t]" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 (goto-char (match-beginning 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 (point-max))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 number))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 (defun message-narrow-to-headers ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 "Narrow the buffer to the head of the message."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 (narrow-to-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 (if (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 (concat "^" (regexp-quote mail-header-separator) "\n") nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 (match-beginning 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 (goto-char (point-min)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 (defun message-narrow-to-head ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 "Narrow the buffer to the head of the message."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 (narrow-to-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 (if (search-forward "\n\n" nil 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 (1- (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 (goto-char (point-min)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 (defun message-news-p ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 "Say whether the current buffer contains a news message."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 (message-narrow-to-headers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 (message-fetch-field "newsgroups"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 (defun message-mail-p ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 "Say whether the current buffer contains a mail message."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 (message-narrow-to-headers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 (or (message-fetch-field "to")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 (message-fetch-field "cc")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 (message-fetch-field "bcc")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 (defun message-next-header ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 "Go to the beginning of the next header."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 (or (eobp) (forward-char 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 (not (if (re-search-forward "^[^ \t]" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 (goto-char (point-max)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 (defun message-sort-headers-1 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 "Sort the buffer as headers using `message-rank' text props."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 (sort-subr
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 nil 'message-next-header
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 (lambda ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 (message-next-header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 (unless (bobp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 (forward-char -1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 (lambda ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 (or (get-text-property (point) 'message-rank)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 (defun message-sort-headers ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 "Sort the headers of the current message according to `message-header-format-alist'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 (let ((max (1+ (length message-header-format-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 rank)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 (message-narrow-to-headers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 (while (re-search-forward "^[^ \n]+:" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 (put-text-property
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 (match-beginning 0) (1+ (match-beginning 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 'message-rank
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675 (if (setq rank (length (memq (assq (intern (buffer-substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 (match-beginning 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 (1- (match-end 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 message-header-format-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 message-header-format-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 (- max rank)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 (1+ max)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 (message-sort-headers-1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 ;;; Message mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 ;;; Set up keymap.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692 (defvar message-mode-map nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 (unless message-mode-map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 (setq message-mode-map (copy-keymap text-mode-map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 (define-key message-mode-map "\C-c?" 'describe-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698 (define-key message-mode-map "\C-c\C-f\C-t" 'message-goto-to)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 (define-key message-mode-map "\C-c\C-f\C-b" 'message-goto-bcc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700 (define-key message-mode-map "\C-c\C-f\C-w" 'message-goto-fcc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701 (define-key message-mode-map "\C-c\C-f\C-c" 'message-goto-cc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702 (define-key message-mode-map "\C-c\C-f\C-s" 'message-goto-subject)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 (define-key message-mode-map "\C-c\C-f\C-r" 'message-goto-reply-to)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 (define-key message-mode-map "\C-c\C-f\C-n" 'message-goto-newsgroups)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 (define-key message-mode-map "\C-c\C-f\C-d" 'message-goto-distribution)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 (define-key message-mode-map "\C-c\C-f\C-f" 'message-goto-followup-to)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 (define-key message-mode-map "\C-c\C-f\C-k" 'message-goto-keywords)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 (define-key message-mode-map "\C-c\C-f\C-u" 'message-goto-summary)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 (define-key message-mode-map "\C-c\C-b" 'message-goto-body)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 (define-key message-mode-map "\C-c\C-i" 'message-goto-signature)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712 (define-key message-mode-map "\C-c\C-t" 'message-insert-to)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 (define-key message-mode-map "\C-c\C-n" 'message-insert-newsgroups)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 (define-key message-mode-map "\C-c\C-y" 'message-yank-original)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 (define-key message-mode-map "\C-c\C-q" 'message-fill-yanked-message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717 (define-key message-mode-map "\C-c\C-w" 'message-insert-signature)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718 (define-key message-mode-map "\C-c\C-r" 'message-caesar-buffer-body)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719 (define-key message-mode-map "\C-c\C-o" 'message-sort-headers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720 (define-key message-mode-map "\C-c\M-r" 'message-rename-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722 (define-key message-mode-map "\C-c\C-c" 'message-send-and-exit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723 (define-key message-mode-map "\C-c\C-s" 'message-send)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 (define-key message-mode-map "\C-c\C-k" 'message-kill-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725 (define-key message-mode-map "\C-c\C-d" 'message-dont-send)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 (define-key message-mode-map "\t" 'message-tab))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729 (easy-menu-define message-mode-menu message-mode-map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 "Message Menu."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 '("Message"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 "Go to Field:"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 "----"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 ["To" message-goto-to t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735 ["Subject" message-goto-subject t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736 ["Cc" message-goto-cc t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737 ["Reply-to" message-goto-reply-to t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 ["Summary" message-goto-summary t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 ["Keywords" message-goto-keywords t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 ["Newsgroups" message-goto-newsgroups t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 ["Followup-To" message-goto-followup-to t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 ["Distribution" message-goto-distribution t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743 ["Body" message-goto-body t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744 ["Signature" message-goto-signature t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745 "----"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746 "Miscellaneous Commands:"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747 "----"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748 ["Sort Headers" message-sort-headers t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 ["Yank Original" message-yank-original t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750 ["Fill Yanked Message" message-fill-yanked-message t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751 ["Insert Signature" message-insert-signature t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 ["Caesar (rot13) Message" message-caesar-buffer-body t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 ["Rename buffer" message-rename-buffer t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754 ["Spellcheck" ispell-message t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755 "----"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 ["Send Message" message-send-and-exit t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757 ["Abort Message" message-dont-send t]))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 (defvar facemenu-add-face-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760 (defvar facemenu-remove-face-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763 (defun message-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764 "Major mode for editing mail and news to be sent.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765 Like Text Mode but with these additional commands:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766 C-c C-s message-send (send the message) C-c C-c message-send-and-exit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 C-c C-f move to a header field (and create it if there isn't):
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768 C-c C-f C-t move to To C-c C-f C-s move to Subject
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769 C-c C-f C-c move to Cc C-c C-f C-b move to Bcc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
770 C-c C-f C-f move to Fcc C-c C-f C-r move to Reply-To
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
771 C-c C-f C-u move to Summary C-c C-f C-n move to Newsgroups
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772 C-c C-f C-k move to Keywords C-c C-f C-d move to Distribution
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773 C-c C-f C-o move to Followup-To
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774 C-c C-t message-insert-to (add a To header to a news followup)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775 C-c C-n message-insert-newsgroups (add a Newsgroup header to a news reply)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776 C-c C-b message-goto-body (move to beginning of message text).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777 C-c C-i message-goto-signature (move to the beginning of the signature).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778 C-c C-w message-insert-signature (insert `message-signature-file' file).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779 C-c C-y message-yank-original (insert current message, if any).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 C-c C-q message-fill-yanked-message (fill what was yanked).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781 C-c C-r message-ceasar-buffer-body (rot13 the message body)."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783 (kill-all-local-variables)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784 (make-local-variable 'message-reply-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785 (setq message-reply-buffer nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786 (make-local-variable 'message-send-actions)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787 (make-local-variable 'message-exit-actions)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788 (make-local-variable 'message-kill-actions)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789 (make-local-variable 'message-postpone-actions)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790 (set-syntax-table message-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 (use-local-map message-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792 (setq local-abbrev-table text-mode-abbrev-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793 (setq major-mode 'message-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794 (setq mode-name "Message")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795 (setq buffer-offer-save t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796 (make-local-variable 'font-lock-defaults)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797 (setq font-lock-defaults '(message-font-lock-keywords t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798 (make-local-variable 'facemenu-add-face-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799 (make-local-variable 'facemenu-remove-face-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800 (setq facemenu-add-face-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801 (lambda (face end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802 (let ((face-fun (cdr (assq face message-face-alist))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803 (if face-fun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804 (funcall face-fun (point) end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805 (error "Face %s not configured for %s mode" face mode-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806 "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807 facemenu-remove-face-function t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808 (make-local-variable 'paragraph-separate)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809 (make-local-variable 'paragraph-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810 (setq paragraph-start (concat (regexp-quote mail-header-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811 "$\\|[ \t]*[-_][-_][-_]+$\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812 "-- $\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813 paragraph-start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814 (setq paragraph-separate (concat (regexp-quote mail-header-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
815 "$\\|[ \t]*[-_][-_][-_]+$\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
816 "-- $\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817 paragraph-separate))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818 (make-local-variable 'message-reply-headers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819 (setq message-reply-headers nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
820 (make-local-variable 'message-newsreader)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821 (make-local-variable 'message-mailer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
822 (make-local-variable 'message-post-method)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
823 (make-local-variable 'message-sent-message-via)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
824 (setq message-sent-message-via nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
825 (make-local-variable 'message-checksum)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826 (setq message-checksum nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827 (when (fboundp 'mail-hist-define-keys)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828 (mail-hist-define-keys))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829 (when (string-match "XEmacs\\|Lucid" emacs-version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830 (message-setup-toolbar))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831 (easy-menu-add message-mode-menu message-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832 ;; Allow mail alias things.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
833 (if (fboundp 'mail-abbrevs-setup)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834 (mail-abbrevs-setup)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835 (funcall (intern "mail-aliases-setup")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836 (run-hooks 'text-mode-hook 'message-mode-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841 ;;; Message mode commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844 ;;; Movement commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846 (defun message-goto-to ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847 "Move point to the To header."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849 (message-position-on-field "To"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 (defun message-goto-subject ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852 "Move point to the Subject header."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854 (message-position-on-field "Subject"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856 (defun message-goto-cc ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857 "Move point to the Cc header."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
859 (message-position-on-field "Cc" "To"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
861 (defun message-goto-bcc ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
862 "Move point to the Bcc header."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
863 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
864 (message-position-on-field "Bcc" "Cc" "To"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
865
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
866 (defun message-goto-fcc ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
867 "Move point to the Fcc header."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
868 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
869 (message-position-on-field "Fcc" "To" "Newsgroups"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
870
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
871 (defun message-goto-reply-to ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
872 "Move point to the Reply-To header."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
873 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874 (message-position-on-field "Reply-To" "Subject"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
875
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876 (defun message-goto-newsgroups ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877 "Move point to the Newsgroups header."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
879 (message-position-on-field "Newsgroups"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881 (defun message-goto-distribution ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
882 "Move point to the Distribution header."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
883 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
884 (message-position-on-field "Distribution"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
886 (defun message-goto-followup-to ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
887 "Move point to the Followup-To header."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
888 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
889 (message-position-on-field "Followup-To" "Newsgroups"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891 (defun message-goto-keywords ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
892 "Move point to the Keywords header."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
893 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
894 (message-position-on-field "Keywords" "Subject"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
895
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
896 (defun message-goto-summary ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
897 "Move point to the Summary header."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
898 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
899 (message-position-on-field "Summary" "Subject"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
900
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
901 (defun message-goto-body ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
902 "Move point to the beginning of the message body."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
903 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
904 (if (looking-at "[ \t]*\n") (expand-abbrev))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
905 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
906 (search-forward (concat "\n" mail-header-separator "\n") nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
907
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
908 (defun message-goto-signature ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
909 "Move point to the beginning of the message signature."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
910 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
911 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
912 (or (re-search-forward message-signature-separator nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
913 (goto-char (point-max))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
914
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
915
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
916
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
917 (defun message-insert-to ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
918 "Insert a To header that points to the author of the article being replied to."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
919 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
920 (when (and (message-position-on-field "To")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
921 (mail-fetch-field "to")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
922 (not (string-match "\\` *\\'" (mail-fetch-field "to"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
923 (insert ", "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
924 (insert (or (message-fetch-reply-field "reply-to")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
925 (message-fetch-reply-field "from") "")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
926
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
927 (defun message-insert-newsgroups ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
928 "Insert the Newsgroups header from the article being replied to."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
929 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
930 (when (and (message-position-on-field "Newsgroups")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
931 (mail-fetch-field "newsgroups")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
932 (not (string-match "\\` *\\'" (mail-fetch-field "newsgroups"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
933 (insert ","))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
934 (insert (or (message-fetch-reply-field "newsgroups") "")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
935
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
936
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
937
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
938 ;;; Various commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
939
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
940 (defun message-insert-signature (&optional force)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
941 "Insert a signature. See documentation for the `message-signature' variable."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
942 (interactive (list 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
943 (let* ((signature
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
944 (cond ((and (null message-signature)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
945 (eq force 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
946 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
947 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
948 (not (re-search-backward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
949 message-signature-separator nil t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
950 ((and (null message-signature)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
951 force)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
952 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
953 ((message-functionp message-signature)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
954 (funcall message-signature))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
955 ((listp message-signature)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
956 (eval message-signature))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
957 (t message-signature)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
958 (signature
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
959 (cond ((stringp signature)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
960 signature)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
961 ((and (eq t signature)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
962 message-signature-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
963 (file-exists-p message-signature-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
964 signature))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
965 (when signature
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
966 ; ;; Remove blank lines at the end of the message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
967 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
968 ; (skip-chars-backward " \t\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
969 ; (delete-region (point) (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
970 ;; Insert the signature.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
971 (unless (bolp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
972 (insert "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
973 (insert "\n-- \n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
974 (if (eq signature t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
975 (insert-file-contents message-signature-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
976 (insert signature))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
977 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
978 (or (bolp) (insert "\n")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
979
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
980 (defvar message-caesar-translation-table nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
981
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
982 (defun message-caesar-region (b e &optional n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
983 "Caesar rotation of region by N, default 13, for decrypting netnews."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
984 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
985 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
986 (min (point) (or (mark t) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
987 (max (point) (or (mark t) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
988 (when current-prefix-arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
989 (prefix-numeric-value current-prefix-arg))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
990
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
991 (setq n (if (numberp n) (mod n 26) 13)) ;canonize N
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
992 (unless (or (zerop n) ; no action needed for a rot of 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
993 (= b e)) ; no region to rotate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
994 ;; We build the table, if necessary.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
995 (when (or (not message-caesar-translation-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
996 (/= (aref message-caesar-translation-table ?a) (+ ?a n)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
997 (let ((i -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
998 (table (make-string 256 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
999 (while (< (incf i) 256)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1000 (aset table i i))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1001 (setq table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1002 (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1003 (substring table 0 ?A)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1004 (substring table (+ ?A n) (+ ?A n (- 26 n)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1005 (substring table ?A (+ ?A n))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1006 (substring table (+ ?A 26) ?a)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1007 (substring table (+ ?a n) (+ ?a n (- 26 n)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1008 (substring table ?a (+ ?a n))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1009 (substring table (+ ?a 26) 255)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1010 (setq message-caesar-translation-table table)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1011 ;; Then we translate the region. Do it this way to retain
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1012 ;; text properties.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1013 (while (< b e)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1014 (subst-char-in-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1015 b (1+ b) (char-after b)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1016 (aref message-caesar-translation-table (char-after b)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1017 (incf b))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1018
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1019 (defun message-caesar-buffer-body (&optional rotnum)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1020 "Caesar rotates all letters in the current buffer by 13 places.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1021 Used to encode/decode possibly offensive messages (commonly in net.jokes).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1022 With prefix arg, specifies the number of places to rotate each letter forward.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1023 Mail and USENET news headers are not rotated."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1024 (interactive (if current-prefix-arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1025 (list (prefix-numeric-value current-prefix-arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1026 (list nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1027 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1028 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1029 (when (message-goto-body)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1030 (narrow-to-region (point) (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1031 (message-caesar-region (point-min) (point-max) rotnum))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1032
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1033 (defun message-rename-buffer (&optional enter-string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1034 "Rename the *message* buffer to \"*message* RECIPIENT\".
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1035 If the function is run with a prefix, it will ask for a new buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1036 name, rather than giving an automatic name."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1037 (interactive "Pbuffer name: ")
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 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1040 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1041 (narrow-to-region (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1042 (search-forward mail-header-separator nil 'end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1043 (let* ((mail-to (if (message-news-p) (message-fetch-field "Newsgroups")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1044 (message-fetch-field "To")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1045 (mail-trimmed-to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1046 (if (string-match "," mail-to)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1047 (concat (substring mail-to 0 (match-beginning 0)) ", ...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1048 mail-to))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1049 (name-default (concat "*message* " mail-trimmed-to))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1050 (name (if enter-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1051 (read-string "New buffer name: " name-default)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1052 name-default)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1053 (rename-buffer name t)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1054
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1055 (defun message-fill-yanked-message (&optional justifyp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1056 "Fill the paragraphs of a message yanked into this one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1057 Numeric argument means justify as well."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1058 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1059 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1060 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1061 (search-forward (concat "\n" mail-header-separator "\n") nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1062 (let ((fill-prefix message-yank-prefix))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1063 (fill-individual-paragraphs (point) (point-max) justifyp t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1064
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1065 (defun message-indent-citation ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1066 "Modify text just inserted from a message to be cited.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1067 The inserted text should be the region.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1068 When this function returns, the region is again around the modified text.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1069
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1070 Normally, indent each nonblank line `message-indentation-spaces' spaces.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1071 However, if `message-yank-prefix' is non-nil, insert that prefix on each line."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1072 (let ((start (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1073 ;; Remove unwanted headers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1074 (when message-ignored-cited-headers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1075 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1076 (narrow-to-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1077 (goto-char start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1078 (if (search-forward "\n\n" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1079 (1- (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1080 (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1081 (message-remove-header message-ignored-cited-headers t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1082 ;; Do the indentation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1083 (if (null message-yank-prefix)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1084 (indent-rigidly start (mark t) message-indentation-spaces)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1085 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1086 (goto-char start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1087 (while (< (point) (mark t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1088 (insert message-yank-prefix)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1089 (forward-line 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1090 (goto-char start))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1091
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1092 (defun message-yank-original (&optional arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1093 "Insert the message being replied to, if any.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1094 Puts point before the text and mark after.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1095 Normally indents each nonblank line ARG spaces (default 3). However,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1096 if `message-yank-prefix' is non-nil, insert that prefix on each line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1097
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1098 Just \\[universal-argument] as argument means don't indent, insert no
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1099 prefix, and don't delete any headers."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1100 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1101 (let ((modified (buffer-modified-p)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1102 (when (and message-reply-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1103 message-cite-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1104 (delete-windows-on message-reply-buffer t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1105 (insert-buffer message-reply-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1106 (funcall message-cite-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1107 (message-exchange-point-and-mark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1108 (unless (bolp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1109 (insert ?\n))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1110 (unless modified
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1111 (setq message-checksum (cons (message-checksum) (buffer-size)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1112
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1113 (defun message-cite-original ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1114 (let ((start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1115 (functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1116 (when message-indent-citation-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1117 (if (listp message-indent-citation-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1118 message-indent-citation-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1119 (list message-indent-citation-function)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1120 (goto-char start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1121 (while functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1122 (funcall (pop functions)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1123 (when message-citation-line-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1124 (unless (bolp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1125 (insert "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1126 (funcall message-citation-line-function))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1127
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1128 (defun message-insert-citation-line ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1129 "Function that inserts a simple citation line."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1130 (when message-reply-headers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1131 (insert (mail-header-from message-reply-headers) " writes:\n\n")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1132
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1133 (defun message-position-on-field (header &rest afters)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1134 (let ((case-fold-search t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1135 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1136 (narrow-to-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1137 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1138 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1139 (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1140 (concat "^" (regexp-quote mail-header-separator) "$"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1141 (match-beginning 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1142 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1143 (if (re-search-forward (concat "^" (regexp-quote header) ":") nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1144 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1145 (re-search-forward "^[^ \t]" nil 'move)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1146 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1147 (skip-chars-backward "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1148 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1149 (while (and afters
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1150 (not (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1151 (concat "^" (regexp-quote (car afters)) ":")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1152 nil t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1153 (pop afters))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1154 (when afters
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1155 (re-search-forward "^[^ \t]" nil 'move)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1156 (beginning-of-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1157 (insert header ": \n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1158 (forward-char -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1159 nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1160
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1161 (defun message-remove-signature ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1162 "Remove the signature from the text between point and mark.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1163 The text will also be indented the normal way."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1164 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1165 (let ((start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1166 mark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1167 (if (not (re-search-forward message-signature-separator (mark t) t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1168 ;; No signature here, so we just indent the cited text.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1169 (message-indent-citation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1170 ;; Find the last non-empty line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1171 (forward-line -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1172 (while (looking-at "[ \t]*$")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1173 (forward-line -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1174 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1175 (setq mark (set-marker (make-marker) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1176 (goto-char start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1177 (message-indent-citation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1178 ;; Enable undoing the deletion.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1179 (undo-boundary)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1180 (delete-region mark (mark t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1181 (set-marker mark nil)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1182
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1183
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1184
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1185 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1186 ;;; Sending messages
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1187 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1188
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1189 (defun message-send-and-exit (&optional arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1190 "Send message like `message-send', then, if no errors, exit from mail buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1191 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1192 (let ((buf (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1193 (actions message-exit-actions))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1194 (when (and (message-send arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1195 (buffer-name buf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1196 (if message-kill-buffer-on-exit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1197 (kill-buffer buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1198 (bury-buffer buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1199 (when (eq buf (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1200 (message-bury buf)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1201 (message-do-actions actions))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1202
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1203 (defun message-dont-send ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1204 "Don't send the message you have been editing."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1205 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1206 (message-bury (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1207 (message-do-actions message-postpone-actions))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1208
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1209 (defun message-kill-buffer ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1210 "Kill the current buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1211 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1212 (let ((actions message-kill-actions))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1213 (kill-buffer (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1214 (message-do-actions actions)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1215
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1216 (defun message-bury (buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1217 "Bury this mail buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1218 (let ((newbuf (other-buffer buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1219 (bury-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1220 (if (and (fboundp 'frame-parameters)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1221 (cdr (assq 'dedicated (frame-parameters)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1222 (not (null (delq (selected-frame) (visible-frame-list)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1223 (delete-frame (selected-frame))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1224 (switch-to-buffer newbuf))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1225
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1226 (defun message-send (&optional arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1227 "Send the message in the current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1228 If `message-interactive' is non-nil, wait for success indication
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1229 or error messages, and inform user.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1230 Otherwise any failure is reported in a message back to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1231 the user from the mailer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1232 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1233 (when (if buffer-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1234 (y-or-n-p (format "Send buffer contents as %s message? "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1235 (if (message-mail-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1236 (if (message-news-p) "mail and news" "mail")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1237 "news")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1238 (or (buffer-modified-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1239 (y-or-n-p "No changes in the buffer; really send? ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1240 ;; Make it possible to undo the coming changes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1241 (undo-boundary)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1242 (let ((inhibit-read-only t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1243 (put-text-property (point-min) (point-max) 'read-only nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1244 (message-fix-before-sending)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1245 (run-hooks 'message-send-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1246 (message "Sending...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1247 (when (and (or (not (message-news-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1248 (and (or (not (memq 'news message-sent-message-via))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1249 (y-or-n-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1250 "Already sent message via news; resend? "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1251 (funcall message-send-news-function arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1252 (or (not (message-mail-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1253 (and (or (not (memq 'mail message-sent-message-via))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1254 (y-or-n-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1255 "Already sent message via mail; resend? "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1256 (message-send-mail arg))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1257 (message-do-fcc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1258 (when (fboundp 'mail-hist-put-headers-into-history)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1259 (mail-hist-put-headers-into-history))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1260 (run-hooks 'message-sent-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1261 (message "Sending...done")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1262 ;; If buffer has no file, mark it as unmodified and delete autosave.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1263 (unless buffer-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1264 (set-buffer-modified-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1265 (delete-auto-save-file-if-necessary t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1266 ;; Delete other mail buffers and stuff.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1267 (message-do-send-housekeeping)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1268 (message-do-actions message-send-actions)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1269 ;; Return success.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1270 t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1271
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1272 (defun message-fix-before-sending ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1273 "Do various things to make the message nice before sending it."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1274 ;; Make sure there's a newline at the end of the message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1275 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1276 (unless (bolp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1277 (insert "\n")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1278
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1279 (defun message-add-action (action &rest types)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1280 "Add ACTION to be performed when doing an exit of type TYPES."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1281 (let (var)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1282 (while types
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1283 (set (setq var (intern (format "message-%s-actions" (pop types))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1284 (nconc (symbol-value var) (list action))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1285
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1286 (defun message-do-actions (actions)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1287 "Perform all actions in ACTIONS."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1288 ;; Now perform actions on successful sending.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1289 (while actions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1290 (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1291 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1292 ;; A simple function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1293 ((message-functionp (car actions))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1294 (funcall (car actions)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1295 ;; Something to be evaled.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1296 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1297 (eval (car actions))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1298 (error))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1299 (pop actions)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1300
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1301 (defun message-send-mail (&optional arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1302 (require 'mail-utils)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1303 (let ((tembuf (generate-new-buffer " message temp"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1304 (case-fold-search nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1305 (news (message-news-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1306 (mailbuf (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1307 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1308 (message-narrow-to-headers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1309 ;; Insert some headers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1310 (let ((message-deletable-headers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1311 (if news nil message-deletable-headers)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1312 (message-generate-headers message-required-mail-headers))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1313 ;; Let the user do all of the above.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1314 (run-hooks 'message-header-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1315 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1316 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1317 (set-buffer tembuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1318 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1319 (insert-buffer-substring mailbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1320 ;; Remove some headers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1321 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1322 (message-narrow-to-headers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1323 ;; Remove some headers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1324 (message-remove-header message-ignored-mail-headers t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1325 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1326 ;; require one newline at the end.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1327 (or (= (preceding-char) ?\n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1328 (insert ?\n))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1329 (when (and news
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1330 (or (message-fetch-field "cc")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1331 (message-fetch-field "to")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1332 (message-insert-courtesy-copy))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1333 (funcall message-send-mail-function))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1334 (kill-buffer tembuf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1335 (set-buffer mailbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1336 (push 'mail message-sent-message-via)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1337
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1338 (defun message-send-mail-with-sendmail ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1339 "Send off the prepared buffer with sendmail."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1340 (let ((errbuf (if message-interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1341 (generate-new-buffer " sendmail errors")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1342 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1343 resend-to-addresses delimline)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1344 (let ((case-fold-search t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1345 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1346 (message-narrow-to-headers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1347 (setq resend-to-addresses (message-fetch-field "resent-to")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1348 ;; Change header-delimiter to be what sendmail expects.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1349 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1350 (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1351 (concat "^" (regexp-quote mail-header-separator) "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1352 (replace-match "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1353 (backward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1354 (setq delimline (point-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1355 ;; Insert an extra newline if we need it to work around
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1356 ;; Sun's bug that swallows newlines.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1357 (goto-char (1+ delimline))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1358 (when (eval message-mailer-swallows-blank-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1359 (newline))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1360 (when message-interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1361 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1362 (set-buffer errbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1363 (erase-buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1364 (let ((default-directory "/"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1365 (apply 'call-process-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1366 (append (list (point-min) (point-max)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1367 (if (boundp 'sendmail-program)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1368 sendmail-program
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1369 "/usr/lib/sendmail")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1370 nil errbuf nil "-oi")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1371 ;; Always specify who from,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1372 ;; since some systems have broken sendmails.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1373 (list "-f" (user-login-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1374 ;; These mean "report errors by mail"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1375 ;; and "deliver in background".
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1376 (if (null message-interactive) '("-oem" "-odb"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1377 ;; Get the addresses from the message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1378 ;; unless this is a resend.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1379 ;; We must not do that for a resend
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1380 ;; because we would find the original addresses.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1381 ;; For a resend, include the specific addresses.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1382 (if resend-to-addresses
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1383 (list resend-to-addresses)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1384 '("-t")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1385 (when message-interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1386 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1387 (set-buffer errbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1388 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1389 (while (re-search-forward "\n\n* *" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1390 (replace-match "; "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1391 (if (not (zerop (buffer-size)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1392 (error "Sending...failed to %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1393 (buffer-substring (point-min) (point-max)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1394 (when (bufferp errbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1395 (kill-buffer errbuf)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1396
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1397 (defun message-send-mail-with-mh ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1398 "Send the prepared message buffer with mh."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1399 (let ((mh-previous-window-config nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1400 (name (make-temp-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1401 (concat (file-name-as-directory message-autosave-directory)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1402 "msg."))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1403 (setq buffer-file-name name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1404 (mh-send-letter)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1405 (condition-case ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1406 (delete-file name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1407 (error nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1408
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1409 (defun message-send-news (&optional arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1410 (let ((tembuf (generate-new-buffer " *message temp*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1411 (case-fold-search nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1412 (method (if (message-functionp message-post-method)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1413 (funcall message-post-method arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1414 message-post-method))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1415 (messbuf (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1416 result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1417 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1418 (message-narrow-to-headers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1419 ;; Insert some headers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1420 (message-generate-headers message-required-news-headers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1421 ;; Let the user do all of the above.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1422 (run-hooks 'message-header-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1423 (message-cleanup-headers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1424 (when (message-check-news-syntax)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1425 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1426 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1427 (set-buffer tembuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1428 (buffer-disable-undo (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1429 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1430 (insert-buffer-substring messbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1431 ;; Remove some headers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1432 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1433 (message-narrow-to-headers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1434 ;; Remove some headers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1435 (message-remove-header message-ignored-news-headers t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1436 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1437 ;; require one newline at the end.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1438 (or (= (preceding-char) ?\n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1439 (insert ?\n))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1440 (let ((case-fold-search t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1441 ;; Remove the delimeter.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1442 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1443 (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1444 (concat "^" (regexp-quote mail-header-separator) "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1445 (replace-match "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1446 (backward-char 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1447 (require (car method))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1448 (funcall (intern (format "%s-open-server" (car method)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1449 (cadr method) (cddr method))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1450 (setq result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1451 (funcall (intern (format "%s-request-post" (car method))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1452 (kill-buffer tembuf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1453 (set-buffer messbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1454 (if result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1455 (push 'news message-sent-message-via)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1456 (message "Couldn't send message via news: %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1457 (nnheader-get-report (car method)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1458 nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1459
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1460 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1461 ;;; Header generation & syntax checking.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1462 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1463
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1464 (defun message-check-news-syntax ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1465 "Check the syntax of the message."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1466 (and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1467 ;; We narrow to the headers and check them first.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1468 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1469 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1470 (message-narrow-to-headers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1471 (and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1472 ;; Check for commands in Subject.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1473 (or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1474 (message-check-element 'subject-cmsg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1475 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1476 (if (string-match "^cmsg " (message-fetch-field "subject"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1477 (y-or-n-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1478 "The control code \"cmsg \" is in the subject. Really post? ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1479 t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1480 ;; Check for multiple identical headers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1481 (or (message-check-element 'multiple-headers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1482 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1483 (let (found)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1484 (while (and (not found)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1485 (re-search-forward "^[^ \t:]+: " nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1486 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1487 (or (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1488 (concat "^" (setq found
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1489 (buffer-substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1490 (match-beginning 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1491 (- (match-end 0) 2))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1492 nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1493 (setq found nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1494 (if found
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1495 (y-or-n-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1496 (format "Multiple %s headers. Really post? " found))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1497 t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1498 ;; Check for Version and Sendsys.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1499 (or (message-check-element 'sendsys)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1500 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1501 (if (re-search-forward "^Sendsys:\\|^Version:" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1502 (y-or-n-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1503 (format "The article contains a %s command. Really post? "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1504 (buffer-substring (match-beginning 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1505 (1- (match-end 0)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1506 t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1507 ;; See whether we can shorten Followup-To.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1508 (or (message-check-element 'shorten-followup-to)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1509 (let ((newsgroups (message-fetch-field "newsgroups"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1510 (followup-to (message-fetch-field "followup-to"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1511 to)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1512 (when (and newsgroups (string-match "," newsgroups)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1513 (not followup-to)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1514 (not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1515 (zerop
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1516 (length
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1517 (setq to (completing-read
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1518 "Followups to: (default all groups) "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1519 (mapcar (lambda (g) (list g))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1520 (cons "poster"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1521 (message-tokenize-header
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1522 newsgroups)))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1523 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1524 (insert "Followup-To: " to "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1525 t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1526 ;; Check "Shoot me".
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1527 (or (message-check-element 'shoot)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1528 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1529 (if (search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1530 ".i-have-a-misconfigured-system-so-shoot-me" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1531 (y-or-n-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1532 "You appear to have a misconfigured system. Really post? ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1533 t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1534 ;; Check for Approved.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1535 (or (message-check-element 'approved)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1536 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1537 (if (re-search-forward "^Approved:" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1538 (y-or-n-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1539 "The article contains an Approved header. Really post? ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1540 t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1541 ;; Check the Message-Id header.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1542 (or (message-check-element 'message-id)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1543 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1544 (let* ((case-fold-search t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1545 (message-id (message-fetch-field "message-id")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1546 (or (not message-id)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1547 (and (string-match "@" message-id)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1548 (string-match "@[^\\.]*\\." message-id))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1549 (y-or-n-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1550 (format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1551 "The Message-ID looks strange: \"%s\". Really post? "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1552 message-id))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1553 ;; Check the Subject header.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1554 (or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1555 (message-check-element 'subject)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1556 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1557 (let* ((case-fold-search t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1558 (subject (message-fetch-field "subject")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1559 (or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1560 (and subject
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1561 (not (string-match "\\`[ \t]*\\'" subject)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1562 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1563 (message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1564 "The subject field is empty or missing. Posting is denied.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1565 nil)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1566 ;; Check the Newsgroups & Followup-To headers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1567 (or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1568 (message-check-element 'existing-newsgroups)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1569 (let* ((case-fold-search t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1570 (newsgroups (message-fetch-field "newsgroups"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1571 (followup-to (message-fetch-field "followup-to"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1572 (groups (message-tokenize-header
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1573 (if followup-to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1574 (concat newsgroups "," followup-to)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1575 newsgroups)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1576 (hashtb (and (boundp 'gnus-active-hashtb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1577 gnus-active-hashtb))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1578 errors)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1579 (if (not hashtb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1580 t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1581 (while groups
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1582 (when (and (not (boundp (intern (car groups) hashtb)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1583 (not (equal (car groups) "poster")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1584 (push (car groups) errors))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1585 (pop groups))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1586 (if (not errors)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1587 t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1588 (y-or-n-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1589 (format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1590 "Really post to %s unknown group%s: %s "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1591 (if (= (length errors) 1) "this" "these")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1592 (if (= (length errors) 1) "" "s")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1593 (mapconcat 'identity errors ", ")))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1594 ;; Check the Newsgroups & Followup-To headers for syntax errors.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1595 (or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1596 (message-check-element 'valid-newsgroups)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1597 (let ((case-fold-search t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1598 (headers '("Newsgroups" "Followup-To"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1599 header error)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1600 (while (and headers (not error))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1601 (when (setq header (mail-fetch-field (car headers)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1602 (if (or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1603 (not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1604 (string-match
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1605 "\\`\\([-+_&.a-zA-Z0-9]+\\)?\\(,[-.a-zA-Z0-9]+\\)*\\'"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1606 header))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1607 (memq
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1608 nil (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1609 (lambda (g)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1610 (not (string-match "\\.\\'\\|\\.\\." g)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1611 (message-tokenize-header header ","))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1612 (setq error t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1613 (unless error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1614 (pop headers)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1615 (if (not error)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1616 t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1617 (y-or-n-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1618 (format "The %s header looks odd: \"%s\". Really post? "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1619 (car headers) header)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1620 ;; Check the From header.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1621 (or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1622 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1623 (let* ((case-fold-search t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1624 (from (message-fetch-field "from")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1625 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1626 ((not from)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1627 (message "There is no From line. Posting is denied.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1628 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1629 ((not (string-match "@[^\\.]*\\." from))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1630 (message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1631 "Denied posting -- the From looks strange: \"%s\"." from)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1632 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1633 ((string-match "@[^@]*@" from)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1634 (message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1635 "Denied posting -- two \"@\"'s in the From header: %s." from)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1636 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1637 ((string-match "(.*).*(.*)" from)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1638 (message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1639 "Denied posting -- the From header looks strange: \"%s\"."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1640 from)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1641 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1642 (t t))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1643 ;; Check for long lines.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1644 (or (message-check-element 'long-lines)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1645 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1646 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1647 (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1648 (concat "^" (regexp-quote mail-header-separator) "$"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1649 (while (and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1650 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1651 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1652 (< (current-column) 80))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1653 (zerop (forward-line 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1654 (or (bolp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1655 (eobp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1656 (y-or-n-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1657 "You have lines longer than 79 characters. Really post? "))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1658 ;; Check whether the article is empty.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1659 (or (message-check-element 'empty)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1660 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1661 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1662 (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1663 (concat "^" (regexp-quote mail-header-separator) "$"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1664 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1665 (let ((b (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1666 (or (re-search-forward message-signature-separator nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1667 (goto-char (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1668 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1669 (or (re-search-backward "[^ \n\t]" b t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1670 (y-or-n-p "Empty article. Really post? ")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1671 ;; Check for control characters.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1672 (or (message-check-element 'control-chars)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1673 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1674 (if (re-search-forward "[\000-\007\013\015-\037\200-\237]" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1675 (y-or-n-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1676 "The article contains control characters. Really post? ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1677 t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1678 ;; Check excessive size.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1679 (or (message-check-element 'size)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1680 (if (> (buffer-size) 60000)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1681 (y-or-n-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1682 (format "The article is %d octets long. Really post? "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1683 (buffer-size)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1684 t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1685 ;; Check whether any new text has been added.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1686 (or (message-check-element 'new-text)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1687 (not message-checksum)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1688 (not (and (eq (message-checksum) (car message-checksum))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1689 (eq (buffer-size) (cdr message-checksum))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1690 (y-or-n-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1691 "It looks like no new text has been added. Really post? "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1692 ;; Check the length of the signature.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1693 (or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1694 (message-check-element 'signature)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1695 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1696 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1697 (if (or (not (re-search-backward "^-- $" nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1698 (search-forward message-forward-end-separator nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1699 t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1700 (if (> (count-lines (point) (point-max)) 5)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1701 (y-or-n-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1702 (format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1703 "Your .sig is %d lines; it should be max 4. Really post? "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1704 (count-lines (point) (point-max))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1705 t))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1706
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1707 (defun message-check-element (type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1708 "Returns non-nil if this type is not to be checked."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1709 (if (eq message-syntax-checks 'dont-check-for-anything-just-trust-me)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1710 t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1711 (let ((able (assq type message-syntax-checks)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1712 (and (consp able)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1713 (eq (cdr able) 'disabled)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1714
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1715 (defun message-checksum ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1716 "Return a \"checksum\" for the current buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1717 (let ((sum 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1718 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1719 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1720 (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1721 (concat "^" (regexp-quote mail-header-separator) "$"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1722 (while (not (eobp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1723 (when (not (looking-at "[ \t\n]"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1724 (setq sum (logxor (ash sum 1) (following-char))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1725 (forward-char 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1726 sum))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1727
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1728 (defun message-do-fcc ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1729 "Process Fcc headers in the current buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1730 (let ((case-fold-search t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1731 (buf (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1732 list file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1733 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1734 (set-buffer (get-buffer-create " *message temp*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1735 (buffer-disable-undo (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1736 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1737 (insert-buffer-substring buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1738 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1739 (message-narrow-to-headers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1740 (while (setq file (message-fetch-field "fcc"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1741 (push file list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1742 (message-remove-header "fcc" nil t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1743 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1744 (re-search-forward (concat "^" (regexp-quote mail-header-separator) "$"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1745 (replace-match "" t t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1746 ;; Process FCC operations.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1747 (while list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1748 (setq file (pop list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1749 (if (string-match "^[ \t]*|[ \t]*\\(.*\\)[ \t]*$" file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1750 ;; Pipe the article to the program in question.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1751 (call-process-region (point-min) (point-max) shell-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1752 nil nil nil shell-command-switch
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1753 (match-string 1 file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1754 ;; Save the article.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1755 (setq file (expand-file-name file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1756 (unless (file-exists-p (file-name-directory file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1757 (make-directory (file-name-directory file) t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1758 (if (and message-fcc-handler-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1759 (not (eq message-fcc-handler-function 'rmail-output)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1760 (funcall message-fcc-handler-function file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1761 (if (and (file-readable-p file) (mail-file-babyl-p file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1762 (rmail-output file 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1763 (let ((mail-use-rfc822 t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1764 (rmail-output file 1 t t))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1765 (kill-buffer (current-buffer)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1766
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1767 (defun message-cleanup-headers ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1768 "Do various automatic cleanups of the headers."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1769 ;; Remove empty lines in the header.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1770 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1771 (message-narrow-to-headers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1772 (while (re-search-forward "^[ \t]*\n" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1773 (replace-match "" t t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1774
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1775 ;; Correct Newsgroups and Followup-To headers: change sequence of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1776 ;; spaces to comma and eliminate spaces around commas. Eliminate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1777 ;; embedded line breaks.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1778 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1779 (while (re-search-forward "^\\(Newsgroups\\|Followup-To\\): +" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1780 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1781 (narrow-to-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1782 (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1783 (if (re-search-forward "^[^ \t]" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1784 (match-beginning 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1785 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1786 (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1787 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1788 (while (re-search-forward "\n[ \t]+" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1789 (replace-match " " t t)) ;No line breaks (too confusing)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1790 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1791 (while (re-search-forward "[ \t\n]*,[ \t\n]*\\|[ \t]+" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1792 (replace-match "," t t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1793 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1794 ;; Remove trailing commas.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1795 (when (re-search-forward ",+$" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1796 (replace-match "" t t)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1797
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1798 (defun message-make-date ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1799 "Make a valid data header."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1800 (let ((now (current-time)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1801 (timezone-make-date-arpa-standard
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1802 (current-time-string now) (current-time-zone now))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1803
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1804 (defun message-make-message-id ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1805 "Make a unique Message-ID."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1806 (concat "<" (message-unique-id)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1807 (let ((psubject (save-excursion (message-fetch-field "subject"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1808 (if (and message-reply-headers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1809 (mail-header-references message-reply-headers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1810 (mail-header-subject message-reply-headers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1811 psubject
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1812 (mail-header-subject message-reply-headers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1813 (not (string=
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1814 (message-strip-subject-re
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1815 (mail-header-subject message-reply-headers))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1816 (message-strip-subject-re psubject))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1817 "_-_" ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1818 "@" (message-make-fqdn) ">"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1819
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1820 (defvar message-unique-id-char nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1821
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1822 ;; If you ever change this function, make sure the new version
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1823 ;; cannot generate IDs that the old version could.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1824 ;; You might for example insert a "." somewhere (not next to another dot
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1825 ;; or string boundary), or modify the "fsf" string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1826 (defun message-unique-id ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1827 ;; Don't use microseconds from (current-time), they may be unsupported.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1828 ;; Instead we use this randomly inited counter.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1829 (setq message-unique-id-char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1830 (% (1+ (or message-unique-id-char (logand (random t) (1- (lsh 1 20)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1831 ;; (current-time) returns 16-bit ints,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1832 ;; and 2^16*25 just fits into 4 digits i base 36.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1833 (* 25 25)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1834 (let ((tm (current-time)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1835 (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1836 (if (memq system-type '(ms-dos emx vax-vms))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1837 (let ((user (downcase (user-login-name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1838 (while (string-match "[^a-z0-9_]" user)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1839 (aset user (match-beginning 0) ?_))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1840 user)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1841 (message-number-base36 (user-uid) -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1842 (message-number-base36 (+ (car tm)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1843 (lsh (% message-unique-id-char 25) 16)) 4)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1844 (message-number-base36 (+ (nth 1 tm)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1845 (lsh (/ message-unique-id-char 25) 16)) 4)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1846 ;; Append the newsreader name, because while the generated
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1847 ;; ID is unique to this newsreader, other newsreaders might
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1848 ;; otherwise generate the same ID via another algorithm.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1849 ".fsf")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1850
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1851 (defun message-number-base36 (num len)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1852 (if (if (< len 0) (<= num 0) (= len 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1853 ""
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1854 (concat (message-number-base36 (/ num 36) (1- len))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1855 (char-to-string (aref "zyxwvutsrqponmlkjihgfedcba9876543210"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1856 (% num 36))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1857
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1858 (defun message-make-organization ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1859 "Make an Organization header."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1860 (let* ((organization
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1861 (or (getenv "ORGANIZATION")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1862 (when message-user-organization
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1863 (if (message-functionp message-user-organization)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1864 (funcall message-user-organization)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1865 message-user-organization)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1866 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1867 (message-set-work-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1868 (cond ((stringp organization)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1869 (insert organization))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1870 ((and (eq t organization)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1871 message-user-organization-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1872 (file-exists-p message-user-organization-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1873 (insert-file-contents message-user-organization-file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1874 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1875 (while (re-search-forward "[\t\n]+" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1876 (replace-match "" t t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1877 (unless (zerop (buffer-size))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1878 (buffer-string)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1879
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1880 (defun message-make-lines ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1881 "Count the number of lines and return numeric string."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1882 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1883 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1884 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1885 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1886 (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1887 (concat "^" (regexp-quote mail-header-separator) "$"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1888 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1889 (int-to-string (count-lines (point) (point-max))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1890
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1891 (defun message-make-in-reply-to ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1892 "Return the In-Reply-To header for this message."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1893 (when message-reply-headers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1894 (let ((from (mail-header-from message-reply-headers))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1895 (date (mail-header-date message-reply-headers)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1896 (when from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1897 (let ((stop-pos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1898 (string-match " *at \\| *@ \\| *(\\| *<" from)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1899 (concat (if stop-pos (substring from 0 stop-pos) from)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1900 "'s message of "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1901 (if (or (not date) (string= date ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1902 "(unknown date)" date)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1903
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1904 (defun message-make-distribution ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1905 "Make a Distribution header."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1906 (let ((orig-distribution (message-fetch-reply-field "distribution")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1907 (cond ((message-functionp message-distribution-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1908 (funcall message-distribution-function))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1909 (t orig-distribution))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1910
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1911 (defun message-make-expires ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1912 "Return an Expires header based on `message-expires'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1913 (let ((current (current-time))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1914 (future (* 1.0 message-expires 60 60 24)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1915 ;; Add the future to current.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1916 (setcar current (+ (car current) (round (/ future (expt 2 16)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1917 (setcar (cdr current) (+ (nth 1 current) (% (round future) (expt 2 16))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1918 ;; Return the date in the future in UT.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1919 (timezone-make-date-arpa-standard
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1920 (current-time-string current) (current-time-zone current) '(0 "UT"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1921
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1922 (defun message-make-path ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1923 "Return uucp path."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1924 (let ((login-name (user-login-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1925 (cond ((null message-user-path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1926 (concat (system-name) "!" login-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1927 ((stringp message-user-path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1928 ;; Support GENERICPATH. Suggested by vixie@decwrl.dec.com.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1929 (concat message-user-path "!" login-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1930 (t login-name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1931
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1932 (defun message-make-from ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1933 "Make a From header."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1934 (let* ((login (message-make-address))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1935 (fullname
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1936 (or (and (boundp 'user-full-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1937 user-full-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1938 (user-full-name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1939 (when (string= fullname "&")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1940 (setq fullname (user-login-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1941 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1942 (message-set-work-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1943 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1944 ((or (null message-from-style)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1945 (equal fullname ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1946 (insert login))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1947 ((or (eq message-from-style 'angles)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1948 (and (not (eq message-from-style 'parens))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1949 ;; Use angles if no quoting is needed, or if parens would
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1950 ;; need quoting too.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1951 (or (not (string-match "[^- !#-'*+/-9=?A-Z^-~]" fullname))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1952 (let ((tmp (concat fullname nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1953 (while (string-match "([^()]*)" tmp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1954 (aset tmp (match-beginning 0) ?-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1955 (aset tmp (1- (match-end 0)) ?-))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1956 (string-match "[\\()]" tmp)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1957 (insert fullname)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1958 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1959 ;; Look for a character that cannot appear unquoted
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1960 ;; according to RFC 822.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1961 (when (re-search-forward "[^- !#-'*+/-9=?A-Z^-~]" nil 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1962 ;; Quote fullname, escaping specials.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1963 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1964 (insert "\"")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1965 (while (re-search-forward "[\"\\]" nil 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1966 (replace-match "\\\\\\&" t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1967 (insert "\""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1968 (insert " <" login ">"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1969 (t ; 'parens or default
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1970 (insert login " (")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1971 (let ((fullname-start (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1972 (insert fullname)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1973 (goto-char fullname-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1974 ;; RFC 822 says \ and nonmatching parentheses
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1975 ;; must be escaped in comments.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1976 ;; Escape every instance of ()\ ...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1977 (while (re-search-forward "[()\\]" nil 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1978 (replace-match "\\\\\\&" t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1979 ;; ... then undo escaping of matching parentheses,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1980 ;; including matching nested parentheses.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1981 (goto-char fullname-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1982 (while (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1983 "\\(\\=\\|[^\\]\\(\\\\\\\\\\)*\\)\\\\(\\(\\([^\\]\\|\\\\\\\\\\)*\\)\\\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1984 nil 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1985 (replace-match "\\1(\\3)" t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1986 (goto-char fullname-start)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1987 (insert ")")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1988 (buffer-string))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1989
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1990 (defun message-make-sender ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1991 "Return the \"real\" user address.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1992 This function tries to ignore all user modifications, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1993 give as trustworthy answer as possible."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1994 (concat (user-login-name) "@" (system-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1995
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1996 (defun message-make-address ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1997 "Make the address of the user."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1998 (or (message-user-mail-address)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1999 (concat (user-login-name) "@" (message-make-domain))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2000
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2001 (defun message-user-mail-address ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2002 "Return the pertinent part of `user-mail-address'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2003 (when user-mail-address
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2004 (nth 1 (mail-extract-address-components user-mail-address))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2005
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2006 (defun message-make-fqdn ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2007 "Return user's fully qualified domain name."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2008 (let ((system-name (system-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2009 (user-mail (message-user-mail-address)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2010 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2011 ((string-match "[^.]\\.[^.]" system-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2012 ;; `system-name' returned the right result.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2013 system-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2014 ;; Try `mail-host-address'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2015 ((and (boundp 'mail-host-address)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2016 (stringp mail-host-address)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2017 (string-match "\\." mail-host-address))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2018 mail-host-address)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2019 ;; We try `user-mail-address' as a backup.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2020 ((and (string-match "\\." user-mail)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2021 (string-match "@\\(.*\\)\\'" user-mail))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2022 (match-string 1 user-mail))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2023 ;; Default to this bogus thing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2024 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2025 (concat system-name ".i-have-a-misconfigured-system-so-shoot-me")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2026
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2027 (defun message-make-host-name ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2028 "Return the name of the host."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2029 (let ((fqdn (message-make-fqdn)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2030 (string-match "^[^.]+\\." fqdn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2031 (substring fqdn 0 (1- (match-end 0)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2032
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2033 (defun message-make-domain ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2034 "Return the domain name."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2035 (or mail-host-address
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2036 (message-make-fqdn)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2037
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2038 (defun message-generate-headers (headers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2039 "Prepare article HEADERS.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2040 Headers already prepared in the buffer are not modified."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2041 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2042 (message-narrow-to-headers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2043 (let* ((Date (message-make-date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2044 (Message-ID (message-make-message-id))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2045 (Organization (message-make-organization))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2046 (From (message-make-from))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2047 (Path (message-make-path))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2048 (Subject nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2049 (Newsgroups nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2050 (In-Reply-To (message-make-in-reply-to))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2051 (To nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2052 (Distribution (message-make-distribution))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2053 (Lines (message-make-lines))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2054 (X-Newsreader message-newsreader)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2055 (X-Mailer (and (not (message-fetch-field "X-Newsreader"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2056 message-mailer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2057 (Expires (message-make-expires))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2058 (case-fold-search t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2059 header value elem)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2060 ;; First we remove any old generated headers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2061 (let ((headers message-deletable-headers))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2062 (while headers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2063 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2064 (and (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2065 (concat "^" (symbol-name (car headers)) ": *") nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2066 (get-text-property (1+ (match-beginning 0)) 'message-deletable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2067 (message-delete-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2068 (pop headers)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2069 ;; Go through all the required headers and see if they are in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2070 ;; articles already. If they are not, or are empty, they are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2071 ;; inserted automatically - except for Subject, Newsgroups and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2072 ;; Distribution.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2073 (while headers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2074 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2075 (setq elem (pop headers))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2076 (if (consp elem)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2077 (if (eq (car elem) 'optional)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2078 (setq header (cdr elem))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2079 (setq header (car elem)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2080 (setq header elem))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2081 (when (or (not (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2082 (concat "^" (downcase (symbol-name header)) ":")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2083 nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2084 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2085 ;; The header was found. We insert a space after the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2086 ;; colon, if there is none.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2087 (if (/= (following-char) ? ) (insert " ") (forward-char 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2088 ;; Find out whether the header is empty...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2089 (looking-at "[ \t]*$")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2090 ;; So we find out what value we should insert.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2091 (setq value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2092 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2093 ((and (consp elem) (eq (car elem) 'optional))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2094 ;; This is an optional header. If the cdr of this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2095 ;; is something that is nil, then we do not insert
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2096 ;; this header.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2097 (setq header (cdr elem))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2098 (or (and (fboundp (cdr elem)) (funcall (cdr elem)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2099 (and (boundp (cdr elem)) (symbol-value (cdr elem)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2100 ((consp elem)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2101 ;; The element is a cons. Either the cdr is a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2102 ;; string to be inserted verbatim, or it is a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2103 ;; function, and we insert the value returned from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2104 ;; this function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2105 (or (and (stringp (cdr elem)) (cdr elem))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2106 (and (fboundp (cdr elem)) (funcall (cdr elem)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2107 ((and (boundp header) (symbol-value header))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2108 ;; The element is a symbol. We insert the value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2109 ;; of this symbol, if any.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2110 (symbol-value header))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2111 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2112 ;; We couldn't generate a value for this header,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2113 ;; so we just ask the user.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2114 (read-from-minibuffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2115 (format "Empty header for %s; enter value: " header)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2116 ;; Finally insert the header.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2117 (when (and value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2118 (not (equal value "")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2119 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2120 (if (bolp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2121 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2122 ;; This header didn't exist, so we insert it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2123 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2124 (insert (symbol-name header) ": " value "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2125 (forward-line -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2126 ;; The value of this header was empty, so we clear
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2127 ;; totally and insert the new value.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2128 (delete-region (point) (message-point-at-eol))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2129 (insert value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2130 ;; Add the deletable property to the headers that require it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2131 (and (memq header message-deletable-headers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2132 (progn (beginning-of-line) (looking-at "[^:]+: "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2133 (add-text-properties
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2134 (point) (match-end 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2135 '(message-deletable t face italic) (current-buffer)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2136 ;; Insert new Sender if the From is strange.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2137 (let ((from (message-fetch-field "from"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2138 (sender (message-fetch-field "sender"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2139 (secure-sender (message-make-sender)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2140 (when (and from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2141 (not (message-check-element 'sender))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2142 (not (string=
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2143 (downcase
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2144 (cadr (mail-extract-address-components from)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2145 (downcase secure-sender)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2146 (or (null sender)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2147 (not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2148 (string=
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2149 (downcase
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2150 (cadr (mail-extract-address-components sender)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2151 (downcase secure-sender)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2152 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2153 ;; Rename any old Sender headers to Original-Sender.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2154 (when (re-search-forward "^Sender:" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2155 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2156 (insert "Original-")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2157 (beginning-of-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2158 (insert "Sender: " secure-sender "\n"))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2159
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2160 (defun message-insert-courtesy-copy ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2161 "Insert a courtesy message in mail copies of combined messages."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2162 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2163 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2164 (message-narrow-to-headers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2165 (let ((newsgroups (message-fetch-field "newsgroups")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2166 (when newsgroups
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2167 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2168 (insert "Posted-To: " newsgroups "\n"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2169 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2170 (insert message-courtesy-message)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2171
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2172 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2173 ;;; Setting up a message buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2174 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2175
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2176 (defun message-fill-address (header value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2177 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2178 (narrow-to-region (point) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2179 (insert (capitalize (symbol-name header))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2180 ": "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2181 (if (consp value) (car value) value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2182 "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2183 (narrow-to-region (point-min) (1- (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2184 (let (quoted last)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2185 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2186 (while (not (eobp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2187 (skip-chars-forward "^,\"" (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2188 (if (or (= (following-char) ?,)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2189 (eobp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2190 (when (not quoted)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2191 (if (and (> (current-column) 78)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2192 last)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2193 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2194 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2195 (goto-char last)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2196 (insert "\n\t"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2197 (setq last (1+ (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2198 (setq last (1+ (point)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2199 (setq quoted (not quoted)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2200 (unless (eobp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2201 (forward-char 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2202 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2203 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2204 (forward-line 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2205
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2206 (defun message-fill-header (header value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2207 (let ((begin (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2208 (fill-column 78)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2209 (fill-prefix "\t"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2210 (insert (capitalize (symbol-name header))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2211 ": "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2212 (if (consp value) (car value) value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2213 "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2214 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2215 (narrow-to-region begin (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2216 (fill-region-as-paragraph begin (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2217 ;; Tapdance around looong Message-IDs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2218 (forward-line -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2219 (when (looking-at "[ \t]*$")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2220 (message-delete-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2221 (goto-char begin)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2222 (re-search-forward ":" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2223 (when (looking-at "\n[ \t]+")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2224 (replace-match " " t t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2225 (goto-char (point-max)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2226
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2227 (defun message-position-point ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2228 "Move point to where the user probably wants to find it."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2229 (message-narrow-to-headers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2230 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2231 ((re-search-forward "^[^:]+:[ \t]*$" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2232 (search-backward ":" )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2233 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2234 (forward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2235 (if (= (following-char) ? )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2236 (forward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2237 (insert " ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2238 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2239 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2240 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2241 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2242 (unless (looking-at "$")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2243 (forward-line 2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2244 (sit-for 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2245
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2246 (defun message-buffer-name (type &optional to group)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2247 "Return a new (unique) buffer name based on TYPE and TO."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2248 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2249 ;; Check whether `message-generate-new-buffers' is a function,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2250 ;; and if so, call it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2251 ((message-functionp message-generate-new-buffers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2252 (funcall message-generate-new-buffers type to group))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2253 ;; Generate a new buffer name The Message Way.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2254 (message-generate-new-buffers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2255 (generate-new-buffer-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2256 (concat "*" type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2257 (if to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2258 (concat " to "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2259 (or (car (mail-extract-address-components to))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2260 to) "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2261 "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2262 (if (and group (not (string= group ""))) (concat " on " group) "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2263 "*")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2264 ;; Use standard name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2265 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2266 (format "*%s message*" type))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2267
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2268 (defun message-pop-to-buffer (name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2269 "Pop to buffer NAME, and warn if it already exists and is modified."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2270 (let ((buffer (get-buffer name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2271 (if (and buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2272 (buffer-name buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2273 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2274 (set-buffer (pop-to-buffer buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2275 (when (and (buffer-modified-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2276 (not (y-or-n-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2277 "Message already being composed; erase? ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2278 (error "Message being composed")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2279 (set-buffer (pop-to-buffer name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2280 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2281 (message-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2282
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2283 (defun message-do-send-housekeeping ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2284 "Kill old message buffers."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2285 ;; We might have sent this buffer already. Delete it from the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2286 ;; list of buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2287 (setq message-buffer-list (delq (current-buffer) message-buffer-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2288 (when (and message-max-buffers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2289 (>= (length message-buffer-list) message-max-buffers))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2290 ;; Kill the oldest buffer -- unless it has been changed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2291 (let ((buffer (pop message-buffer-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2292 (when (and (buffer-name buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2293 (not (buffer-modified-p buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2294 (kill-buffer buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2295 ;; Rename the buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2296 (if message-send-rename-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2297 (funcall message-send-rename-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2298 (when (string-match "\\`\\*" (buffer-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2299 (rename-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2300 (concat "*sent " (substring (buffer-name) (match-end 0))) t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2301 ;; Push the current buffer onto the list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2302 (when message-max-buffers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2303 (setq message-buffer-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2304 (nconc message-buffer-list (list (current-buffer))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2305
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2306 (defvar mc-modes-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2307 (defun message-setup (headers &optional replybuffer actions)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2308 (when (and (boundp 'mc-modes-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2309 (not (assq 'message-mode mc-modes-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2310 (push '(message-mode (encrypt . mc-encrypt-message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2311 (sign . mc-sign-message))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2312 mc-modes-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2313 (when actions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2314 (setq message-send-actions actions))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2315 (setq message-reply-buffer replybuffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2316 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2317 ;; Insert all the headers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2318 (mail-header-format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2319 (let ((h headers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2320 (alist message-header-format-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2321 (while h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2322 (unless (assq (caar h) message-header-format-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2323 (push (list (caar h)) alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2324 (pop h))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2325 alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2326 headers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2327 (delete-region (point) (progn (forward-line -1) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2328 (when message-default-headers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2329 (insert message-default-headers))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2330 (put-text-property
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2331 (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2332 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2333 (insert mail-header-separator "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2334 (1- (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2335 'read-only nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2336 (forward-line -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2337 (when (message-news-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2338 (when message-default-news-headers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2339 (insert message-default-news-headers))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2340 (when message-generate-headers-first
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2341 (message-generate-headers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2342 (delq 'Lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2343 (delq 'Subject
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2344 (copy-sequence message-required-news-headers))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2345 (when (message-mail-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2346 (when message-default-mail-headers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2347 (insert message-default-mail-headers))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2348 (when message-generate-headers-first
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2349 (message-generate-headers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2350 (delq 'Lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2351 (delq 'Subject
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2352 (copy-sequence message-required-mail-headers))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2353 (run-hooks 'message-signature-setup-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2354 (message-insert-signature)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2355 (message-set-auto-save-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2356 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2357 (message-narrow-to-headers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2358 (run-hooks 'message-header-setup-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2359 (set-buffer-modified-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2360 (run-hooks 'message-setup-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2361 (message-position-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2362 (undo-boundary))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2363
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2364 (defun message-set-auto-save-file-name ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2365 "Associate the message buffer with a file in the drafts directory."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2366 (when message-autosave-directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2367 (unless (file-exists-p message-autosave-directory)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2368 (make-directory message-autosave-directory t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2369 (let ((name (make-temp-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2370 (concat (file-name-as-directory message-autosave-directory)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2371 "msg."))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2372 (setq buffer-auto-save-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2373 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2374 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2375 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2376 (set-buffer (get-buffer-create " *draft tmp*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2377 (setq buffer-file-name name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2378 (make-auto-save-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2379 (kill-buffer (current-buffer)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2380 (clear-visited-file-modtime))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2381
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2382
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2383
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2384 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2385 ;;; Commands for interfacing with message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2386 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2387
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2388 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2389 (defun message-mail (&optional to subject)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2390 "Start editing a mail message to be sent."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2391 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2392 (message-pop-to-buffer (message-buffer-name "mail" to))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2393 (message-setup `((To . ,(or to "")) (Subject . ,(or subject "")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2394
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2395 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2396 (defun message-news (&optional newsgroups subject)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2397 "Start editing a news article to be sent."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2398 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2399 (message-pop-to-buffer (message-buffer-name "news" nil newsgroups))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2400 (message-setup `((Newsgroups . ,(or newsgroups ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2401 (Subject . ,(or subject "")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2402
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2403 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2404 (defun message-reply (&optional to-address wide ignore-reply-to)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2405 "Start editing a reply to the article in the current buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2406 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2407 (let ((cur (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2408 from subject date reply-to to cc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2409 references message-id follow-to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2410 mct never-mct gnus-warning)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2411 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2412 (narrow-to-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2413 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2414 (if (search-forward "\n\n" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2415 (1- (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2416 (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2417 ;; Allow customizations to have their say.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2418 (if (not wide)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2419 ;; This is a regular reply.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2420 (if (message-functionp message-reply-to-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2421 (setq follow-to (funcall message-reply-to-function)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2422 ;; This is a followup.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2423 (if (message-functionp message-wide-reply-to-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2424 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2425 (setq follow-to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2426 (funcall message-wide-reply-to-function)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2427 ;; Find all relevant headers we need.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2428 (setq from (message-fetch-field "from")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2429 date (message-fetch-field "date")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2430 subject (or (message-fetch-field "subject") "none")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2431 to (message-fetch-field "to")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2432 cc (message-fetch-field "cc")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2433 mct (message-fetch-field "mail-copies-to")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2434 reply-to (unless ignore-reply-to (message-fetch-field "reply-to"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2435 references (message-fetch-field "references")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2436 message-id (message-fetch-field "message-id"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2437 ;; Remove any (buggy) Re:'s that are present and make a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2438 ;; proper one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2439 (when (string-match "^[ \t]*[Rr][Ee]:[ \t]*" subject)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2440 (setq subject (substring subject (match-end 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2441 (setq subject (concat "Re: " subject))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2442
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2443 (when (and (setq gnus-warning (message-fetch-field "gnus-warning"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2444 (string-match "<[^>]+>" gnus-warning))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2445 (setq message-id (match-string 0 gnus-warning)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2446
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2447 ;; Handle special values of Mail-Copies-To.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2448 (when mct
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2449 (cond ((equal (downcase mct) "never")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2450 (setq never-mct t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2451 (setq mct nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2452 ((equal (downcase mct) "always")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2453 (setq mct (or reply-to from)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2454
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2455 (unless follow-to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2456 (if (or (not wide)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2457 to-address)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2458 (setq follow-to (list (cons 'To (or to-address reply-to from))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2459 (let (ccalist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2460 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2461 (message-set-work-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2462 (unless never-mct
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2463 (insert (or reply-to from "")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2464 (insert
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2465 (if (bolp) "" ", ") (or to "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2466 (if mct (concat (if (bolp) "" ", ") mct) "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2467 (if cc (concat (if (bolp) "" ", ") cc) ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2468 ;; Remove addresses that match `rmail-dont-reply-to-names'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2469 (insert (prog1 (rmail-dont-reply-to (buffer-string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2470 (erase-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2471 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2472 (setq ccalist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2473 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2474 (lambda (addr)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2475 (cons (mail-strip-quoted-names addr) addr))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2476 (nreverse (mail-parse-comma-list))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2477 (let ((s ccalist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2478 (while s
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2479 (setq ccalist (delq (assoc (car (pop s)) s) ccalist)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2480 (setq follow-to (list (cons 'To (cdr (pop ccalist)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2481 (when ccalist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2482 (push (cons 'Cc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2483 (mapconcat (lambda (addr) (cdr addr)) ccalist ", "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2484 follow-to)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2485 (widen))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2486
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2487 (message-pop-to-buffer (message-buffer-name "reply" from))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2488
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2489 (setq message-reply-headers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2490 (vector 0 subject from date message-id references 0 0 ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2491
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2492 (message-setup
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2493 `((Subject . ,subject)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2494 ,@follow-to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2495 ,@(if (or references message-id)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2496 `((References . ,(concat (or references "") (and references " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2497 (or message-id ""))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2498 nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2499 cur)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2500
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2501 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2502 (defun message-wide-reply (&optional to-address)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2503 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2504 (message-reply to-address t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2505
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2506 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2507 (defun message-followup ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2508 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2509 (let ((cur (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2510 from subject date reply-to mct
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2511 references message-id follow-to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2512 followup-to distribution newsgroups gnus-warning)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2513 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2514 (narrow-to-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2515 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2516 (if (search-forward "\n\n" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2517 (1- (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2518 (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2519 (when (message-functionp message-followup-to-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2520 (setq follow-to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2521 (funcall message-followup-to-function)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2522 (setq from (message-fetch-field "from")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2523 date (message-fetch-field "date")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2524 subject (or (message-fetch-field "subject") "none")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2525 references (message-fetch-field "references")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2526 message-id (message-fetch-field "message-id")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2527 followup-to (message-fetch-field "followup-to")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2528 newsgroups (message-fetch-field "newsgroups")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2529 reply-to (message-fetch-field "reply-to")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2530 distribution (message-fetch-field "distribution")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2531 mct (message-fetch-field "mail-copies-to"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2532 (when (and (setq gnus-warning (message-fetch-field "gnus-warning"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2533 (string-match "<[^>]+>" gnus-warning))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2534 (setq message-id (match-string 0 gnus-warning)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2535 ;; Remove bogus distribution.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2536 (and (stringp distribution)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2537 (string-match "world" distribution)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2538 (setq distribution nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2539 ;; Remove any (buggy) Re:'s that are present and make a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2540 ;; proper one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2541 (when (string-match "^[ \t]*[Rr][Ee]:[ \t]*" subject)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2542 (setq subject (substring subject (match-end 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2543 (setq subject (concat "Re: " subject))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2544 (widen))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2545
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2546 (message-pop-to-buffer (message-buffer-name "followup" from newsgroups))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2547
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2548 (message-setup
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2549 `((Subject . ,subject)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2550 ,@(cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2551 (follow-to follow-to)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2552 ((and followup-to message-use-followup-to)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2553 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2554 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2555 ((equal (downcase followup-to) "poster")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2556 (if (or (eq message-use-followup-to 'use)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2557 (message-y-or-n-p "Obey Followup-To: poster? " t "\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2558 You should normally obey the Followup-To: header.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2559
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2560 `Followup-To: poster' sends your response via e-mail instead of news.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2561
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2562 A typical situation where `Followup-To: poster' is used is when the poster
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2563 does not read the newsgroup, so he wouldn't see any replies sent to it."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2564 (cons 'To (or reply-to from ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2565 (cons 'Newsgroups newsgroups)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2566 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2567 (if (or (equal followup-to newsgroups)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2568 (not (eq message-use-followup-to 'ask))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2569 (message-y-or-n-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2570 (concat "Obey Followup-To: " followup-to "? ") t "\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2571 You should normally obey the Followup-To: header.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2572
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2573 `Followup-To: " followup-to "'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2574 directs your response to " (if (string-match "," followup-to)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2575 "the specified newsgroups"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2576 "that newsgroup only") ".
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2577
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2578 If a message is posted to several newsgroups, Followup-To is often
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2579 used to direct the following discussion to one newsgroup only,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2580 because discussions that are spread over several newsgroup tend to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2581 be fragmented and very difficult to follow.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2582
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2583 Also, some source/announcment newsgroups are not indented for discussion;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2584 responses here are directed to other newsgroups."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2585 (cons 'Newsgroups followup-to)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2586 (cons 'Newsgroups newsgroups))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2587 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2588 `((Newsgroups . ,newsgroups))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2589 ,@(and distribution (list (cons 'Distribution distribution)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2590 (References . ,(concat (or references "") (and references " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2591 (or message-id "")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2592 ,@(when (and mct
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2593 (not (equal (downcase mct) "never")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2594 (list (cons 'Cc (if (equal (downcase mct) "always")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2595 (or reply-to from "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2596 mct)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2597
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2598 cur)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2599
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2600 (setq message-reply-headers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2601 (vector 0 subject from date message-id references 0 0 ""))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2602
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2603
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2604 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2605 (defun message-cancel-news ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2606 "Cancel an article you posted."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2607 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2608 (unless (message-news-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2609 (error "This is not a news article; canceling is impossible"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2610 (when (yes-or-no-p "Do you really want to cancel this article? ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2611 (let (from newsgroups message-id distribution buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2612 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2613 ;; Get header info. from original article.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2614 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2615 (message-narrow-to-head)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2616 (setq from (message-fetch-field "from")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2617 newsgroups (message-fetch-field "newsgroups")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2618 message-id (message-fetch-field "message-id")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2619 distribution (message-fetch-field "distribution")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2620 ;; Make sure that this article was written by the user.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2621 (unless (string-equal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2622 (downcase (cadr (mail-extract-address-components from)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2623 (downcase (message-make-address)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2624 (error "This article is not yours"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2625 ;; Make control message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2626 (setq buf (set-buffer (get-buffer-create " *message cancel*")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2627 (buffer-disable-undo (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2628 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2629 (insert "Newsgroups: " newsgroups "\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2630 "From: " (message-make-from) "\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2631 "Subject: cmsg cancel " message-id "\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2632 "Control: cancel " message-id "\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2633 (if distribution
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2634 (concat "Distribution: " distribution "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2635 "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2636 mail-header-separator "\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2637 "This is a cancel message from " from ".\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2638 (message "Canceling your article...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2639 (let ((message-syntax-checks 'dont-check-for-anything-just-trust-me))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2640 (funcall message-send-news-function))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2641 (message "Canceling your article...done")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2642 (kill-buffer buf)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2643
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2644 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2645 (defun message-supersede ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2646 "Start composing a message to supersede the current message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2647 This is done simply by taking the old article and adding a Supersedes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2648 header line with the old Message-ID."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2649 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2650 (let ((cur (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2651 ;; Check whether the user owns the article that is to be superseded.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2652 (unless (string-equal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2653 (downcase (cadr (mail-extract-address-components
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2654 (message-fetch-field "from"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2655 (downcase (message-make-address)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2656 (error "This article is not yours"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2657 ;; Get a normal message buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2658 (message-pop-to-buffer (message-buffer-name "supersede"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2659 (insert-buffer-substring cur)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2660 (message-narrow-to-head)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2661 ;; Remove unwanted headers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2662 (when message-ignored-supersedes-headers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2663 (message-remove-header message-ignored-supersedes-headers t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2664 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2665 (if (not (re-search-forward "^Message-ID: " nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2666 (error "No Message-ID in this article")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2667 (replace-match "Supersedes: " t t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2668 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2669 (insert mail-header-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2670 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2671 (forward-line 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2672
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2673 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2674 (defun message-recover ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2675 "Reread contents of current buffer from its last auto-save file."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2676 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2677 (let ((file-name (make-auto-save-file-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2678 (cond ((save-window-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2679 (if (not (eq system-type 'vax-vms))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2680 (with-output-to-temp-buffer "*Directory*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2681 (buffer-disable-undo standard-output)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2682 (let ((default-directory "/"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2683 (call-process
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2684 "ls" nil standard-output nil "-l" file-name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2685 (yes-or-no-p (format "Recover auto save file %s? " file-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2686 (let ((buffer-read-only nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2687 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2688 (insert-file-contents file-name nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2689 (t (error "message-recover cancelled")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2690
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2691 ;;; Forwarding messages.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2692
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2693 (defun message-make-forward-subject ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2694 "Return a Subject header suitable for the message in the current buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2695 (concat "[" (or (message-fetch-field (if (message-news-p) "newsgroups" "from"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2696 "(nowhere)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2697 "] " (or (message-fetch-field "Subject") "")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2698
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2699 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2700 (defun message-forward (&optional news)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2701 "Forward the current message via mail.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2702 Optional NEWS will use news to forward instead of mail."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2703 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2704 (let ((cur (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2705 (subject (message-make-forward-subject)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2706 (if news (message-news nil subject) (message-mail nil subject))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2707 ;; Put point where we want it before inserting the forwarded
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2708 ;; message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2709 (if message-signature-before-forwarded-message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2710 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2711 (message-goto-body))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2712 ;; Make sure we're at the start of the line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2713 (unless (eolp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2714 (insert "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2715 ;; Narrow to the area we are to insert.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2716 (narrow-to-region (point) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2717 ;; Insert the separators and the forwarded buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2718 (insert message-forward-start-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2719 (insert-buffer-substring cur)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2720 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2721 (insert message-forward-end-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2722 (set-text-properties (point-min) (point-max) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2723 ;; Remove all unwanted headers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2724 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2725 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2726 (narrow-to-region (point) (if (search-forward "\n\n" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2727 (1- (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2728 (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2729 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2730 (message-remove-header message-included-forward-headers t nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2731 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2732 (message-position-point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2733
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2734 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2735 (defun message-resend (address)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2736 "Resend the current article to ADDRESS."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2737 (interactive "sResend message to: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2738 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2739 (let ((cur (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2740 beg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2741 ;; We first set up a normal mail buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2742 (set-buffer (get-buffer-create " *message resend*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2743 (buffer-disable-undo (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2744 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2745 (message-setup `((To . ,address)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2746 ;; Insert our usual headers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2747 (message-generate-headers '(From Date To))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2748 (message-narrow-to-headers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2749 ;; Rename them all to "Resent-*".
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2750 (while (re-search-forward "^[A-Za-z]" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2751 (forward-char -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2752 (insert "Resent-"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2753 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2754 (forward-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2755 (delete-region (point) (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2756 (setq beg (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2757 ;; Insert the message to be resent.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2758 (insert-buffer-substring cur)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2759 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2760 (search-forward "\n\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2761 (forward-char -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2762 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2763 (narrow-to-region beg (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2764 (message-remove-header message-ignored-resent-headers t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2765 (goto-char (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2766 (insert mail-header-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2767 ;; Rename all old ("Also-")Resent headers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2768 (while (re-search-backward "^\\(Also-\\)?Resent-" beg t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2769 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2770 (insert "Also-"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2771 ;; Send it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2772 (message-send-mail)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2773 (kill-buffer (current-buffer)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2774
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2775 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2776 (defun message-bounce ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2777 "Re-mail the current message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2778 This only makes sense if the current message is a bounce message than
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2779 contains some mail you have written which has been bounced back to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2780 you."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2781 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2782 (let ((cur (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2783 boundary)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2784 (message-pop-to-buffer (message-buffer-name "bounce"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2785 (insert-buffer-substring cur)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2786 (undo-boundary)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2787 (message-narrow-to-head)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2788 (if (and (message-fetch-field "Mime-Version")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2789 (setq boundary (message-fetch-field "Content-Type")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2790 (if (string-match "boundary=\"\\([^\"]+\\)\"" boundary)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2791 (setq boundary (concat (match-string 1 boundary) " *\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2792 "Content-Type: message/rfc822"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2793 (setq boundary nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2794 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2795 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2796 (search-forward "\n\n" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2797 (or (and boundary
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2798 (re-search-forward boundary nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2799 (forward-line 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2800 (and (re-search-forward message-unsent-separator nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2801 (forward-line 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2802 (and (search-forward "\n\n" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2803 (re-search-forward "^Return-Path:.*\n" nil t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2804 ;; We remove everything before the bounced mail.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2805 (delete-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2806 (point-min)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2807 (if (re-search-forward "^[^ \n\t]+:" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2808 (match-beginning 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2809 (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2810 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2811 (message-narrow-to-head)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2812 (message-remove-header message-ignored-bounced-headers t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2813 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2814 (insert mail-header-separator))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2815 (message-position-point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2816
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2817 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2818 ;;; Interactive entry points for new message buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2819 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2820
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2821 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2822 (defun message-mail-other-window (&optional to subject)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2823 "Like `message-mail' command, but display mail buffer in another window."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2824 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2825 (let ((pop-up-windows t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2826 (special-display-buffer-names nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2827 (special-display-regexps nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2828 (same-window-buffer-names nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2829 (same-window-regexps nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2830 (message-pop-to-buffer (message-buffer-name "mail" to)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2831 (message-setup `((To . ,(or to "")) (Subject . ,(or subject "")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2832
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2833 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2834 (defun message-mail-other-frame (&optional to subject)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2835 "Like `message-mail' command, but display mail buffer in another frame."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2836 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2837 (let ((pop-up-frames t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2838 (special-display-buffer-names nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2839 (special-display-regexps nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2840 (same-window-buffer-names nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2841 (same-window-regexps nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2842 (message-pop-to-buffer (message-buffer-name "mail" to)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2843 (message-setup `((To . ,(or to "")) (Subject . ,(or subject "")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2844
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2845 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2846 (defun message-news-other-window (&optional newsgroups subject)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2847 "Start editing a news article to be sent."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2848 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2849 (let ((pop-up-windows t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2850 (special-display-buffer-names nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2851 (special-display-regexps nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2852 (same-window-buffer-names nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2853 (same-window-regexps nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2854 (message-pop-to-buffer (message-buffer-name "news" nil newsgroups)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2855 (message-setup `((Newsgroups . ,(or newsgroups ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2856 (Subject . ,(or subject "")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2857
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2858 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2859 (defun message-news-other-frame (&optional newsgroups subject)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2860 "Start editing a news article to be sent."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2861 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2862 (let ((pop-up-frames t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2863 (special-display-buffer-names nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2864 (special-display-regexps nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2865 (same-window-buffer-names nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2866 (same-window-regexps nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2867 (message-pop-to-buffer (message-buffer-name "news" nil newsgroups)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2868 (message-setup `((Newsgroups . ,(or newsgroups ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2869 (Subject . ,(or subject "")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2870
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2871 ;;; underline.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2872
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2873 ;; This code should be moved to underline.el (from which it is stolen).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2874
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2875 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2876 (defun bold-region (start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2877 "Bold all nonblank characters in the region.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2878 Works by overstriking characters.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2879 Called from program, takes two arguments START and END
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2880 which specify the range to operate on."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2881 (interactive "r")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2882 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2883 (let ((end1 (make-marker)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2884 (move-marker end1 (max start end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2885 (goto-char (min start end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2886 (while (< (point) end1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2887 (or (looking-at "[_\^@- ]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2888 (insert (following-char) "\b"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2889 (forward-char 1)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2890
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2891 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2892 (defun unbold-region (start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2893 "Remove all boldness (overstruck characters) in the region.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2894 Called from program, takes two arguments START and END
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2895 which specify the range to operate on."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2896 (interactive "r")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2897 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2898 (let ((end1 (make-marker)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2899 (move-marker end1 (max start end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2900 (goto-char (min start end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2901 (while (re-search-forward "\b" end1 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2902 (if (eq (following-char) (char-after (- (point) 2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2903 (delete-char -2))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2904
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2905 (fset 'message-exchange-point-and-mark 'exchange-point-and-mark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2906
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2907 ;; Support for toolbar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2908 (when (string-match "XEmacs\\|Lucid" emacs-version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2909 (require 'messagexmas))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2910
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2911 ;;; Group name completion.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2912
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2913 (defvar message-newgroups-header-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2914 "^\\(Newsgroups\\|Followup-To\\|Posted-To\\):"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2915 "Regexp that match headers that lists groups.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2916
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2917 (defun message-tab ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2918 "Expand group names in Newsgroups and Followup-To headers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2919 Do a `tab-to-tab-stop' if not in those headers."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2920 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2921 (if (let ((mail-abbrev-mode-regexp message-newgroups-header-regexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2922 (mail-abbrev-in-expansion-header-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2923 (message-expand-group)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2924 (tab-to-tab-stop)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2925
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2926 (defvar gnus-active-hashtb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2927 (defun message-expand-group ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2928 (let* ((b (save-excursion (skip-chars-backward "^, :\t\n") (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2929 (completion-ignore-case t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2930 (string (buffer-substring b (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2931 (hashtb (and (boundp 'gnus-active-hashtb) gnus-active-hashtb))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2932 (completions (all-completions string hashtb))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2933 (cur (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2934 comp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2935 (delete-region b (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2936 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2937 ((= (length completions) 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2938 (if (string= (car completions) string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2939 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2940 (insert string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2941 (message "Only matching group"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2942 (insert (car completions))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2943 ((and (setq comp (try-completion string hashtb))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2944 (not (string= comp string)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2945 (insert comp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2946 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2947 (insert string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2948 (if (not comp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2949 (message "No matching groups")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2950 (pop-to-buffer "*Completions*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2951 (buffer-disable-undo (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2952 (let ((buffer-read-only nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2953 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2954 (let ((standard-output (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2955 (display-completion-list (sort completions 'string<)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2956 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2957 (pop-to-buffer cur)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2958
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2959 ;;; Help stuff.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2960
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2961 (defmacro message-y-or-n-p (question show &rest text)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2962 "Ask QUESTION, displaying the rest of the arguments in a temporary buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2963 `(message-talkative-question 'y-or-n-p ,question ,show ,@text))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2964
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2965 (defun message-talkative-question (ask question show &rest text)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2966 "Call FUNCTION with argument QUESTION, displaying the rest of the arguments in a temporary buffer if SHOW.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2967 The following arguments may contain lists of values."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2968 (if (and show
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2969 (setq text (message-flatten-list text)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2970 (save-window-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2971 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2972 (with-output-to-temp-buffer " *MESSAGE information message*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2973 (set-buffer " *MESSAGE information message*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2974 (mapcar 'princ text)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2975 (goto-char (point-min))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2976 (funcall ask question))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2977 (funcall ask question)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2978
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2979 (defun message-flatten-list (&rest list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2980 (message-flatten-list-1 list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2981
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2982 (defun message-flatten-list-1 (list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2983 (cond ((consp list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2984 (apply 'append (mapcar 'message-flatten-list-1 list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2985 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2986 (list list))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2987
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2988 (run-hooks 'message-load-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2989
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2990 (provide 'message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2991
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2992 ;;; message.el ends here