annotate lisp/message.el @ 15547:c3e0ef571f08

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