-(defun gnus-new-news (&optional group inhibit-prompt)
- "Set up a *post-news* buffer that points to GROUP.
-If INHIBIT-PROMPT, never prompt for a Subject."
- (let ((winconf (current-window-configuration))
- subject)
- (when (and gnus-interactive-post
- (not inhibit-prompt)
- (not gnus-expert-user))
- (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 (and group (gnus-group-real-name group)) nil)
- ;; Associate this buffer with the draft group.
- (gnus-enter-buffer-into-draft)
- (goto-char (point-min))
-
- (unless (re-search-forward
- (concat "^" (regexp-quote mail-header-separator) "$") nil t)
- (goto-char (point-max)))
- (insert "\n\n")
-
- (gnus-inews-insert-bfcc)
- (gnus-inews-insert-gcc)
- (gnus-inews-insert-archive-gcc)
- (gnus-inews-insert-signature)
- (and gnus-post-prepare-function
- (gnus-functionp gnus-post-prepare-function)
- (funcall gnus-post-prepare-function group))
- (run-hooks 'gnus-post-prepare-hook)
- (gnus-inews-set-point)
- (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 newsgroups)
- (set-buffer (get-buffer-create gnus-post-news-buffer))
- (news-reply-mode)
- ;; Associate this buffer with the draft group.
- (gnus-enter-buffer-into-draft)
- (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)
- (nnheader-narrow-to-headers)
- (if (gnus-functionp 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 newsgroups (mail-fetch-field "newsgroups"))
- (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 sendto
- (and followup-to
- gnus-use-followup-to
- (or (not (eq gnus-use-followup-to 'ask))
- (gnus-y-or-n-p
- (format
- "Use Followup-To %s? " followup-to)))
- followup-to)
- newsgroups 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)
- (when (and followup-to newsgroups)
- (make-local-variable 'gnus-newsgroup-followup)
- (setq gnus-newsgroup-followup
- (cons newsgroups followup-to)))
-
- (gnus-inews-insert-signature)
-
- (and gnus-post-prepare-function
- (gnus-functionp 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)
- (unless (gnus-group-get-parameter
- group 'broken-reply-to)
- (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))))
-
- (gnus-inews-insert-bfcc)
- (gnus-inews-insert-gcc)
- (gnus-inews-insert-archive-gcc)
-
- ;; 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)
- (progn
- (gnus-configure-windows 'followup 'force)
- (insert "\n\n")
- (forward-line -2))
- (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)))
- (gnus-inews-set-point))))))
-
-(defun gnus-message-of (from date)
- "Take a FROM and a DATE and return an IN-REPLY-TO."
- (when from
- (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."
- (interactive)
- (let* ((reply gnus-article-reply)
- (winconf gnus-prev-winconf)
- (address-group gnus-add-to-address)
- (to-address (and address-group
- (mail-fetch-field "to"))))
- (setq gnus-add-to-address nil)
- (let ((buffer-file-name nil))
- (or dont-send (gnus-mail-send)))
- (bury-buffer)
- ;; This mail group doesn't have a `to-list', so we add one
- ;; here. Magic!
- (and to-address
- (gnus-group-add-parameter
- address-group (cons 'to-list to-address)))
- (if (get-buffer gnus-group-buffer)
- (progn
- (if (gnus-buffer-exists-p (car-safe reply))
- (progn
- (set-buffer (car reply))
- (and (cdr reply)
- (gnus-summary-mark-article-as-replied
- (cdr reply)))))
- (and winconf (set-window-configuration winconf))))))