message.el 235 KB
Newer Older
1 2
;;; message.el --- composing mail and news messages
;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
3
;;        Free Software Foundation, Inc.
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
4

5
;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
;; Keywords: mail, news

;; This file is part of GNU Emacs.

;; GNU Emacs is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.

;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING.  If not, write to the
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.

;;; Commentary:

;; This mode provides mail-sending facilities from within Emacs.  It
;; consists mainly of large chunks of code from the sendmail.el,
;; gnus-msg.el and rnewspost.el files.

;;; Code:

33 34
(eval-when-compile
  (require 'cl)
35 36 37
  (defvar gnus-message-group-art)
  (defvar gnus-list-identifiers)) ; gnus-sum is required where necessary
(require 'canlock)
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
38 39
(require 'mailheader)
(require 'nnheader)
40 41 42
;; This is apparently necessary even though things are autoloaded.
;; Because we dynamically bind mail-abbrev-mode-regexp, we'd better
;; require mailabbrev here.
43
(if (featurep 'xemacs)
44 45
    (require 'mail-abbrevs)
  (require 'mailabbrev))
46 47
(require 'mail-parse)
(require 'mml)
48 49 50 51 52
(require 'rfc822)
(eval-and-compile
  (autoload 'gnus-find-method-for-group "gnus")
  (autoload 'nnvirtual-find-group-art "nnvirtual")
  (autoload 'gnus-group-decoded-name "gnus-group"))
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124

(defgroup message '((user-mail-address custom-variable)
		    (user-full-name custom-variable))
  "Mail and news message composing."
  :link '(custom-manual "(message)Top")
  :group 'mail
  :group 'news)

(put 'user-mail-address 'custom-type 'string)
(put 'user-full-name 'custom-type 'string)

(defgroup message-various nil
  "Various Message Variables"
  :link '(custom-manual "(message)Various Message Variables")
  :group 'message)

(defgroup message-buffers nil
  "Message Buffers"
  :link '(custom-manual "(message)Message Buffers")
  :group 'message)

(defgroup message-sending nil
  "Message Sending"
  :link '(custom-manual "(message)Sending Variables")
  :group 'message)

(defgroup message-interface nil
  "Message Interface"
  :link '(custom-manual "(message)Interface")
  :group 'message)

(defgroup message-forwarding nil
  "Message Forwarding"
  :link '(custom-manual "(message)Forwarding")
  :group 'message-interface)

(defgroup message-insertion nil
  "Message Insertion"
  :link '(custom-manual "(message)Insertion")
  :group 'message)

(defgroup message-headers nil
  "Message Headers"
  :link '(custom-manual "(message)Message Headers")
  :group 'message)

(defgroup message-news nil
  "Composing News Messages"
  :group 'message)

(defgroup message-mail nil
  "Composing Mail Messages"
  :group 'message)

(defgroup message-faces nil
  "Faces used for message composing."
  :group 'message
  :group 'faces)

(defcustom message-directory "~/Mail/"
  "*Directory from which all other mail file variables are derived."
  :group 'message-various
  :type 'directory)

(defcustom message-max-buffers 10
  "*How many buffers to keep before starting to kill them off."
  :group 'message-buffers
  :type 'integer)

(defcustom message-send-rename-function nil
  "Function called to rename the buffer after sending it."
  :group 'message-buffers
Dave Love's avatar
Dave Love committed
125
  :type '(choice function (const nil)))
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
126 127 128 129 130 131 132 133 134 135

(defcustom message-fcc-handler-function 'message-output
  "*A function called to save outgoing articles.
This function will be called with the name of the file to store the
article in.  The default function is `message-output' which saves in Unix
mailbox format."
  :type '(radio (function-item message-output)
		(function :tag "Other"))
  :group 'message-sending)

136 137
(defcustom message-fcc-externalize-attachments nil
  "If non-nil, attachments are included as external parts in Fcc copies."
138
  :version "21.4"
139 140 141
  :type 'boolean
  :group 'message-sending)

Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
142 143 144 145 146 147 148
(defcustom message-courtesy-message
  "The following message is a courtesy copy of an article\nthat has been posted to %s as well.\n\n"
  "*This is inserted at the start of a mailed copy of a posted message.
If the string contains the format spec \"%s\", the Newsgroups
the article has been posted to will be inserted there.
If this variable is nil, no such courtesy message will be added."
  :group 'message-sending
149
  :type '(radio (string :format "%t: %v\n" :size 0) (const nil)))
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
150

151 152
(defcustom message-ignored-bounced-headers
  "^\\(Received\\|Return-Path\\|Delivered-To\\):"
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
153 154 155 156 157 158 159 160
  "*Regexp that matches headers to be removed in resent bounced mail."
  :group 'message-interface
  :type 'regexp)

;;;###autoload
(defcustom message-from-style 'default
  "*Specifies how \"From\" headers look.

Dave Love's avatar
Dave Love committed
161
If nil, they contain just the return address like:
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
162 163 164 165 166 167 168 169 170 171 172 173 174 175
	king@grassland.com
If `parens', they look like:
	king@grassland.com (Elvis Parsley)
If `angles', they look like:
	Elvis Parsley <king@grassland.com>

Otherwise, most addresses look like `angles', but they look like
`parens' if `angles' would need quoting and `parens' would not."
  :type '(choice (const :tag "simple" nil)
		 (const parens)
		 (const angles)
		 (const default))
  :group 'message-headers)

176 177
(defcustom message-insert-canlock t
  "Whether to insert a Cancel-Lock header in news postings."
178
  :version "21.4"
179 180 181 182 183
  :group 'message-headers
  :type 'boolean)

(defcustom message-syntax-checks
  (if message-insert-canlock '((sender . disabled)) nil)
184
  ;; Guess this one shouldn't be easy to customize...
185
  "*Controls what syntax checks should not be performed on outgoing posts.
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
186 187 188 189 190
To disable checking of long signatures, for instance, add
 `(signature . disabled)' to this list.

Don't touch this variable unless you really know what you're doing.

Dave Love's avatar
Dave Love committed
191 192 193 194 195
Checks include `subject-cmsg', `multiple-headers', `sendsys',
`message-id', `from', `long-lines', `control-chars', `size',
`new-text', `quoting-style', `redirected-followup', `signature',
`approved', `sender', `empty', `empty-headers', `message-id', `from',
`subject', `shorten-followup-to', `existing-newsgroups',
196 197 198
`buffer-file-name', `unchanged', `newsgroups', `reply-to',
`continuation-headers', `long-header-lines', `invisible-text' and
`illegible-text'."
199
  :group 'message-news
Dave Love's avatar
Dave Love committed
200
  :type '(repeat sexp))			; Fixme: improve this
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
201

202 203 204 205 206
(defcustom message-required-headers '((optional . References)
				      From)
  "*Headers to be generated or prompted for when sending a message.
Also see `message-required-news-headers' and
`message-required-mail-headers'."
207
  :version "21.4"
208 209 210 211 212 213 214
  :group 'message-news
  :group 'message-headers
  :link '(custom-manual "(message)Message Headers")
  :type '(repeat sexp))

(defcustom message-draft-headers '(References From)
  "*Headers to be generated when saving a draft message."
215
  :version "21.4"
216 217 218 219 220
  :group 'message-news
  :group 'message-headers
  :link '(custom-manual "(message)Message Headers")
  :type '(repeat sexp))

Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
221 222
(defcustom message-required-news-headers
  '(From Newsgroups Subject Date Message-ID
223
	 (optional . Organization)
224
	 (optional . User-Agent))
225
  "*Headers to be generated or prompted for when posting an article.
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
226 227
RFC977 and RFC1036 require From, Date, Newsgroups, Subject,
Message-ID.  Organization, Lines, In-Reply-To, Expires, and
228
User-Agent are optional.  If don't you want message to insert some
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
229 230 231
header, remove it from this list."
  :group 'message-news
  :group 'message-headers
232
  :link '(custom-manual "(message)Message Headers")
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
233 234 235
  :type '(repeat sexp))

(defcustom message-required-mail-headers
236
  '(From Subject Date (optional . In-Reply-To) Message-ID
237
	 (optional . User-Agent))
238
  "*Headers to be generated or prompted for when mailing a message.
239 240
It is recommended that From, Date, To, Subject and Message-ID be
included.  Organization and User-Agent are optional."
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
241 242
  :group 'message-mail
  :group 'message-headers
243
  :link '(custom-manual "(message)Message Headers")
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
244 245 246 247 248
  :type '(repeat sexp))

(defcustom message-deletable-headers '(Message-ID Date Lines)
  "Headers to be deleted if they already exist and were generated by message previously."
  :group 'message-headers
249
  :link '(custom-manual "(message)Message Headers")
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
250 251 252
  :type 'sexp)

(defcustom message-ignored-news-headers
253
  "^NNTP-Posting-Host:\\|^Xref:\\|^[BGF]cc:\\|^Resent-Fcc:\\|^X-Draft-From:\\|^X-Gnus-Agent-Meta-Information:"
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
254 255 256
  "*Regexp of headers to be removed unconditionally before posting."
  :group 'message-news
  :group 'message-headers
257
  :link '(custom-manual "(message)Message Headers")
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
258 259
  :type 'regexp)

260 261
(defcustom message-ignored-mail-headers
  "^[GF]cc:\\|^Resent-Fcc:\\|^Xref:\\|^X-Draft-From:\\|^X-Gnus-Agent-Meta-Information:"
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
262 263 264
  "*Regexp of headers to be removed unconditionally before mailing."
  :group 'message-mail
  :group 'message-headers
265
  :link '(custom-manual "(message)Mail Headers")
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
266 267
  :type 'regexp)

268
(defcustom message-ignored-supersedes-headers "^Path:\\|^Date\\|^NNTP-Posting-Host:\\|^Xref:\\|^Lines:\\|^Received:\\|^X-From-Line:\\|^X-Trace:\\|^X-Complaints-To:\\|Return-Path:\\|^Supersedes:\\|^NNTP-Posting-Date:\\|^X-Trace:\\|^X-Complaints-To:\\|^Cancel-Lock:\\|^Cancel-Key:\\|^X-Hashcash:\\|^X-Payment:"
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
269 270 271 272
  "*Header lines matching this regexp will be deleted before posting.
It's best to delete old Path and Date headers before posting to avoid
any confusion."
  :group 'message-interface
273
  :link '(custom-manual "(message)Superseding")
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
274 275
  :type 'regexp)

276 277
(defcustom message-subject-re-regexp
  "^[ \t]*\\([Rr][Ee]\\(\\[[0-9]*\\]\\)*:[ \t]*\\)*[ \t]*"
278 279
  "*Regexp matching \"Re: \" in the subject line."
  :group 'message-various
280
  :link '(custom-manual "(message)Message Headers")
281 282
  :type 'regexp)

283 284 285 286 287 288 289 290 291 292
;;; Start of variables adopted from `message-utils.el'.

(defcustom message-subject-trailing-was-query 'ask
  "*What to do with trailing \"(was: <old subject>)\" in subject lines.
If nil, leave the subject unchanged.  If it is the symbol `ask', query
the user what do do.  In this case, the subject is matched against
`message-subject-trailing-was-ask-regexp'.  If
`message-subject-trailing-was-query' is t, always strip the trailing
old subject.  In this case, `message-subject-trailing-was-regexp' is
used."
293
  :version "21.4"
294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309
  :type '(choice (const :tag "never" nil)
		 (const :tag "always strip" t)
                 (const ask))
  :link '(custom-manual "(message)Message Headers")
  :group 'message-various)

(defcustom message-subject-trailing-was-ask-regexp
  "[ \t]*\\([[(]+[Ww][Aa][Ss][ \t]*.*[\])]+\\)"
  "*Regexp matching \"(was: <old subject>)\" in the subject line.

The function `message-strip-subject-trailing-was' uses this regexp if
`message-subject-trailing-was-query' is set to the symbol `ask'.  If
the variable is t instead of `ask', use
`message-subject-trailing-was-regexp' instead.

It is okay to create some false positives here, as the user is asked."
310
  :version "21.4"
311 312 313 314 315 316 317 318 319 320 321 322
  :group 'message-various
  :link '(custom-manual "(message)Message Headers")
  :type 'regexp)

(defcustom message-subject-trailing-was-regexp
  "[ \t]*\\((*[Ww][Aa][Ss]:[ \t]*.*)\\)"
  "*Regexp matching \"(was: <old subject>)\" in the subject line.

If `message-subject-trailing-was-query' is set to t, the subject is
matched against `message-subject-trailing-was-regexp' in
`message-strip-subject-trailing-was'.  You should use a regexp creating very
few false positives here."
323
  :version "21.4"
324 325 326 327 328 329 330 331 332 333 334 335
  :group 'message-various
  :link '(custom-manual "(message)Message Headers")
  :type 'regexp)

;; Fixme: Why are all these things autoloaded?

;;; marking inserted text

;;;###autoload
(defcustom message-mark-insert-begin
  "--8<---------------cut here---------------start------------->8---\n"
  "How to mark the beginning of some inserted text."
336
  :version "21.4"
337 338 339 340 341 342 343 344
  :type 'string
  :link '(custom-manual "(message)Insertion Variables")
  :group 'message-various)

;;;###autoload
(defcustom message-mark-insert-end
  "--8<---------------cut here---------------end--------------->8---\n"
  "How to mark the end of some inserted text."
345
  :version "21.4"
346 347 348 349 350 351 352 353 354
  :type 'string
  :link '(custom-manual "(message)Insertion Variables")
  :group 'message-various)

;;;###autoload
(defcustom message-archive-header
  "X-No-Archive: Yes\n"
  "Header to insert when you don't want your article to be archived.
Archives \(such as groups.google.com\) respect this header."
355
  :version "21.4"
356 357 358 359 360 361 362 363 364
  :type 'string
  :link '(custom-manual "(message)Header Commands")
  :group 'message-various)

;;;###autoload
(defcustom message-archive-note
  "X-No-Archive: Yes - save http://groups.google.com/"
  "Note to insert why you wouldn't want this posting archived.
If nil, don't insert any text in the body."
365
  :version "21.4"
366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384
  :type '(radio (string :format "%t: %v\n" :size 0)
		(const nil))
  :link '(custom-manual "(message)Header Commands")
  :group 'message-various)

;;; Crossposts and Followups
;; inspired by JoH-followup-to by Jochem Huhman <joh  at gmx.de>
;; new suggestions by R. Weikusat <rw at another.de>

(defvar message-cross-post-old-target nil
  "Old target for cross-posts or follow-ups.")
(make-variable-buffer-local 'message-cross-post-old-target)

;;;###autoload
(defcustom message-cross-post-default t
  "When non-nil `message-cross-post-followup-to' will perform a crosspost.
If nil, `message-cross-post-followup-to' will only do a followup.  Note that
you can explicitly override this setting by calling
`message-cross-post-followup-to' with a prefix."
385
  :version "21.4"
386 387 388 389 390 391 392
  :type 'boolean
  :group 'message-various)

;;;###autoload
(defcustom message-cross-post-note
  "Crosspost & Followup-To: "
  "Note to insert before signature to notify of cross-post and follow-up."
393
  :version "21.4"
394 395 396 397 398 399 400
  :type 'string
  :group 'message-various)

;;;###autoload
(defcustom message-followup-to-note
  "Followup-To: "
  "Note to insert before signature to notify of follow-up only."
401
  :version "21.4"
402 403 404 405 406 407 408 409 410 411
  :type 'string
  :group 'message-various)

;;;###autoload
(defcustom message-cross-post-note-function
  'message-cross-post-insert-note
  "Function to use to insert note about Crosspost or Followup-To.
The function will be called with four arguments.  The function should not only
insert a note, but also ensure old notes are deleted.  See the documentation
for `message-cross-post-insert-note'."
412
  :version "21.4"
413 414 415 416 417
  :type 'function
  :group 'message-various)

;;; End of variables adopted from `message-utils.el'.

Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
418 419 420 421
;;;###autoload
(defcustom message-signature-separator "^-- *$"
  "Regexp matching the signature separator."
  :type 'regexp
422
  :link '(custom-manual "(message)Various Message Variables")
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
423 424
  :group 'message-various)

425
(defcustom message-elide-ellipsis "\n[...]\n\n"
426 427
  "*The string which is inserted for elided text."
  :type 'string
428
  :link '(custom-manual "(message)Various Commands")
429
  :group 'message-various)
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
430

431
(defcustom message-interactive t
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
432 433 434 435
  "Non-nil means when sending a message wait for and display errors.
nil means let mailer mail back a message to report errors."
  :group 'message-sending
  :group 'message-mail
436
  :link '(custom-manual "(message)Sending Variables")
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
437 438
  :type 'boolean)

439
(defcustom message-generate-new-buffers 'unique
Dave Love's avatar
Dave Love committed
440
  "*Non-nil means create a new message buffer whenever `message-setup' is called.
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
441 442 443 444
If this is a function, call that function with three parameters:  The type,
the to address and the group name.  (Any of these may be nil.)  The function
should return the new buffer name."
  :group 'message-buffers
445
  :link '(custom-manual "(message)Message Buffers")
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
446
  :type '(choice (const :tag "off" nil)
447 448
		 (const :tag "unique" unique)
		 (const :tag "unsent" unsent)
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
449 450 451 452 453
		 (function fun)))

(defcustom message-kill-buffer-on-exit nil
  "*Non-nil means that the message buffer will be killed after sending a message."
  :group 'message-buffers
454
  :link '(custom-manual "(message)Message Buffers")
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
455 456
  :type 'boolean)

457 458
(eval-when-compile
  (defvar gnus-local-organization))
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474
(defcustom message-user-organization
  (or (and (boundp 'gnus-local-organization)
	   (stringp gnus-local-organization)
	   gnus-local-organization)
      (getenv "ORGANIZATION")
      t)
  "*String to be used as an Organization header.
If t, use `message-user-organization-file'."
  :group 'message-headers
  :type '(choice string
		 (const :tag "consult file" t)))

;;;###autoload
(defcustom message-user-organization-file "/usr/lib/news/organization"
  "*Local news organization file."
  :type 'file
475
  :link '(custom-manual "(message)News Headers")
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
476 477
  :group 'message-headers)

478
(defcustom message-make-forward-subject-function
479
  #'message-forward-subject-name-subject
Dave Love's avatar
Dave Love committed
480
  "*List of functions called to generate subject headers for forwarded messages.
481 482 483 484 485
The subject generated by the previous function is passed into each
successive function.

The provided functions are:

486 487 488 489 490
* `message-forward-subject-author-subject' Source of article (author or
      newsgroup), in brackets followed by the subject
* `message-forward-subject-name-subject' Source of article (name of author
      or newsgroup), in brackets followed by the subject
* `message-forward-subject-fwd' Subject of article with 'Fwd:' prepended
491
      to it."
492
  :group 'message-forwarding
493
  :link '(custom-manual "(message)Forwarding")
494
  :type '(radio (function-item message-forward-subject-author-subject)
Dave Love's avatar
Dave Love committed
495
		(function-item message-forward-subject-fwd)
496
		(function-item message-forward-subject-name-subject)
Dave Love's avatar
Dave Love committed
497
		(repeat :tag "List of functions" function)))
498 499

(defcustom message-forward-as-mime t
500 501
  "*Non-nil means forward messages as an inline/rfc822 MIME section.
Otherwise, directly inline the old message in the forwarded message."
502
  :version "21.1"
503
  :group 'message-forwarding
504
  :link '(custom-manual "(message)Forwarding")
505 506
  :type 'boolean)

507 508 509 510 511 512 513 514
(defcustom message-forward-show-mml 'best
  "*Non-nil means show forwarded messages as MML (decoded from MIME).
Otherwise, forwarded messages are unchanged.
Can also be the symbol `best' to indicate that MML should be
used, except when it is a bad idea to use MML.  One example where
it is a bad idea is when forwarding a signed or encrypted
message, because converting MIME to MML would invalidate the
digital signature."
515
  :version "21.1"
516
  :group 'message-forwarding
517 518 519
  :type '(choice (const :tag "use MML" t)
		 (const :tag "don't use MML " nil)
		 (const :tag "use MML when appropriate" best)))
520 521

(defcustom message-forward-before-signature t
522
  "*Non-nil means put forwarded message before signature, else after."
523 524
  :group 'message-forwarding
  :type 'boolean)
525 526

(defcustom message-wash-forwarded-subjects nil
527 528
  "*Non-nil means try to remove as much cruft as possible from the subject.
Done before generating the new subject of a forward."
529
  :group 'message-forwarding
530
  :link '(custom-manual "(message)Forwarding")
531 532
  :type 'boolean)

533
(defcustom message-ignored-resent-headers "^Return-receipt\\|^X-Gnus\\|^Gnus-Warning:\\|^>?From "
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
534 535
  "*All headers that match this regexp will be deleted when resending a message."
  :group 'message-interface
536
  :link '(custom-manual "(message)Resending")
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
537 538
  :type 'regexp)

539 540
(defcustom message-forward-ignored-headers "^Content-Transfer-Encoding:\\|^X-Gnus"
  "*All headers that match this regexp will be deleted when forwarding a message."
541
  :version "21.1"
542 543 544 545
  :group 'message-forwarding
  :type '(choice (const :tag "None" nil)
		 regexp))

Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
546 547 548
(defcustom message-ignored-cited-headers "."
  "*Delete these headers from the messages you yank."
  :group 'message-insertion
549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572
  :link '(custom-manual "(message)Insertion Variables")
  :type 'regexp)

(defcustom message-cite-prefix-regexp
  (if (string-match "[[:digit:]]" "1") ;; support POSIX?
      "\\([ \t]*[-_.[:word:]]+>+\\|[ \t]*[]>|}+]\\)+"
    ;; ?-, ?_ or ?. MUST NOT be in syntax entry w.
    (let ((old-table (syntax-table))
	  non-word-constituents)
      (set-syntax-table text-mode-syntax-table)
      (setq non-word-constituents
	    (concat
	     (if (string-match "\\w" "-")  "" "-")
	     (if (string-match "\\w" "_")  "" "_")
	     (if (string-match "\\w" ".")  "" ".")))
      (set-syntax-table old-table)
      (if (equal non-word-constituents "")
	  "\\([ \t]*\\(\\w\\)+>+\\|[ \t]*[]>|}+]\\)+"
	(concat "\\([ \t]*\\(\\w\\|["
		non-word-constituents
		"]\\)+>+\\|[ \t]*[]>|}+]\\)+"))))
  "*Regexp matching the longest possible citation prefix on a line."
  :group 'message-insertion
  :link '(custom-manual "(message)Insertion Variables")
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
573 574
  :type 'regexp)

575
(defcustom message-cancel-message "I am canceling my own article.\n"
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
576 577
  "Message to be inserted in the cancel message."
  :group 'message-interface
578
  :link '(custom-manual "(message)Canceling News")
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
579 580 581 582 583 584 585 586 587
  :type 'string)

;; Useful to set in site-init.el
;;;###autoload
(defcustom message-send-mail-function 'message-send-mail-with-sendmail
  "Function to call to send the current buffer as mail.
The headers should be delimited by a line whose contents match the
variable `mail-header-separator'.

588
Valid values include `message-send-mail-with-sendmail' (the default),
Dave Love's avatar
Dave Love committed
589
`message-send-mail-with-mh', `message-send-mail-with-qmail',
590
`message-smtpmail-send-it', `smtpmail-send-it' and `feedmail-send-it'.
Dave Love's avatar
Dave Love committed
591 592

See also `send-mail-function'."
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
593 594 595
  :type '(radio (function-item message-send-mail-with-sendmail)
		(function-item message-send-mail-with-mh)
		(function-item message-send-mail-with-qmail)
596
		(function-item message-smtpmail-send-it)
597
		(function-item smtpmail-send-it)
Dave Love's avatar
Dave Love committed
598
		(function-item feedmail-send-it)
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
599 600
		(function :tag "Other"))
  :group 'message-sending
601
  :link '(custom-manual "(message)Mail Variables")
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
602 603 604 605 606 607 608 609
  :group 'message-mail)

(defcustom message-send-news-function 'message-send-news
  "Function to call to send the current buffer as news.
The headers should be delimited by a line whose contents match the
variable `mail-header-separator'."
  :group 'message-sending
  :group 'message-news
610
  :link '(custom-manual "(message)News Variables")
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
611 612 613
  :type 'function)

(defcustom message-reply-to-function nil
Dave Love's avatar
Dave Love committed
614
  "If non-nil, function that should return a list of headers.
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
615 616 617
This function should pick out addresses from the To, Cc, and From headers
and respond with new To and Cc headers."
  :group 'message-interface
618
  :link '(custom-manual "(message)Reply")
Dave Love's avatar
Dave Love committed
619
  :type '(choice function (const nil)))
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
620 621

(defcustom message-wide-reply-to-function nil
Dave Love's avatar
Dave Love committed
622
  "If non-nil, function that should return a list of headers.
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
623 624 625
This function should pick out addresses from the To, Cc, and From headers
and respond with new To and Cc headers."
  :group 'message-interface
626
  :link '(custom-manual "(message)Wide Reply")
Dave Love's avatar
Dave Love committed
627
  :type '(choice function (const nil)))
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
628 629

(defcustom message-followup-to-function nil
Dave Love's avatar
Dave Love committed
630
  "If non-nil, function that should return a list of headers.
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
631 632 633
This function should pick out addresses from the To, Cc, and From headers
and respond with new To and Cc headers."
  :group 'message-interface
634
  :link '(custom-manual "(message)Followup")
Dave Love's avatar
Dave Love committed
635
  :type '(choice function (const nil)))
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
636 637 638 639 640 641 642 643

(defcustom message-use-followup-to 'ask
  "*Specifies what to do with Followup-To header.
If nil, always ignore the header.  If it is t, use its value, but
query before using the \"poster\" value.  If it is the symbol `ask',
always query the user whether to use the value.  If it is the symbol
`use', always use the value."
  :group 'message-interface
644
  :link '(custom-manual "(message)Followup")
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
645
  :type '(choice (const :tag "ignore" nil)
646
		 (const :tag "use & query" t)
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
647 648 649
		 (const use)
		 (const ask)))

650 651 652 653 654
(defcustom message-use-mail-followup-to 'use
  "*Specifies what to do with Mail-Followup-To header.
If nil, always ignore the header.  If it is the symbol `ask', always
query the user whether to use the value.  If it is the symbol `use',
always use the value."
655
  :version "21.4"
656 657 658 659 660 661 662 663 664 665 666 667 668
  :group 'message-interface
  :link '(custom-manual "(message)Mailing Lists")
  :type '(choice (const :tag "ignore" nil)
		 (const use)
		 (const ask)))

(defcustom message-subscribed-address-functions nil
  "*Specifies functions for determining list subscription.
If nil, do not attempt to determine list subscription with functions.
If non-nil, this variable contains a list of functions which return
regular expressions to match lists.  These functions can be used in
conjunction with `message-subscribed-regexps' and
`message-subscribed-addresses'."
669
  :version "21.4"
670 671 672 673 674 675 676 677
  :group 'message-interface
  :link '(custom-manual "(message)Mailing Lists")
  :type '(repeat sexp))

(defcustom message-subscribed-address-file nil
  "*A file containing addresses the user is subscribed to.
If nil, do not look at any files to determine list subscriptions.  If
non-nil, each line of this file should be a mailing list address."
678
  :version "21.4"
679 680 681 682 683 684 685 686 687 688
  :group 'message-interface
  :link '(custom-manual "(message)Mailing Lists")
  :type '(radio (file :format "%t: %v\n" :size 0)
		(const nil)))

(defcustom message-subscribed-addresses nil
  "*Specifies a list of addresses the user is subscribed to.
If nil, do not use any predefined list subscriptions.  This list of
addresses can be used in conjunction with
`message-subscribed-address-functions' and `message-subscribed-regexps'."
689
  :version "21.4"
690 691 692 693 694 695 696 697 698
  :group 'message-interface
  :link '(custom-manual "(message)Mailing Lists")
  :type '(repeat string))

(defcustom message-subscribed-regexps nil
  "*Specifies a list of addresses the user is subscribed to.
If nil, do not use any predefined list subscriptions.  This list of
regular expressions can be used in conjunction with
`message-subscribed-address-functions' and `message-subscribed-addresses'."
699
  :version "21.4"
700 701 702 703 704 705 706 707 708
  :group 'message-interface
  :link '(custom-manual "(message)Mailing Lists")
  :type '(repeat regexp))

(defcustom message-allow-no-recipients 'ask
  "Specifies what to do when there are no recipients other than Gcc/Fcc.
If it is the symbol `always', the posting is allowed.  If it is the
symbol `never', the posting is not allowed.  If it is the symbol
`ask', you are prompted."
709
  :version "21.4"
710 711 712 713 714 715
  :group 'message-interface
  :link '(custom-manual "(message)Message Headers")
  :type '(choice (const always)
		 (const never)
		 (const ask)))

Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
716
(defcustom message-sendmail-f-is-evil nil
Dave Love's avatar
Dave Love committed
717
  "*Non-nil means don't add \"-f username\" to the sendmail command line.
718
Doing so would be even more evil than leaving it out."
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
719
  :group 'message-sending
720
  :link '(custom-manual "(message)Mail Variables")
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
721 722
  :type 'boolean)

723 724 725 726 727 728 729 730 731 732
(defcustom message-sendmail-envelope-from nil
  "*Envelope-from when sending mail with sendmail.
If this is nil, use `user-mail-address'.  If it is the symbol
`header', use the From: header of the message."
  :type '(choice (string :tag "From name")
		 (const :tag "Use From: header from message" header)
		 (const :tag "Use `user-mail-address'" nil))
  :link '(custom-manual "(message)Mail Variables")
  :group 'message-sending)

Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
733 734 735 736
;; qmail-related stuff
(defcustom message-qmail-inject-program "/var/qmail/bin/qmail-inject"
  "Location of the qmail-inject program."
  :group 'message-sending
737
  :link '(custom-manual "(message)Mail Variables")
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
738 739 740 741
  :type 'file)

(defcustom message-qmail-inject-args nil
  "Arguments passed to qmail-inject programs.
742 743
This should be a list of strings, one string for each argument.  It
may also be a function.
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
744 745 746 747 748

For e.g., if you wish to set the envelope sender address so that bounces
go to the right place or to deal with listserv's usage of that address, you
might set this variable to '(\"-f\" \"you@some.where\")."
  :group 'message-sending
749 750 751
  :link '(custom-manual "(message)Mail Variables")
  :type '(choice (function)
		 (repeat string)))
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
752

753 754 755 756 757
(defvar message-cater-to-broken-inn t
  "Non-nil means Gnus should not fold the `References' header.
Folding `References' makes ancient versions of INN create incorrect
NOV lines.")

758 759 760
(eval-when-compile
  (defvar gnus-post-method)
  (defvar gnus-select-method))
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
761 762
(defcustom message-post-method
  (cond ((and (boundp 'gnus-post-method)
763
	      (listp gnus-post-method)
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
764 765 766 767 768
	      gnus-post-method)
	 gnus-post-method)
	((boundp 'gnus-select-method)
	 gnus-select-method)
	(t '(nnspool "")))
769 770 771
  "*Method used to post news.
Note that when posting from inside Gnus, for instance, this
variable isn't used."
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
772 773 774 775 776 777
  :group 'message-news
  :group 'message-sending
  ;; This should be the `gnus-select-method' widget, but that might
  ;; create a dependence to `gnus.el'.
  :type 'sexp)

778 779 780 781 782 783 784 785 786 787 788 789 790
;; FIXME: This should be a temporary workaround until someone implements a
;; proper solution.  If a crash happens while replying, the auto-save file
;; will *not* have a `References:' header if `message-generate-headers-first'
;; is nil.  See: http://article.gmane.org/gmane.emacs.gnus.general/51138
(defcustom message-generate-headers-first '(references)
  "Which headers should be generated before starting to compose a message.
If `t', generate all required headers.  This can also be a list of headers to
generate.  The variables `message-required-news-headers' and
`message-required-mail-headers' specify which headers to generate.

Note that the variable `message-deletable-headers' specifies headers which
are to be deleted and then re-generated before sending, so this variable
will not have a visible effect for those headers."
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
791
  :group 'message-headers
792 793 794 795 796
  :link '(custom-manual "(message)Message Headers")
  :type '(choice (const :tag "None" nil)
                 (const :tag "References" '(references))
                 (const :tag "All" t)
                 (repeat (sexp :tag "Header"))))
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
797 798 799 800 801

(defcustom message-setup-hook nil
  "Normal hook, run each time a new outgoing message is initialized.
The function `message-setup' runs this hook."
  :group 'message-various
802
  :link '(custom-manual "(message)Various Message Variables")
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
803 804
  :type 'hook)

805 806 807
(defcustom message-cancel-hook nil
  "Hook run when cancelling articles."
  :group 'message-various
808
  :link '(custom-manual "(message)Various Message Variables")
809 810
  :type 'hook)

Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
811 812 813 814 815
(defcustom message-signature-setup-hook nil
  "Normal hook, run each time a new outgoing message is initialized.
It is run after the headers have been inserted and before
the signature is inserted."
  :group 'message-various
816
  :link '(custom-manual "(message)Various Message Variables")
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
817 818 819 820 821 822 823 824 825 826 827 828 829
  :type 'hook)

(defcustom message-mode-hook nil
  "Hook run in message mode buffers."
  :group 'message-various
  :type 'hook)

(defcustom message-header-hook nil
  "Hook run in a message mode buffer narrowed to the headers."
  :group 'message-various
  :type 'hook)

(defcustom message-header-setup-hook nil
830
  "Hook called narrowed to the headers when setting up a message buffer."
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
831
  :group 'message-various
832
  :link '(custom-manual "(message)Various Message Variables")
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
833 834
  :type 'hook)

835 836 837 838 839 840
(defcustom message-minibuffer-local-map
  (let ((map (make-sparse-keymap 'message-minibuffer-local-map)))
    (set-keymap-parent map minibuffer-local-map)
    map)
  "Keymap for `message-read-from-minibuffer'.")

Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
841 842
;;;###autoload
(defcustom message-citation-line-function 'message-insert-citation-line
843 844 845 846 847 848
  "*Function called to insert the \"Whomever writes:\" line.

Note that Gnus provides a feature where the reader can click on
`writes:' to hide the cited text.  If you change this line too much,
people who read your message will have to change their Gnus
configuration.  See the variable `gnus-cite-attribution-suffix'."
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
849
  :type 'function
850
  :link '(custom-manual "(message)Insertion Variables")
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
851 852 853 854
  :group 'message-insertion)

;;;###autoload
(defcustom message-yank-prefix "> "
855 856 857 858 859 860 861 862 863 864 865
  "*Prefix inserted on the lines of yanked messages.
Fix `message-cite-prefix-regexp' if it is set to an abnormal value.
See also `message-yank-cited-prefix'."
  :type 'string
  :link '(custom-manual "(message)Insertion Variables")
  :group 'message-insertion)

(defcustom message-yank-cited-prefix ">"
  "*Prefix inserted on cited or empty lines of yanked messages.
Fix `message-cite-prefix-regexp' if it is set to an abnormal value.
See also `message-yank-prefix'."
866
  :version "21.4"
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
867
  :type 'string
868
  :link '(custom-manual "(message)Insertion Variables")
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
869 870 871 872 873 874
  :group 'message-insertion)

(defcustom message-indentation-spaces 3
  "*Number of spaces to insert at the beginning of each cited line.
Used by `message-yank-original' via `message-yank-cite'."
  :group 'message-insertion
875
  :link '(custom-manual "(message)Insertion Variables")
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
876 877 878
  :type 'integer)

;;;###autoload
879
(defcustom message-cite-function 'message-cite-original
880 881 882
  "*Function for citing an original message.
Predefined functions include `message-cite-original' and
`message-cite-original-without-signature'.
883
Note that `message-cite-original' uses `mail-citation-hook' if that is non-nil."
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
884
  :type '(radio (function-item message-cite-original)
885
		(function-item message-cite-original-without-signature)
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
886 887
		(function-item sc-cite-original)
		(function :tag "Other"))
888
  :link '(custom-manual "(message)Insertion Variables")
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
889 890 891 892 893 894 895 896 897
  :group 'message-insertion)

;;;###autoload
(defcustom message-indent-citation-function 'message-indent-citation
  "*Function for modifying a citation just inserted in the mail buffer.
This can also be a list of functions.  Each function can find the
citation between (point) and (mark t).  And each function should leave
point and mark around the citation text as modified."
  :type 'function
898
  :link '(custom-manual "(message)Insertion Variables")
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
899 900 901 902 903 904 905 906 907
  :group 'message-insertion)

;;;###autoload
(defcustom message-signature t
  "*String to be inserted at the end of the message buffer.
If t, the `message-signature-file' file will be inserted instead.
If a function, the result from the function will be used instead.
If a form, the result from the form will be used instead."
  :type 'sexp
908
  :link '(custom-manual "(message)Insertion Variables")
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
909 910 911 912
  :group 'message-insertion)

;;;###autoload
(defcustom message-signature-file "~/.signature"
913 914 915 916
  "*Name of file containing the text inserted at end of message buffer.
Ignored if the named file doesn't exist.
If nil, don't insert a signature."
  :type '(choice file (const :tags "None" nil))
917 918 919 920 921 922
  :link '(custom-manual "(message)Insertion Variables")
  :group 'message-insertion)

;;;###autoload
(defcustom message-signature-insert-empty-line t
  "*If non-nil, insert an empty line before the signature separator."
923
  :version "21.4"
924 925
  :type 'boolean
  :link '(custom-manual "(message)Insertion Variables")
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
926 927 928 929 930 931
  :group 'message-insertion)

(defcustom message-distribution-function nil
  "*Function called to return a Distribution header."
  :group 'message-news
  :group 'message-headers
932
  :link '(custom-manual "(message)News Headers")
Dave Love's avatar
Dave Love committed
933
  :type '(choice function (const nil)))
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952

(defcustom message-expires 14
  "Number of days before your article expires."
  :group 'message-news
  :group 'message-headers
  :link '(custom-manual "(message)News Headers")
  :type 'integer)

(defcustom message-user-path nil
  "If nil, use the NNTP server name in the Path header.
If stringp, use this; if non-nil, use no host name (user name only)."
  :group 'message-news
  :group 'message-headers
  :link '(custom-manual "(message)News Headers")
  :type '(choice (const :tag "nntp" nil)
		 (string :tag "name")
		 (sexp :tag "none" :format "%t" t)))

(defvar message-reply-buffer nil)
953 954 955 956
(defvar message-reply-headers nil
  "The headers of the current replied article.
It is a vector of the following headers:
\[number subject from date id references chars lines xref extra].")
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
957 958 959 960 961 962 963 964 965 966 967 968 969
(defvar message-newsreader nil)
(defvar message-mailer nil)
(defvar message-sent-message-via nil)
(defvar message-checksum nil)
(defvar message-send-actions nil
  "A list of actions to be performed upon successful sending of a message.")
(defvar message-exit-actions nil
  "A list of actions to be performed upon exiting after sending a message.")
(defvar message-kill-actions nil
  "A list of actions to be performed before killing a message buffer.")
(defvar message-postpone-actions nil
  "A list of actions to be performed after postponing a message.")

970 971
(define-widget 'message-header-lines 'text
  "All header lines must be LFD terminated."
972
  :format "%{%t%}:%n%v"
973 974 975
  :valid-regexp "^\\'"
  :error "All header lines must be newline terminated")

Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
976 977 978 979 980
(defcustom message-default-headers ""
  "*A string containing header lines to be inserted in outgoing messages.
It is inserted before you edit the message, so you can edit or delete
these lines."
  :group 'message-headers
981
  :link '(custom-manual "(message)Message Headers")
982
  :type 'message-header-lines)
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
983 984 985 986 987

(defcustom message-default-mail-headers ""
  "*A string of header lines to be inserted in outgoing mails."
  :group 'message-headers
  :group 'message-mail
988
  :link '(custom-manual "(message)Mail Headers")
989
  :type 'message-header-lines)
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
990 991

(defcustom message-default-news-headers ""
992
  "*A string of header lines to be inserted in outgoing news articles."
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
993 994
  :group 'message-headers
  :group 'message-news
995
  :link '(custom-manual "(message)News Headers")
996
  :type 'message-header-lines)
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017

;; Note: could use /usr/ucb/mail instead of sendmail;
;; options -t, and -v if not interactive.
(defcustom message-mailer-swallows-blank-line
  (if (and (string-match "sparc-sun-sunos\\(\\'\\|[^5]\\)"
			 system-configuration)
	   (file-readable-p "/etc/sendmail.cf")
	   (let ((buffer (get-buffer-create " *temp*")))
	     (unwind-protect
		 (save-excursion
		   (set-buffer buffer)
		   (insert-file-contents "/etc/sendmail.cf")
		   (goto-char (point-min))
		   (let ((case-fold-search nil))
		     (re-search-forward "^OR\\>" nil t)))
	       (kill-buffer buffer))))
      ;; According to RFC822, "The field-name must be composed of printable
      ;; ASCII characters (i. e., characters that have decimal values between
      ;; 33 and 126, except colon)", i. e., any chars except ctl chars,
      ;; space, or colon.
      '(looking-at "[ \t]\\|[][!\"#$%&'()*+,-./0-9;<=>?@A-Z\\\\^_`a-z{|}~]+:"))
1018
  "*Set this non-nil if the system's mailer runs the header and body together.
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
1019 1020 1021 1022
\(This problem exists on Sunos 4 when sendmail is run in remote mode.)
The value should be an expression to test whether the problem will
actually occur."
  :group 'message-sending
1023
  :link '(custom-manual "(message)Mail Variables")
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
1024 1025
  :type 'sexp)

1026
;;;###autoload
1027 1028 1029
(define-mail-user-agent 'message-user-agent
  'message-mail 'message-send-and-exit
  'message-kill-buffer 'message-send-hook)
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
1030 1031 1032 1033

(defvar message-mh-deletable-headers '(Message-ID Date Lines Sender)
  "If non-nil, delete the deletable headers before feeding to mh.")

1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047
(defvar message-send-method-alist
  '((news message-news-p message-send-via-news)
    (mail message-mail-p message-send-via-mail))
  "Alist of ways to send outgoing messages.
Each element has the form

  \(TYPE PREDICATE FUNCTION)

where TYPE is a symbol that names the method; PREDICATE is a function
called without any parameters to determine whether the message is
a message of type TYPE; and FUNCTION is a function to be called if
PREDICATE returns non-nil.  FUNCTION is called with one parameter --
the prefix.")

1048
(defcustom message-mail-alias-type 'abbrev
1049 1050
  "*What alias expansion type to use in Message buffers.
The default is `abbrev', which uses mailabbrev.  nil switches
1051 1052 1053 1054 1055
mail aliases off."
  :group 'message
  :link '(custom-manual "(message)Mail Aliases")
  :type '(choice (const :tag "Use Mailabbrev" abbrev)
		 (const :tag "No expansion" nil)))
1056

1057
(defcustom message-auto-save-directory
Dave Love's avatar
Dave Love committed
1058
  (file-name-as-directory (nnheader-concat message-directory "drafts"))
1059 1060 1061
  "*Directory where Message auto-saves buffers if Gnus isn't running.
If nil, Message won't auto-save."
  :group 'message-buffers
1062
  :link '(custom-manual "(message)Various Message Variables")
Dave Love's avatar
Dave Love committed
1063
  :type '(choice directory (const :tag "Don't auto-save" nil)))
1064

Dave Love's avatar
Dave Love committed
1065
(defcustom message-default-charset
1066 1067 1068
  (and (not (mm-multibyte-p)) 'iso-8859-1)
  "Default charset used in non-MULE Emacsen.
If nil, you might be asked to input the charset."
1069
  :version "21.1"
1070
  :group 'message
1071
  :link '(custom-manual "(message)Various Message Variables")
1072 1073
  :type 'symbol)

Dave Love's avatar
Dave Love committed
1074
(defcustom message-dont-reply-to-names
1075
  (and (boundp 'rmail-dont-reply-to-names) rmail-dont-reply-to-names)
1076 1077
  "*A regexp specifying addresses to prune when doing wide replies.
A value of nil means exclude your own user name only."
1078
  :version "21.1"
1079
  :group 'message
1080
  :link '(custom-manual "(message)Wide Reply")
1081 1082 1083
  :type '(choice (const :tag "Yourself" nil)
		 regexp))

1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103
(defvar message-shoot-gnksa-feet nil
  "*A list of GNKSA feet you are allowed to shoot.
Gnus gives you all the opportunity you could possibly want for
shooting yourself in the foot.  Also, Gnus allows you to shoot the
feet of Good Net-Keeping Seal of Approval.  The following are foot
candidates:
`empty-article'     Allow you to post an empty article;
`quoted-text-only'  Allow you to post quoted text only;
`multiple-copies'   Allow you to post multiple copies;
`cancel-messages'   Allow you to cancel or supersede messages from
                    your other email addresses.")

(defsubst message-gnksa-enable-p (feature)
  (or (not (listp message-shoot-gnksa-feet))
      (memq feature message-shoot-gnksa-feet)))

(defcustom message-hidden-headers nil
  "Regexp of headers to be hidden when composing new messages.
This can also be a list of regexps to match headers.  Or a list
starting with `not' and followed by regexps."
1104
  :version "21.4"
1105 1106 1107 1108
  :group 'message
  :link '(custom-manual "(message)Message Headers")
  :type '(repeat regexp))

Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
1109 1110 1111 1112 1113 1114
;;; Internal variables.
;;; Well, not really internal.

(defvar message-mode-syntax-table
  (let ((table (copy-syntax-table text-mode-syntax-table)))
    (modify-syntax-entry ?% ". " table)
1115 1116
    (modify-syntax-entry ?> ". " table)
    (modify-syntax-entry ?< ". " table)
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
1117 1118 1119 1120 1121 1122
    table)
  "Syntax table used while in Message mode.")

(defface message-header-to-face
  '((((class color)
      (background dark))
1123
     (:foreground "green2" :bold t))
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
1124 1125
    (((class color)
      (background light))
1126
     (:foreground "MidnightBlue" :bold t))
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
1127
    (t
1128
     (:bold t :italic t)))
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
1129 1130 1131 1132 1133 1134
  "Face used for displaying From headers."
  :group 'message-faces)

(defface message-header-cc-face
  '((((class color)
      (background dark))
1135
     (:foreground "green4" :bold t))
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
1136 1137 1138 1139
    (((class color)
      (background light))
     (:foreground "MidnightBlue"))
    (t
1140
     (:bold t)))
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
1141 1142 1143 1144 1145 1146 1147 1148 1149
  "Face used for displaying Cc headers."
  :group 'message-faces)

(defface message-header-subject-face
  '((((class color)
      (background dark))
     (:foreground "green3"))
    (((class color)
      (background light))
1150
     (:foreground "navy blue" :bold t))
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
1151
    (t
1152
     (:bold t)))
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
1153 1154 1155 1156 1157 1158
  "Face used for displaying subject headers."
  :group 'message-faces)

(defface message-header-newsgroups-face
  '((((class color)
      (background dark))
1159
     (:foreground "yellow" :bold t :italic t))
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
1160 1161
    (((class color)
      (background light))
1162
     (:foreground "blue4" :bold t :italic t))
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
1163
    (t
1164
     (:bold t :italic t)))
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
1165 1166 1167 1168 1169 1170
  "Face used for displaying newsgroups headers."
  :group 'message-faces)

(defface message-header-other-face
  '((((class color)
      (background dark))
1171
     (:foreground "#b00000"))
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
1172 1173 1174 1175
    (((class color)
      (background light))
     (:foreground "steel blue"))
    (t
1176
     (:bold t :italic t)))
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187
  "Face used for displaying newsgroups headers."
  :group 'message-faces)

(defface message-header-name-face
  '((((class color)
      (background dark))
     (:foreground "DarkGreen"))
    (((class color)
      (background light))
     (:foreground "cornflower blue"))
    (t
1188
     (:bold t)))
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199
  "Face used for displaying header names."
  :group 'message-faces)

(defface message-header-xheader-face
  '((((class color)
      (background dark))
     (:foreground "blue"))
    (((class color)
      (background light))
     (:foreground "blue"))
    (t
1200
     (:bold t)))
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
1201 1202 1203 1204 1205