summaryrefslogtreecommitdiff
path: root/lisp/mail
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/mail')
-rw-r--r--lisp/mail/emacsbug.el48
-rw-r--r--lisp/mail/feedmail.el6
-rw-r--r--lisp/mail/mail-extr.el7
-rw-r--r--lisp/mail/rmail.el55
-rw-r--r--lisp/mail/rmailout.el10
-rw-r--r--lisp/mail/rmailsum.el26
-rw-r--r--lisp/mail/sendmail.el357
-rw-r--r--lisp/mail/smtpmail.el21
8 files changed, 285 insertions, 245 deletions
diff --git a/lisp/mail/emacsbug.el b/lisp/mail/emacsbug.el
index bb88c447320..47b7f1c3a1b 100644
--- a/lisp/mail/emacsbug.el
+++ b/lisp/mail/emacsbug.el
@@ -56,9 +56,6 @@
(defvar report-emacs-bug-orig-text nil
"The automatically-created initial text of bug report.")
-(defvar report-emacs-bug-text-prompt nil
- "The automatically-created initial prompt of bug report.")
-
(defcustom report-emacs-bug-no-confirmation nil
"*If non-nil, suppress the confirmations asked for the sake of novice users."
:group 'emacsbug
@@ -78,15 +75,20 @@ Prompts for bug subject. Leaves you in a mail buffer."
(interactive (reverse (list (recent-keys) (read-string "Bug Subject: "))))
;; If there are four numbers in emacs-version, this is a pretest
;; version.
- (let ((pretest-p (string-match "\\..*\\..*\\." emacs-version))
+ (let* ((pretest-p (string-match "\\..*\\..*\\." emacs-version))
(from-buffer (current-buffer))
- user-point prompt-beg-point message-end-point)
+ (reporting-address (if pretest-p
+ report-emacs-bug-pretest-address
+ report-emacs-bug-address))
+ ;; Put these properties on semantically-void text.
+ (prompt-properties '(field emacsbug-prompt
+ intangible but-helpful
+ rear-nonsticky t))
+ user-point message-end-point)
(setq message-end-point
(with-current-buffer (get-buffer-create "*Messages*")
(point-max-marker)))
- (compose-mail (if pretest-p
- report-emacs-bug-pretest-address
- report-emacs-bug-address)
+ (compose-mail reporting-address
topic)
;; The rest of this does not execute
;; if the user was asked to confirm and said no.
@@ -97,33 +99,30 @@ Prompts for bug subject. Leaves you in a mail buffer."
(delete-region (point) (point-max))
(insert signature)
(backward-char (length signature)))
- (setq prompt-beg-point (point))
(unless report-emacs-bug-no-explanations
;; Insert warnings for novice users.
- (insert "This bug report will be sent to the Free Software Foundation,\n")
- (let ((pos (point)))
- (insert "not to your local site managers!")
- (put-text-property pos (point) 'face 'highlight))
- (insert "\nPlease write in ")
+ (when (string-match "@gnu\\.org^" reporting-address)
+ (insert "This bug report will be sent to the Free Software Foundation,\n")
+ (let ((pos (point)))
+ (insert "not to your local site managers!")
+ (put-text-property pos (point) 'face 'highlight)))
+ (insert "\nPlease write in ")
(let ((pos (point)))
(insert "English")
(put-text-property pos (point) 'face 'highlight))
(insert " if possible, because the Emacs maintainers
usually do not have translators to read other languages for them.\n\n")
(insert (format "Your bug report will be posted to the %s mailing list"
- (if pretest-p
- report-emacs-bug-pretest-address
- report-emacs-bug-address)))
+ reporting-address))
(if pretest-p
(insert ".\n\n")
(insert ",\nand to the gnu.emacs.bug news group.\n\n")))
(insert "Please describe exactly what actions triggered the bug\n"
- "and the precise symptoms of the bug:")
- (setq report-emacs-bug-text-prompt
- (buffer-substring prompt-beg-point (point)))
+ "and the precise symptoms of the bug:\n\n")
+ (add-text-properties (point) (save-excursion (mail-text) (point))
+ prompt-properties)
- (insert "\n\n")
(setq user-point (point))
(insert "\n\n")
@@ -135,6 +134,7 @@ usually do not have translators to read other languages for them.\n\n")
(if (file-readable-p debug-file)
(insert "If you would like to further debug the crash, please read the file\n"
debug-file " for instructions.\n")))
+ (add-text-properties (1+ user-point) (point) prompt-properties)
(insert "\n\nIn " (emacs-version) "\n")
(if (fboundp 'x-server-vendor)
@@ -274,8 +274,10 @@ and send the mail again using \\[mail-send-and-exit].")))
;; Unclutter
(mail-text)
- (if (looking-at report-emacs-bug-text-prompt)
- (replace-match "Symptoms:"))))
+ (let ((pos (1- (point))))
+ (while (setq pos (text-property-any pos (point-max)
+ 'field 'emacsbug-prompt))
+ (delete-region pos (field-end (1+ pos)))))))
(provide 'emacsbug)
diff --git a/lisp/mail/feedmail.el b/lisp/mail/feedmail.el
index 101e96c8554..3bd287541cf 100644
--- a/lisp/mail/feedmail.el
+++ b/lisp/mail/feedmail.el
@@ -1372,7 +1372,7 @@ complicated cases."
(if (string-match tracer (buffer-name buffy))
(progn
(insert "SMTP Trace from " (buffer-name buffy) "\n---------------")
- (insert-buffer buffy)
+ (insert-buffer-substring buffy)
(insert "\n\n"))))
(buffer-list))))))
@@ -1989,7 +1989,7 @@ mapped to mostly alphanumerics for safety."
(set-buffer feedmail-prepped-text-buffer) (erase-buffer)
;; jam contents of user-supplied mail buffer into our scratch buffer
- (insert-buffer feedmail-raw-text-buffer)
+ (insert-buffer-substring feedmail-raw-text-buffer)
;; require one newline at the end.
(goto-char (point-max))
@@ -2215,7 +2215,7 @@ feedmail-fiddle-plex-blurb."
(erase-buffer)
;; not life's most efficient methodology, but spraying isn't
;; an every-5-minutes event either
- (insert-buffer feedmail-prepped-text-buffer)
+ (insert-buffer-substring feedmail-prepped-text-buffer)
;; There's a good case to me made that each separate transmission of
;; a message in the spray should have a distinct Message-Id:. There
;; is also a less compelling argument in the other direction. I think
diff --git a/lisp/mail/mail-extr.el b/lisp/mail/mail-extr.el
index da5ec4bfda1..0f5aa1e18f7 100644
--- a/lisp/mail/mail-extr.el
+++ b/lisp/mail/mail-extr.el
@@ -699,9 +699,10 @@ Unless NO-REPLACE is true, at each of the positions in LIST-SYMBOL
;;;###autoload
(defun mail-extract-address-components (address &optional all)
"Given an RFC-822 address ADDRESS, extract full name and canonical address.
-Returns a list of the form (FULL-NAME CANONICAL-ADDRESS).
-If no name can be extracted, FULL-NAME will be nil. Also see
-`mail-extr-ignore-single-names' and `mail-extr-ignore-realname-equals-mailbox-name'.
+Returns a list of the form (FULL-NAME CANONICAL-ADDRESS). If no
+name can be extracted, FULL-NAME will be nil. Also see
+`mail-extr-ignore-single-names' and
+`mail-extr-ignore-realname-equals-mailbox-name'.
If the optional argument ALL is non-nil, then ADDRESS can contain zero
or more recipients, separated by commas, and we return a list of
diff --git a/lisp/mail/rmail.el b/lisp/mail/rmail.el
index 1016b1ed1e6..da801492210 100644
--- a/lisp/mail/rmail.el
+++ b/lisp/mail/rmail.el
@@ -447,8 +447,10 @@ examples:
"String to prepend to Subject line when replying to a message.")
;; Some mailers use "Re(2):" or "Re^2:" or "Re: Re:" or "Re[2]:".
-;; This pattern should catch all the common variants.
-(defvar rmail-reply-regexp "\\`\\(Re\\(([0-9]+)\\|\\[[0-9]+\\]\\|\\^[0-9]+\\)?: *\\)*"
+;; This pattern should catch all the common variants. The pattern
+;; also ignores mailing list identifiers sometimes added in square
+;; brackets at the beginning of subject lines.
+(defvar rmail-reply-regexp "\\`\\(\\[.+?\\] \\)?\\(Re\\(([0-9]+)\\|\\[[0-9]+\\]\\|\\^[0-9]+\\)?: *\\)*"
"Regexp to delete from Subject line before inserting `rmail-reply-prefix'.")
(defcustom rmail-display-summary nil
@@ -3143,25 +3145,52 @@ Interactively, empty argument means use same regexp used last time."
;; (rmail-show-message found))
found))
+(defun rmail-current-subject ()
+ "Return the current subject.
+The subject is stripped of leading and trailing whitespace, and
+of typical reply prefixes such as Re:."
+ (let ((subject (or (mail-fetch-field "Subject") "")))
+ (if (string-match "\\`[ \t]+" subject)
+ (setq subject (substring subject (match-end 0))))
+ (if (string-match rmail-reply-regexp subject)
+ (setq subject (substring subject (match-end 0))))
+ (if (string-match "[ \t]+\\'" subject)
+ (setq subject (substring subject 0 (match-beginning 0))))
+ subject))
+
+(defun rmail-current-subject-regexp ()
+ "Return a regular expression matching the current subject.
+The regular expression matches the subject header line of
+messages about the same subject. The subject itself is stripped
+of leading and trailing whitespace, of typical reply prefixes
+such as Re: and whitespace within the subject is replaced by a
+regular expression matching whitespace in general in order to
+take into account that subject header lines may include newlines
+and more whitespace. The returned regular expressions contains
+`rmail-reply-regexp' and ends with a newline."
+ (let ((subject (rmail-current-subject)))
+ ;; If Subject is long, mailers will break it into several lines at
+ ;; arbitrary places, so replace whitespace with a regexp that will
+ ;; match any sequence of spaces, TABs, and newlines.
+ (setq subject (regexp-quote subject))
+ (setq subject
+ (replace-regexp-in-string "[ \t\n]+" "[ \t\n]+" subject t t))
+ (concat "^Subject: "
+ (if (string= "\\`" (substring rmail-reply-regexp 0 2))
+ (substring rmail-reply-regexp 2)
+ rmail-reply-regexp)
+ subject "[ \t]*\n")))
+
(defun rmail-next-same-subject (n)
"Go to the next mail message having the same subject header.
With prefix argument N, do this N times.
If N is negative, go backwards instead."
(interactive "p")
- (let ((subject (mail-fetch-field "Subject"))
+ (let ((search-regexp (rmail-current-subject-regexp))
(forward (> n 0))
(i rmail-current-message)
(case-fold-search t)
- search-regexp found)
- (if (string-match "\\`[ \t]+" subject)
- (setq subject (substring subject (match-end 0))))
- (if (string-match "Re:[ \t]*" subject)
- (setq subject (substring subject (match-end 0))))
- (if (string-match "[ \t]+\\'" subject)
- (setq subject (substring subject 0 (match-beginning 0))))
- (setq search-regexp (concat "^Subject: *\\(Re:[ \t]*\\)?"
- (regexp-quote subject)
- "[ \t]*\n"))
+ found)
(save-excursion
(save-restriction
(widen)
diff --git a/lisp/mail/rmailout.el b/lisp/mail/rmailout.el
index d97c181eb81..97654ae92c5 100644
--- a/lisp/mail/rmailout.el
+++ b/lisp/mail/rmailout.el
@@ -123,11 +123,11 @@ appended in inbox format, the same way `rmail-output' does it.
The default file name comes from `rmail-default-rmail-file',
which is updated to the name you use in this command.
-A prefix argument N says to output N consecutive messages
+A prefix argument COUNT says to output that many consecutive messages,
starting with the current one. Deleted messages are skipped and don't count.
-If optional argument STAY is non-nil, then leave the last filed
-mesasge up instead of moving forward to the next non-deleted message."
+If the optional argument STAY is non-nil, then leave the last filed
+message up instead of moving forward to the next non-deleted message."
(interactive
(list (rmail-output-read-rmail-file-name)
(prefix-numeric-value current-prefix-arg)))
@@ -265,9 +265,9 @@ mesasge up instead of moving forward to the next non-deleted message."
;;;###autoload
(defun rmail-output (file-name &optional count noattribute from-gnus)
"Append this message to system-inbox-format mail file named FILE-NAME.
-A prefix argument N says to output N consecutive messages
+A prefix argument COUNT says to output that many consecutive messages,
starting with the current one. Deleted messages are skipped and don't count.
-When called from lisp code, N may be omitted.
+When called from lisp code, COUNT may be omitted and defaults to 1.
If the pruned message header is shown on the current message, then
messages will be appended with pruned headers; otherwise, messages
diff --git a/lisp/mail/rmailsum.el b/lisp/mail/rmailsum.el
index 497f2f75301..e9ddb83baf3 100644
--- a/lisp/mail/rmailsum.el
+++ b/lisp/mail/rmailsum.el
@@ -132,7 +132,15 @@ Normally checks the Subject field of headers;
but if WHOLE-MESSAGE is non-nil (prefix arg given),
look in the whole message.
SUBJECT is a string of regexps separated by commas."
- (interactive "sTopics to summarize by: \nP")
+ (interactive
+ (let* ((subject (with-current-buffer rmail-buffer
+ (rmail-current-subject)))
+ (subject-re (with-current-buffer rmail-buffer
+ (rmail-current-subject-regexp)))
+ (prompt (concat "Topics to summarize by (regexp"
+ (if subject ", default current subject" "")
+ "): ")))
+ (list (read-string prompt nil nil subject) current-prefix-arg)))
(rmail-new-summary
(concat "about " subject)
(list 'rmail-summary-by-topic subject whole-message)
@@ -568,17 +576,11 @@ With prefix argument N moves backward N messages with these labels."
With prefix argument N, do this N times.
If N is negative, go backwards."
(interactive "p")
- (let (subject search-regexp i found
- (forward (> n 0)))
- (save-excursion
- (set-buffer rmail-buffer)
- (setq subject (mail-fetch-field "Subject"))
- (setq i rmail-current-message))
- (if (string-match "Re:[ \t]*" subject)
- (setq subject (substring subject (match-end 0))))
- (setq search-regexp (concat "^Subject: *\\(Re: *\\)?"
- (regexp-quote subject)
- "\n"))
+ (let ((forward (> n 0))
+ search-regexp i found)
+ (with-current-buffer rmail-buffer
+ (setq search-regexp (rmail-current-subject-regexp)
+ i rmail-current-message))
(save-excursion
(while (and (/= n 0)
(if forward
diff --git a/lisp/mail/sendmail.el b/lisp/mail/sendmail.el
index 0636596ae8d..3276adf31bb 100644
--- a/lisp/mail/sendmail.el
+++ b/lisp/mail/sendmail.el
@@ -49,8 +49,8 @@
:version "22.1")
;;;###autoload
-(defcustom mail-from-style 'angles "\
-*Specifies how \"From:\" fields look.
+(defcustom mail-from-style 'angles
+ "Specifies how \"From:\" fields look.
If `nil', they contain just the return address like:
king@grassland.com
@@ -72,7 +72,7 @@ controlled by a separate variable, `mail-specify-envelope-from'."
;;;###autoload
(defcustom mail-specify-envelope-from nil
- "*If non-nil, specify the envelope-from address when sending mail.
+ "If non-nil, specify the envelope-from address when sending mail.
The value used to specify it is whatever is found in
the variable `mail-envelope-from', with `user-mail-address' as fallback.
@@ -85,7 +85,7 @@ variable `feedmail-deduce-envelope-from'."
:group 'sendmail)
(defcustom mail-envelope-from nil
- "*If non-nil, designate the envelope-from address when sending mail.
+ "If non-nil, designate the envelope-from address when sending mail.
This only has an effect if `mail-specify-envelope-from' is non-nil.
The value should be either a string, or the symbol `header' (in
which case the contents of the \"From\" header of the message
@@ -98,29 +98,43 @@ being sent is used), or nil (in which case the value of
:group 'sendmail)
;;;###autoload
-(defcustom mail-self-blind nil "\
-*Non-nil means insert BCC to self in messages to be sent.
+(defcustom mail-self-blind nil
+ "Non-nil means insert BCC to self in messages to be sent.
This is done when the message is initialized,
so you can remove or alter the BCC field to override the default."
:type 'boolean
:group 'sendmail)
;;;###autoload
-(defcustom mail-interactive nil "\
-*Non-nil means when sending a message wait for and display errors.
+(defcustom mail-interactive nil
+ "Non-nil means when sending a message wait for and display errors.
nil means let mailer mail back a message to report errors."
:type 'boolean
:group 'sendmail)
-;;;###autoload
-(defcustom mail-yank-ignored-headers "^via:\\|^mail-from:\\|^origin:\\|^status:\\|^remailed\\|^received:\\|^message-id:\\|^summary-line:\\|^to:\\|^subject:\\|^in-reply-to:\\|^return-path:\\|^mail-reply-to:\\|^mail-followup-to:" "\
-*Delete these headers from old message when it's inserted in a reply."
+(defcustom mail-yank-ignored-headers
+ (concat "^"
+ (regexp-opt '("via" "mail-from" "origin" "status" "remailed"
+ "received" "message-id" "summary-line" "to" "subject"
+ "in-reply-to" "return-path" "mail-reply-to"
+ "mail-followup-to") "\\(?:")
+ ":")
+ "Delete these headers from old message when it's inserted in a reply."
:type 'regexp
:group 'sendmail)
+;; Prevent problems with `window-system' not having the correct value
+;; when loaddefs.el is loaded. `custom-reevaluate-setting' needs the
+;; standard value.
+;;;###autoload
+(put 'send-mail-function 'standard-value
+ '((if (and window-system (memq system-type '(darwin windows-nt)))
+ 'mailclient-send-it
+ 'sendmail-send-it)))
+
;; Useful to set in site-init.el
;;;###autoload
-(defcustom send-mail-function
+(defcustom send-mail-function
(if (and window-system (memq system-type '(darwin windows-nt)))
'mailclient-send-it
'sendmail-send-it)
@@ -138,30 +152,30 @@ This is used by the default mail-sending commands. See also
:group 'sendmail)
;;;###autoload
-(defcustom mail-header-separator "--text follows this line--" "\
-*Line used to separate headers from text in messages being composed."
+(defcustom mail-header-separator "--text follows this line--"
+ "Line used to separate headers from text in messages being composed."
:type 'string
:group 'sendmail)
;; Set up mail-header-separator for use as a category text property.
(put 'mail-header-separator 'rear-nonsticky '(category))
-;;; This was a nice idea, for preventing accidental modification of
-;;; the separator. But I found it also prevented or obstructed
-;;; certain deliberate operations, such as copying the separator line
-;;; up to the top to send myself a copy of an already sent outgoing message
-;;; and other things. So I turned it off. --rms.
-;;;(put 'mail-header-separator 'read-only t)
+;; This was a nice idea, for preventing accidental modification of
+;; the separator. But I found it also prevented or obstructed
+;; certain deliberate operations, such as copying the separator line
+;; up to the top to send myself a copy of an already sent outgoing message
+;; and other things. So I turned it off. --rms.
+;;(put 'mail-header-separator 'read-only t)
;;;###autoload
-(defcustom mail-archive-file-name nil "\
-*Name of file to write all outgoing messages in, or nil for none.
+(defcustom mail-archive-file-name nil
+ "Name of file to write all outgoing messages in, or nil for none.
This can be an inbox file or an Rmail file."
:type '(choice file (const nil))
:group 'sendmail)
;;;###autoload
(defcustom mail-default-reply-to nil
- "*Address to insert as default Reply-to field of outgoing messages.
+ "Address to insert as default Reply-to field of outgoing messages.
If nil, it will be initialized from the REPLYTO environment variable
when you first send mail."
:type '(choice (const nil) string)
@@ -169,7 +183,7 @@ when you first send mail."
;;;###autoload
(defcustom mail-alias-file nil
- "*If non-nil, the name of a file to use instead of `/usr/lib/aliases'.
+ "If non-nil, the name of a file to use instead of `/usr/lib/aliases'.
This file defines aliases to be expanded by the mailer; this is a different
feature from that of defining aliases in `.mailrc' to be expanded in Emacs.
This variable has no effect unless your system uses sendmail as its mailer."
@@ -178,7 +192,7 @@ This variable has no effect unless your system uses sendmail as its mailer."
;;;###autoload
(defcustom mail-personal-alias-file "~/.mailrc"
- "*If non-nil, the name of the user's personal mail alias file.
+ "If non-nil, the name of the user's personal mail alias file.
This file typically should be in same format as the `.mailrc' file used by
the `Mail' or `mailx' program.
This file need not actually exist."
@@ -207,14 +221,14 @@ The alias definitions in the file have this form:
;;;###autoload
(defcustom mail-yank-prefix nil
- "*Prefix insert on lines of yanked message being replied to.
+ "Prefix insert on lines of yanked message being replied to.
nil means use indentation."
:type '(choice (const nil) string)
:group 'sendmail)
;;;###autoload
(defcustom mail-indentation-spaces 3
- "*Number of spaces to insert at the beginning of each cited line.
+ "Number of spaces to insert at the beginning of each cited line.
Used by `mail-yank-original' via `mail-indent-citation'."
:type 'integer
:group 'sendmail)
@@ -230,7 +244,7 @@ It is semi-obsolete and mail agents should no longer use it.")
;;;###autoload
(defcustom mail-citation-hook nil
- "*Hook for modifying a citation just inserted in the mail buffer.
+ "Hook for modifying a citation just inserted in the mail buffer.
Each hook function can find the citation between (point) and (mark t),
and should leave point and mark around the citation text as modified.
The hook functions can find the header of the cited message
@@ -249,7 +263,7 @@ regardless of what part of it (if any) is included in the cited text.")
;;;###autoload
(defcustom mail-citation-prefix-regexp "[ \t]*[-a-z0-9A-Z]*>+[ \t]*\\|[ \t]*"
- "*Regular expression to match a citation prefix plus whitespace.
+ "Regular expression to match a citation prefix plus whitespace.
It should match whatever sort of citation prefixes you want to handle,
with whitespace before and after; it should also match just whitespace.
The default value matches citations like `foo-bar>' plus whitespace."
@@ -258,7 +272,90 @@ The default value matches citations like `foo-bar>' plus whitespace."
:version "20.3")
(defvar mail-abbrevs-loaded nil)
-(defvar mail-mode-map nil)
+(defvar mail-mode-map
+ (let ((map (make-sparse-keymap)))
+ (define-key map "\M-\t" 'mail-complete)
+ (define-key map "\C-c?" 'describe-mode)
+ (define-key map "\C-c\C-f\C-t" 'mail-to)
+ (define-key map "\C-c\C-f\C-b" 'mail-bcc)
+ (define-key map "\C-c\C-f\C-f" 'mail-fcc)
+ (define-key map "\C-c\C-f\C-c" 'mail-cc)
+ (define-key map "\C-c\C-f\C-s" 'mail-subject)
+ (define-key map "\C-c\C-f\C-r" 'mail-reply-to)
+ (define-key map "\C-c\C-f\C-a" 'mail-mail-reply-to) ; author
+ (define-key map "\C-c\C-f\C-l" 'mail-mail-followup-to) ; list
+ (define-key map "\C-c\C-t" 'mail-text)
+ (define-key map "\C-c\C-y" 'mail-yank-original)
+ (define-key map "\C-c\C-r" 'mail-yank-region)
+ (define-key map [remap split-line] 'mail-split-line)
+ (define-key map "\C-c\C-q" 'mail-fill-yanked-message)
+ (define-key map "\C-c\C-w" 'mail-signature)
+ (define-key map "\C-c\C-v" 'mail-sent-via)
+ (define-key map "\C-c\C-c" 'mail-send-and-exit)
+ (define-key map "\C-c\C-s" 'mail-send)
+ (define-key map "\C-c\C-i" 'mail-attach-file)
+
+ (define-key map [menu-bar mail]
+ (cons "Mail" (make-sparse-keymap "Mail")))
+
+ (define-key map [menu-bar mail fill]
+ '("Fill Citation" . mail-fill-yanked-message))
+
+ (define-key map [menu-bar mail yank]
+ '("Cite Original" . mail-yank-original))
+
+ (define-key map [menu-bar mail signature]
+ '("Insert Signature" . mail-signature))
+
+ (define-key map [menu-bar mail mail-sep]
+ '("--"))
+
+ (define-key map [menu-bar mail cancel]
+ '("Cancel" . mail-dont-send))
+
+ (define-key map [menu-bar mail send-stay]
+ '("Send, Keep Editing" . mail-send))
+
+ (define-key map [menu-bar mail send]
+ '("Send Message" . mail-send-and-exit))
+
+ (define-key map [menu-bar headers]
+ (cons "Headers" (make-sparse-keymap "Move to Header")))
+
+ (define-key map [menu-bar headers text]
+ '("Text" . mail-text))
+
+ (define-key map [menu-bar headers expand-aliases]
+ '("Expand Aliases" . expand-mail-aliases))
+
+ (define-key map [menu-bar headers sent-via]
+ '("Sent Via" . mail-sent-via))
+
+ (define-key map [menu-bar headers mail-reply-to]
+ '("Mail Reply To" . mail-mail-reply-to))
+
+ (define-key map [menu-bar headers mail-followup-to]
+ '("Mail Followup To" . mail-mail-followup-to))
+
+ (define-key map [menu-bar headers reply-to]
+ '("Reply-To" . mail-reply-to))
+
+ (define-key map [menu-bar headers bcc]
+ '("Bcc" . mail-bcc))
+
+ (define-key map [menu-bar headers fcc]
+ '("Fcc" . mail-fcc))
+
+ (define-key map [menu-bar headers cc]
+ '("Cc" . mail-cc))
+
+ (define-key map [menu-bar headers subject]
+ '("Subject" . mail-subject))
+
+ (define-key map [menu-bar headers to]
+ '("To" . mail-to))
+
+ map))
(autoload 'build-mail-aliases "mailalias"
"Read mail aliases from user's personal aliases file and set `mail-aliases'."
@@ -273,7 +370,7 @@ removed from alias expansions."
;;;###autoload
(defcustom mail-signature nil
- "*Text inserted at end of mail buffer when a message is initialized.
+ "Text inserted at end of mail buffer when a message is initialized.
If t, it means to insert the contents of the file `mail-signature-file'.
If a string, that string is inserted.
(To make a proper signature, the string should begin with \\n\\n-- \\n,
@@ -289,13 +386,13 @@ and should insert whatever you want to insert."
;;;###autoload
(defcustom mail-signature-file "~/.signature"
- "*File containing the text inserted at end of mail buffer."
+ "File containing the text inserted at end of mail buffer."
:type 'file
:group 'sendmail)
;;;###autoload
(defcustom mail-default-directory "~/"
- "*Directory for mail buffers.
+ "Directory for mail buffers.
Value of `default-directory' for mail buffers.
This directory is used for auto-save files of mail buffers."
:type '(directory :tag "Directory")
@@ -310,7 +407,7 @@ This directory is used for auto-save files of mail buffers."
;;;###autoload
(defcustom mail-default-headers nil
- "*A string containing header lines, to be inserted in outgoing messages.
+ "A string containing header lines, to be inserted in outgoing messages.
It is inserted before you edit the message,
so you can edit or delete these lines."
:type '(choice (const nil) string)
@@ -318,7 +415,7 @@ so you can edit or delete these lines."
;;;###autoload
(defcustom mail-bury-selects-summary t
- "*If non-nil, try to show RMAIL summary buffer after returning from mail.
+ "If non-nil, try to show RMAIL summary buffer after returning from mail.
The functions \\[mail-send-on-exit] or \\[mail-dont-send] select
the RMAIL summary buffer before returning, if it exists and this variable
is non-nil."
@@ -327,7 +424,7 @@ is non-nil."
;;;###autoload
(defcustom mail-send-nonascii 'mime
- "*Specify whether to allow sending non-ASCII characters in mail.
+ "Specify whether to allow sending non-ASCII characters in mail.
If t, that means do allow it. nil means don't allow it.
`query' means ask the user each time.
`mime' means add an appropriate MIME header if none already present.
@@ -338,7 +435,7 @@ for the recipient, who may not know how to decode them properly."
:group 'sendmail)
(defcustom mail-use-dsn nil
- "*Ask MTA for notification of failed, delayed or successful delivery.
+ "Ask MTA for notification of failed, delayed or successful delivery.
Note that only some MTAs (currently only recent versions of Sendmail)
support Delivery Status Notification."
:group 'sendmail
@@ -352,15 +449,11 @@ support Delivery Status Notification."
(defvar mail-mailer-swallows-blank-line
(if (and (string-match "sparc-sun-sunos\\(\\'\\|[^5]\\)" system-configuration)
(file-readable-p "/etc/sendmail.cf")
- (let ((buffer (get-buffer-create " *temp*")))
- (unwind-protect
- (save-excursion
- (set-buffer buffer)
- (insert-file-contents "/etc/sendmail.cf")
- (goto-char (point-min))
- (let ((case-fold-search nil))
- (re-search-forward "^OR\\>" nil t)))
- (kill-buffer buffer))))
+ (with-temp-buffer
+ (insert-file-contents "/etc/sendmail.cf")
+ (goto-char (point-min))
+ (let ((case-fold-search nil))
+ (re-search-forward "^OR\\>" nil t))))
;; According to RFC822, "The field-name must be composed of printable
;; ASCII characters (i.e. characters that have decimal values between
;; 33 and 126, except colon)", i.e. any chars except ctl chars,
@@ -512,7 +605,10 @@ actually occur.")
(define-derived-mode mail-mode text-mode "Mail"
"Major mode for editing mail to be sent.
Like Text Mode but with these additional commands:
-\\[mail-send] mail-send (send the message) \\[mail-send-and-exit] mail-send-and-exit
+
+\\[mail-send] mail-send (send the message)
+\\[mail-send-and-exit] mail-send-and-exit (send the message and exit)
+
Here are commands that move to a header field (and create it if there isn't):
\\[mail-to] move to To: \\[mail-subject] move to Subject:
\\[mail-cc] move to CC: \\[mail-bcc] move to BCC:
@@ -632,7 +728,7 @@ If within the headers, this makes the new lines into continuation lines."
(while (search-forward "," end t)
(or (looking-at "[ \t]")
(insert " "))))
- (fill-region-as-paragraph beg end)
+ (fill-region-as-paragraph beg end arg)
;; Mark all lines except the first as continuations.
(goto-char beg)
(forward-line 1)
@@ -642,92 +738,6 @@ If within the headers, this makes the new lines into continuation lines."
(move-marker end nil)
t)))
-;;; Set up keymap.
-
-(if mail-mode-map
- nil
- (setq mail-mode-map (make-sparse-keymap))
- (define-key mail-mode-map "\M-\t" 'mail-complete)
- (define-key mail-mode-map "\C-c?" 'describe-mode)
- (define-key mail-mode-map "\C-c\C-f\C-t" 'mail-to)
- (define-key mail-mode-map "\C-c\C-f\C-b" 'mail-bcc)
- (define-key mail-mode-map "\C-c\C-f\C-f" 'mail-fcc)
- (define-key mail-mode-map "\C-c\C-f\C-c" 'mail-cc)
- (define-key mail-mode-map "\C-c\C-f\C-s" 'mail-subject)
- (define-key mail-mode-map "\C-c\C-f\C-r" 'mail-reply-to)
- (define-key mail-mode-map "\C-c\C-f\C-a" 'mail-mail-reply-to) ; author
- (define-key mail-mode-map "\C-c\C-f\C-l" 'mail-mail-followup-to) ; list
- (define-key mail-mode-map "\C-c\C-t" 'mail-text)
- (define-key mail-mode-map "\C-c\C-y" 'mail-yank-original)
- (define-key mail-mode-map "\C-c\C-r" 'mail-yank-region)
- (define-key mail-mode-map [remap split-line] 'mail-split-line)
- (define-key mail-mode-map "\C-c\C-q" 'mail-fill-yanked-message)
- (define-key mail-mode-map "\C-c\C-w" 'mail-signature)
- (define-key mail-mode-map "\C-c\C-v" 'mail-sent-via)
- (define-key mail-mode-map "\C-c\C-c" 'mail-send-and-exit)
- (define-key mail-mode-map "\C-c\C-s" 'mail-send)
- (define-key mail-mode-map "\C-c\C-i" 'mail-attach-file))
-
-(define-key mail-mode-map [menu-bar mail]
- (cons "Mail" (make-sparse-keymap "Mail")))
-
-(define-key mail-mode-map [menu-bar mail fill]
- '("Fill Citation" . mail-fill-yanked-message))
-
-(define-key mail-mode-map [menu-bar mail yank]
- '("Cite Original" . mail-yank-original))
-
-(define-key mail-mode-map [menu-bar mail signature]
- '("Insert Signature" . mail-signature))
-
-(define-key mail-mode-map [menu-bar mail mail-sep]
- '("--"))
-
-(define-key mail-mode-map [menu-bar mail cancel]
- '("Cancel" . mail-dont-send))
-
-(define-key mail-mode-map [menu-bar mail send-stay]
- '("Send, Keep Editing" . mail-send))
-
-(define-key mail-mode-map [menu-bar mail send]
- '("Send Message" . mail-send-and-exit))
-
-(define-key mail-mode-map [menu-bar headers]
- (cons "Headers" (make-sparse-keymap "Move to Header")))
-
-(define-key mail-mode-map [menu-bar headers text]
- '("Text" . mail-text))
-
-(define-key mail-mode-map [menu-bar headers expand-aliases]
- '("Expand Aliases" . expand-mail-aliases))
-
-(define-key mail-mode-map [menu-bar headers sent-via]
- '("Sent Via" . mail-sent-via))
-
-(define-key mail-mode-map [menu-bar headers mail-reply-to]
- '("Mail Reply To" . mail-mail-reply-to))
-
-(define-key mail-mode-map [menu-bar headers mail-followup-to]
- '("Mail Followup To" . mail-mail-followup-to))
-
-(define-key mail-mode-map [menu-bar headers reply-to]
- '("Reply-To" . mail-reply-to))
-
-(define-key mail-mode-map [menu-bar headers bcc]
- '("Bcc" . mail-bcc))
-
-(define-key mail-mode-map [menu-bar headers fcc]
- '("Fcc" . mail-fcc))
-
-(define-key mail-mode-map [menu-bar headers cc]
- '("Cc" . mail-cc))
-
-(define-key mail-mode-map [menu-bar headers subject]
- '("Subject" . mail-subject))
-
-(define-key mail-mode-map [menu-bar headers to]
- '("To" . mail-to))
-
;; User-level commands for sending.
(defun mail-send-and-exit (&optional arg)
@@ -759,8 +769,8 @@ Prefix arg means don't delete this window."
(let (rmail-flag summary-buffer)
(and (not arg)
(not (one-window-p))
- (save-excursion
- (set-buffer (window-buffer (next-window (selected-window) 'not)))
+ (with-current-buffer
+ (window-buffer (next-window (selected-window) 'not))
(setq rmail-flag (eq major-mode 'rmail-mode))
(setq summary-buffer
(and mail-bury-selects-summary
@@ -987,8 +997,7 @@ external program defined by `sendmail-program'."
(and mail-specify-envelope-from
(or (mail-envelope-from) user-mail-address))))
(unwind-protect
- (save-excursion
- (set-buffer tembuf)
+ (with-current-buffer tembuf
(erase-buffer)
(unless multibyte
(set-buffer-multibyte nil))
@@ -1072,8 +1081,8 @@ external program defined by `sendmail-program'."
(goto-char delimline)
(insert "MIME-version: 1.0\n"
"Content-type: text/plain; charset="
- (symbol-name charset) "\n"
- "Content-Transfer-Encoding: 8bit\n")))
+ (symbol-name charset)
+ "\nContent-Transfer-Encoding: 8bit\n")))
;; Insert an extra newline if we need it to work around
;; Sun's bug that swallows newlines.
(goto-char (1+ delimline))
@@ -1086,8 +1095,7 @@ external program defined by `sendmail-program'."
(setq fcc-was-found t)
(mail-do-fcc delimline)))
(if mail-interactive
- (save-excursion
- (set-buffer errbuf)
+ (with-current-buffer errbuf
(erase-buffer))))
(goto-char (point-min))
(if (let ((case-fold-search t))
@@ -1133,8 +1141,7 @@ external program defined by `sendmail-program'."
(or fcc-was-found
(error "No recipients")))
(if mail-interactive
- (save-excursion
- (set-buffer errbuf)
+ (with-current-buffer errbuf
(goto-char (point-min))
(while (re-search-forward "\n\n* *" nil t)
(replace-match "; "))
@@ -1146,22 +1153,22 @@ external program defined by `sendmail-program'."
(kill-buffer errbuf)))))
(defun mail-do-fcc (header-end)
+ (unless (markerp header-end)
+ (error "Value of `header-end' must be a marker"))
(let (fcc-list
(rmailbuf (current-buffer))
(time (current-time))
(tembuf (generate-new-buffer " rmail output"))
(case-fold-search t))
- (unless (markerp header-end)
- (error "Value of `header-end' must be a marker"))
(save-excursion
(goto-char (point-min))
(while (re-search-forward "^FCC:[ \t]*" header-end t)
- (setq fcc-list (cons (buffer-substring (point)
- (progn
- (end-of-line)
- (skip-chars-backward " \t")
- (point)))
- fcc-list))
+ (push (buffer-substring (point)
+ (progn
+ (end-of-line)
+ (skip-chars-backward " \t")
+ (point)))
+ fcc-list)
(delete-region (match-beginning 0)
(progn (forward-line 1) (point))))
(set-buffer tembuf)
@@ -1187,8 +1194,8 @@ external program defined by `sendmail-program'."
(while (search-forward "\nFrom " nil t)
(forward-char -5)
(insert ?>)))
- (while fcc-list
- (let* ((buffer (find-buffer-visiting (car fcc-list)))
+ (dolist (fcc fcc-list)
+ (let* ((buffer (find-buffer-visiting fcc))
(curbuf (current-buffer))
dont-write-the-file
buffer-matches-file
@@ -1197,8 +1204,7 @@ external program defined by `sendmail-program'."
(forward-line 2) (point))))
(if buffer
;; File is present in a buffer => append to that buffer.
- (save-excursion
- (set-buffer buffer)
+ (with-current-buffer buffer
(setq buffer-matches-file
(and (not (buffer-modified-p))
(verify-visited-file-modtime buffer)))
@@ -1239,40 +1245,38 @@ external program defined by `sendmail-program'."
(or buffer-matches-file
(progn
(if (y-or-n-p (format "Save file %s? "
- (car fcc-list)))
+ fcc))
(save-buffer))
(setq dont-write-the-file t))))
(if max (narrow-to-region (point-min) max))))))
;; Append to the file directly,
;; unless we've already taken care of it.
(unless dont-write-the-file
- (if (and (file-exists-p (car fcc-list))
+ (if (and (file-exists-p fcc)
;; Check that the file isn't empty. We don't
;; want to insert a newline at the start of an
;; empty file.
- (not (zerop (nth 7 (file-attributes (car fcc-list)))))
- (mail-file-babyl-p (car fcc-list)))
+ (not (zerop (nth 7 (file-attributes fcc))))
+ (mail-file-babyl-p fcc))
;; If the file is a Babyl file,
;; convert the message to Babyl format.
(let ((coding-system-for-write
(or rmail-file-coding-system
'emacs-mule)))
- (save-excursion
- (set-buffer (get-buffer-create " mail-temp"))
+ (with-current-buffer (get-buffer-create " mail-temp")
(setq buffer-read-only nil)
(erase-buffer)
- (insert "\C-l\n0, unseen,,\n*** EOOH ***\n"
- "Date: " (mail-rfc822-date) "\n")
+ (insert "\C-l\n0, unseen,,\n*** EOOH ***\nDate: "
+ (mail-rfc822-date) "\n")
(insert-buffer-substring curbuf beg2 end)
(insert "\n\C-_")
- (write-region (point-min) (point-max) (car fcc-list) t)
+ (write-region (point-min) (point-max) fcc t)
(erase-buffer)))
(write-region
- (1+ (point-min)) (point-max) (car fcc-list) t)))
+ (1+ (point-min)) (point-max) fcc t)))
(and buffer (not dont-write-the-file)
(with-current-buffer buffer
- (set-visited-file-modtime))))
- (setq fcc-list (cdr fcc-list))))
+ (set-visited-file-modtime))))))
(kill-buffer tembuf)))
(defun mail-sent-via ()
@@ -1281,8 +1285,7 @@ external program defined by `sendmail-program'."
(save-excursion
;; put a marker at the end of the header
(let ((end (copy-marker (mail-header-end)))
- (case-fold-search t)
- to-line)
+ (case-fold-search t))
(goto-char (point-min))
;; search for the To: lines and make Sent-via: lines from them
;; search for the next To: line
@@ -1625,10 +1628,10 @@ The seventh argument ACTIONS is a list of actions to take
when the message is sent, we apply FUNCTION to ARGS.
This is how Rmail arranges to mark messages `answered'."
(interactive "P")
-;;; This is commented out because I found it was confusing in practice.
-;;; It is easy enough to rename *mail* by hand with rename-buffer
-;;; if you want to have multiple mail buffers.
-;;; And then you can control which messages to save. --rms.
+;;; This is commented out because I found it was confusing in practice.
+;;; It is easy enough to rename *mail* by hand with rename-buffer
+;;; if you want to have multiple mail buffers.
+;;; And then you can control which messages to save. --rms.
;;; (let ((index 1)
;;; buffer)
;;; ;; If requested, look for a mail buffer that is modified and go to it.
@@ -1687,7 +1690,7 @@ The seventh argument ACTIONS is a list of actions to take
(mail-mode)
;; Disconnect the buffer from its visited file
;; (in case the user has actually visited a file *mail*).
-; (set-visited-file-name nil)
+;;; (set-visited-file-name nil)
(let (initialized)
(and (not (and noerase
(not (eq noerase 'new))))
@@ -1855,9 +1858,9 @@ you can move to one of them and type C-c C-c to recover that one."
(pop-to-buffer "*mail*"))
(mail noerase to subject in-reply-to cc replybuffer sendactions))
-;;; Do not add anything but external entries on this page.
+;; Do not add anything but external entries on this page.
(provide 'sendmail)
-;;; arch-tag: 48bc1025-d993-4d31-8d81-2a29491f0626
+;; arch-tag: 48bc1025-d993-4d31-8d81-2a29491f0626
;;; sendmail.el ends here
diff --git a/lisp/mail/smtpmail.el b/lisp/mail/smtpmail.el
index 55a4d060fad..4c7e99601b8 100644
--- a/lisp/mail/smtpmail.el
+++ b/lisp/mail/smtpmail.el
@@ -1,6 +1,6 @@
;;; smtpmail.el --- simple SMTP protocol (RFC 821) for sending mail
-;; Copyright (C) 1995, 1996, 2001, 2002, 2003, 2004, 2005
+;; Copyright (C) 1995, 1996, 2001, 2002, 2003, 2004, 2005, 2006
;; Free Software Foundation, Inc.
;; Author: Tomoji Kagatani <kagatani@rbc.ncl.omron.co.jp>
@@ -365,7 +365,7 @@ This is relative to `smtpmail-queue-dir'.")
(make-directory smtpmail-queue-dir t))
(with-current-buffer buffer-data
(erase-buffer)
- (insert-buffer tembuf)
+ (insert-buffer-contents tembuf)
(write-file file-data)
(set-buffer buffer-elisp)
(erase-buffer)
@@ -560,16 +560,18 @@ This is relative to `smtpmail-queue-dir'.")
(>= (car ret) 400))
(throw 'done nil)))
((eq mech 'plain)
- (smtpmail-send-command process "AUTH PLAIN")
- (if (or (null (car (setq ret (smtpmail-read-response process))))
- (not (integerp (car ret)))
- (not (equal (car ret) 334)))
- (throw 'done nil))
- (smtpmail-send-command process (base64-encode-string
+ ;; We used to send an empty initial request, and wait for an
+ ;; empty response, and then send the password, but this
+ ;; violate a SHOULD in RFC 2222 paragraph 5.1. Note that this
+ ;; is not sent if the server did not advertise AUTH PLAIN in
+ ;; the EHLO response. See RFC 2554 for more info.
+ (smtpmail-send-command process
+ (concat "AUTH PLAIN "
+ (base64-encode-string
(concat "\0"
(smtpmail-cred-user cred)
"\0"
- (smtpmail-cred-passwd cred))))
+ passwd))))
(if (or (null (car (setq ret (smtpmail-read-response process))))
(not (integerp (car ret)))
(not (equal (car ret) 235)))
@@ -605,6 +607,7 @@ This is relative to `smtpmail-queue-dir'.")
;; clear the trace buffer of old output
(with-current-buffer process-buffer
+ (setq buffer-undo-list t)
(erase-buffer))
;; open the connection to the server