- "Compose mail in other window.
-Customize the variable `gnus-mail-other-window-method' to use another
-mailer."
- (interactive)
- (gnus-set-global-variables)
- (gnus-new-mail))
-
-(defun gnus-new-mail (&optional to)
- (pop-to-buffer gnus-mail-buffer)
- (erase-buffer)
- (gnus-mail-setup 'new to)
- (gnus-inews-modify-mail-mode-map))
-
-(defun gnus-mail-reply (&optional yank to-address followup)
- (save-excursion
- (set-buffer gnus-summary-buffer)
- (let ((group (gnus-group-real-name gnus-newsgroup-name))
- (cur (cons (current-buffer) (cdr gnus-article-current)))
- (winconf (current-window-configuration))
- from subject date reply-to message-of to cc
- references message-id sender follow-to sendto elt new-cc)
- (set-buffer (get-buffer-create gnus-mail-buffer))
- (mail-mode)
- (if (and (buffer-modified-p)
- (> (buffer-size) 0)
- (not (gnus-y-or-n-p
- "Unsent message being composed; erase it? ")))
- ()
- (erase-buffer)
- (save-excursion
- (gnus-copy-article-buffer)
- (save-restriction
- (set-buffer gnus-article-copy)
- (gnus-narrow-to-headers)
- (if (not followup)
- ;; This is a regular reply.
- (if (and (symbolp gnus-reply-to-function)
- (fboundp gnus-reply-to-function))
- (setq follow-to (funcall gnus-reply-to-function group)))
- ;; This is a followup.
- (if (and (symbolp gnus-followup-to-function)
- (fboundp gnus-followup-to-function))
- (save-excursion
- (setq follow-to
- (funcall gnus-followup-to-function group)))))
- (setq from (mail-fetch-field "from"))
- (setq date (or (mail-fetch-field "date")
- (mail-header-date gnus-current-headers)))
- (setq message-of (gnus-message-of from date))
- (setq sender (mail-fetch-field "sender"))
- (setq subject (or (mail-fetch-field "subject") "none"))
- ;; Remove any (buggy) Re:'s that are present and make a
- ;; proper one.
- (and (string-match "^[ \t]*[Re][Ee]:[ \t]*" subject)
- (setq subject (substring subject (match-end 0))))
- (setq subject (concat "Re: " subject))
- (setq to (mail-fetch-field "to"))
- (setq cc (mail-fetch-field "cc"))
- (setq reply-to (mail-fetch-field "reply-to"))
- (setq references (mail-fetch-field "references"))
- (setq message-id (mail-fetch-field "message-id"))
-
- (if (not followup)
- ()
- ;; When we followup, we want all the headers, I would think.
- (setq new-cc (rmail-dont-reply-to
- (concat (or to "")
- (if cc (concat (if to ", " "") cc) ""))))
- (let ((rmail-dont-reply-to-names
- (regexp-quote (mail-strip-quoted-names
- (or to-address reply-to from "")))))
- (setq new-cc (rmail-dont-reply-to new-cc))))
-
- (widen)))
-
- (setq news-reply-yank-from (or from "(nobody)"))
- (setq news-reply-yank-message-id
- (or message-id "(unknown Message-ID)"))
-
- ;; Gather the "to" addresses out of the follow-to list and remove
- ;; them as we go.
- (if (and follow-to (listp follow-to))
- (while (setq elt (assoc "To" follow-to))
- (setq sendto (concat sendto (and sendto ", ") (cdr elt)))
- (setq follow-to (delq elt follow-to))))
-
- (gnus-mail-setup
- (if followup 'followup 'reply)
- (or to-address
- (if (and follow-to (not (stringp follow-to))) sendto
- (or follow-to reply-to from sender "")))
- subject message-of
- (if (zerop (length new-cc)) nil new-cc)
- gnus-article-copy)
-
- (make-local-variable 'gnus-article-reply)
- (setq gnus-article-reply cur)
- (make-local-variable 'gnus-prev-winconf)
- (setq gnus-prev-winconf winconf)
- (make-local-variable 'gnus-reply-subject)
- (setq gnus-reply-subject subject)
- (make-local-variable 'gnus-in-reply-to)
- (setq gnus-in-reply-to message-of)
-
- (auto-save-mode auto-save-default)
- (gnus-inews-modify-mail-mode-map)
-
- (if (and follow-to (listp follow-to))
- (progn
- (goto-char (point-min))
- (re-search-forward "^To:" nil t)
- (beginning-of-line)
- (forward-line 1)
- (while follow-to
- (insert (car (car follow-to)) ": " (cdr (car follow-to)) "\n")
- (setq follow-to (cdr follow-to)))))
- (nnheader-insert-references references message-id)
-
- ;; Now the headers should be ok, so we do the yanking.
- (goto-char (point-min))
- (re-search-forward
- (concat "^" (regexp-quote mail-header-separator) "$"))
- (forward-line 1)
- (if (not yank)
- (gnus-configure-windows 'reply 'force)
- (let ((last (point))
- end)
- (if (not (listp yank))
- (progn
- (save-excursion
- (mail-yank-original nil))
- (or mail-yank-hooks mail-citation-hook
- (run-hooks 'news-reply-header-hook)))
- (while yank
- (save-window-excursion
- (set-buffer gnus-summary-buffer)
- (gnus-summary-select-article nil nil nil (car yank))
- (gnus-summary-remove-process-mark (car yank)))
- (save-excursion
- (gnus-copy-article-buffer)
- (mail-yank-original nil)
- (setq end (point)))
- (or mail-yank-hooks mail-citation-hook
- (run-hooks 'news-reply-header-hook))
- (goto-char end)
- (setq yank (cdr yank))))
- (goto-char last))
- (gnus-configure-windows 'reply-yank 'force))
- (run-hooks 'gnus-mail-hook)))))
-
-(defun gnus-new-news (&optional group)
- (let ((winconf (current-window-configuration))
- subject)
- (and gnus-interactive-post
- (not gnus-expert-user)
- (not group)
- (progn
- (setq gnus-newsgroup-name
- (setq group
- (completing-read "Group: " gnus-active-hashtb)))
- (setq subject (read-string "Subject: "))))
- (pop-to-buffer gnus-post-news-buffer)
- (erase-buffer)
- (news-reply-mode)
- ;; Let posting styles be configured.
- (gnus-configure-posting-styles)
- (news-setup nil subject nil (gnus-group-real-name group) nil)
- (gnus-inews-insert-signature)
- (and gnus-post-prepare-function
- (symbolp gnus-post-prepare-function)
- (fboundp gnus-post-prepare-function)
- (funcall gnus-post-prepare-function group))
- (run-hooks 'gnus-post-prepare-hook)
- (make-local-variable 'gnus-prev-winconf)
- (setq gnus-prev-winconf winconf)
- (gnus-inews-modify-mail-mode-map)
- (local-set-key "\C-c\C-c" 'gnus-inews-news)))
-
-(defun gnus-news-followup (&optional yank group)
- (save-excursion
- (set-buffer gnus-summary-buffer)
- (if (not (or (not gnus-novice-user)
- gnus-expert-user
- (gnus-y-or-n-p
- "Are you sure you want to post to all of USENET? ")))
- ()
- (let ((group (gnus-group-real-name (or group gnus-newsgroup-name)))
- (cur (cons (current-buffer) (cdr gnus-article-current)))
- (winconf (current-window-configuration))
- from subject date reply-to message-of
- references message-id sender follow-to sendto elt
- followup-to distribution)
- (set-buffer (get-buffer-create gnus-post-news-buffer))
- (news-reply-mode)
- (if (and (buffer-modified-p)
- (> (buffer-size) 0)
- (not (gnus-y-or-n-p
- "Unsent message being composed; erase it? ")))
- ()
- (erase-buffer)
- (save-excursion
- (gnus-copy-article-buffer)
- (save-restriction
- (set-buffer gnus-article-copy)
- (gnus-narrow-to-headers)
- (if (and (symbolp gnus-followup-to-function)
- (fboundp gnus-followup-to-function))
- (save-excursion
- (setq follow-to
- (funcall gnus-followup-to-function group))))
- (setq from (mail-fetch-field "from"))
- (setq date (or (mail-fetch-field "date")
- (mail-header-date gnus-current-headers)))
- (setq message-of (gnus-message-of from date))
- (setq subject (or (mail-fetch-field "subject") "none"))
- ;; Remove any (buggy) Re:'s that are present and make a
- ;; proper one.
- (and (string-match "^[ \t]*[Re][Ee]:[ \t]*" subject)
- (setq subject (substring subject (match-end 0))))
- (setq subject (concat "Re: " subject))
- (setq references (mail-fetch-field "references"))
- (setq message-id (mail-fetch-field "message-id"))
- (setq followup-to (mail-fetch-field "followup-to"))
- (setq distribution (mail-fetch-field "distribution"))
- ;; Remove bogus distribution.
- (and (stringp distribution)
- (string-match "world" distribution)
- (setq distribution nil))
- (widen)))
-
- (setq news-reply-yank-from (or from "(nobody)"))
- (setq news-reply-yank-message-id
- (or message-id "(unknown Message-ID)"))
-
- ;; Gather the "to" addresses out of the follow-to list and remove
- ;; them as we go.
- (if (and follow-to (listp follow-to))
- (while (setq elt (assoc "Newsgroups" follow-to))
- (setq sendto (concat sendto (and sendto ", ") (cdr elt)))
- (setq follow-to (delq elt follow-to))))
-
- ;; Let posting styles be configured.
- (gnus-configure-posting-styles)
-
- (news-setup nil subject nil
- (or group sendto
- (and follow-to
- gnus-use-followup-to
- (or (not (eq gnus-use-followup-to 'ask))
- (gnus-y-or-n-p
- (format
- "Use Followup-To %s? " follow-to))))
- group "")
- gnus-article-copy)
-
- (make-local-variable 'gnus-article-reply)
- (setq gnus-article-reply cur)
- (make-local-variable 'gnus-prev-winconf)
- (setq gnus-prev-winconf winconf)
- (make-local-variable 'gnus-reply-subject)
- (setq gnus-reply-subject (mail-header-subject gnus-current-headers))
- (make-local-variable 'gnus-in-reply-to)
- (setq gnus-in-reply-to message-of)
-
- (gnus-inews-insert-signature)
-
- (and gnus-post-prepare-function
- (symbolp gnus-post-prepare-function)
- (fboundp gnus-post-prepare-function)
- (funcall gnus-post-prepare-function group))
- (run-hooks 'gnus-post-prepare-hook)
-
- (auto-save-mode auto-save-default)
- (gnus-inews-modify-mail-mode-map)
- (local-set-key "\C-c\C-c" 'gnus-inews-news)
-
- (if (and follow-to (listp follow-to))
- (progn
- (goto-char (point-min))
- (and (re-search-forward "^Newsgroups:" nil t)
- (forward-line 1))
- (while follow-to
- (insert (car (car follow-to)) ": "
- (cdr (car follow-to)) "\n")
- (setq follow-to (cdr follow-to)))))
-
- ;; If a distribution existed, we use it.
- (if distribution
- (progn
- (mail-position-on-field "Distribution")
- (insert distribution)))
-
- (nnheader-insert-references references message-id)
-
- ;; Handle `gnus-auto-mail-to-author'.
- ;; Suggested by Daniel Quinlan <quinlan@best.com>.
- ;; Revised to respect Reply-To by Ulrik Dickow <dickow@nbi.dk>.
- (let ((to (if (if (eq gnus-auto-mail-to-author 'ask)
- (y-or-n-p "Also send mail to author? ")
- gnus-auto-mail-to-author)
- (or (save-excursion
- (set-buffer gnus-article-copy)
- (gnus-fetch-field "reply-to"))
- from)))
- (x-mail (save-excursion
- (set-buffer gnus-article-copy)
- (gnus-fetch-field "x-mail-copy-to"))))
- ;; Deny sending copy if there's a negative X-Mail-Copy-To
- ;; header.
- (if x-mail
- (if (and (string= x-mail "never")
- (not (eq gnus-auto-mail-to-author 'force)))
- (setq to nil)
- (setq to x-mail)))
- ;; Insert a To or Cc header.
- (if to
- (if (mail-fetch-field "To")
- (progn
- (beginning-of-line)
- (insert "Cc: " to "\n"))
- (mail-position-on-field "To")
- (insert to))))
-
- ;; Handle author copy using BCC field.
- (if (and gnus-mail-self-blind
- (not (mail-fetch-field "bcc")))
- (progn
- (mail-position-on-field "Bcc")
- (insert (if (stringp gnus-mail-self-blind)
- gnus-mail-self-blind
- (user-login-name)))))
- ;; Handle author copy using FCC field.
- (if gnus-author-copy
- (progn
- (mail-position-on-field "Fcc")
- (insert gnus-author-copy)))
-
- ;; Now the headers should be ok, so we do the yanking.
- (goto-char (point-min))
- (re-search-forward
- (concat "^" (regexp-quote mail-header-separator) "$"))
- (forward-line 1)
- (if (not yank)
- (gnus-configure-windows 'followup 'force)
- (let ((last (point))
- end)
- (if (not (listp yank))
- (progn
- (save-excursion
- (mail-yank-original nil))
- (or mail-yank-hooks mail-citation-hook
- (run-hooks 'news-reply-header-hook)))
- (while yank
- (save-window-excursion
- (set-buffer gnus-summary-buffer)
- (gnus-summary-select-article nil nil nil (car yank))
- (gnus-summary-remove-process-mark (car yank)))
- (save-excursion
- (gnus-copy-article-buffer)
- (mail-yank-original nil)
- (setq end (point)))
- (or mail-yank-hooks mail-citation-hook
- (run-hooks 'news-reply-header-hook))
- (goto-char end)
- (setq yank (cdr yank))))
- (goto-char last))
- (gnus-configure-windows 'followup-yank 'force))
-
- (make-local-variable 'gnus-article-check-size)
- (setq gnus-article-check-size
- (cons (buffer-size) (gnus-article-checksum))))))))
-
-(defun gnus-message-of (from date)
- "Take a FROM and a DATE and create an IN-REPLY-TO."
- (cond
- ((not from)
- nil)
- (t
- (let ((stop-pos
- (string-match " *at \\| *@ \\| *(\\| *<" from)))
- (concat (if stop-pos (substring from 0 stop-pos) from)
- "'s message of "
- (if (or (not date) (string= date ""))
- "(unknown date)" date))))))
-
-(defun gnus-mail-yank-original ()
- (interactive)
- (save-excursion
- (mail-yank-original nil))
- (or mail-yank-hooks mail-citation-hook
- (run-hooks 'news-reply-header-hook)))
-
-(defun gnus-mail-send-and-exit (&optional dont-send)
- "Send the current mail and return to Gnus."