From: yamaoka Date: Tue, 12 Jan 1999 03:51:17 +0000 (+0000) Subject: * nntp.el (nntp-request-post): Put a Message-ID generated by server if it does X-Git-Tag: gnus-6_10-199901121900~7 X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f413a512167705be039ac996f19f3eba5cf1520a;p=elisp%2Fgnus.git- * nntp.el (nntp-request-post): Put a Message-ID generated by server if it does not exist in the article. (nntp-request-post): Run `nntp-prepare-post-hook'. (nntp-wait-for): Save a response from the server in `nntp-process-response' after sending a command. (nntp-prepare-post-hook): New hook, run just before postting an article. * nnheader.el (nnheader-init-server-buffer): Make `nntp-process-response' be buffer-local in `nntp-server-buffer'. (nntp-process-response): New variable, used for holding a response from the server after sending a command. --- diff --git a/lisp/nnheader.el b/lisp/nnheader.el index 9e6024d..9c58e97 100644 --- a/lisp/nnheader.el +++ b/lisp/nnheader.el @@ -378,6 +378,7 @@ the line could be found." ;; Various cruft the backends and Gnus need to communicate. (defvar nntp-server-buffer nil) +(defvar nntp-process-response nil) (defvar gnus-verbose-backends 7 "*A number that says how talkative the Gnus backends should be.") (defvar gnus-nov-is-evil nil @@ -396,6 +397,7 @@ the line could be found." (erase-buffer) (kill-all-local-variables) (setq case-fold-search t) ;Should ignore case. + (set (make-local-variable 'nntp-process-response) nil) t)) ;;; Various functions the backends use. diff --git a/lisp/nntp.el b/lisp/nntp.el index f38c4b7..26c85cd 100644 --- a/lisp/nntp.el +++ b/lisp/nntp.el @@ -2,6 +2,7 @@ ;;; Copyright (C) 1987-90,92-97 Free Software Foundation, Inc. ;; Author: Lars Magne Ingebrigtsen +;; Katsumi Yamaoka ;; Keywords: news ;; This file is part of GNU Emacs. @@ -173,6 +174,10 @@ server there that you can connect to. See also "*Number of seconds to wait before an nntp connection times out. If this variable is nil, which is the default, no timers are set.") +(defvoo nntp-prepare-post-hook nil + "*Hook run just before postting an article. It is supposed to be used for +inserting Cancel-Lock headers, signing with Gpg, etc.") + ;;; Internal variables. (defvar nntp-record-commands nil @@ -254,13 +259,18 @@ If this variable is nil, which is the default, no timers are set.") (nnheader-report 'nntp "Server closed connection")) (t (goto-char (point-max)) - (let ((limit (point-min))) + (let ((limit (point-min)) + response) (while (not (re-search-backward wait-for limit t)) (nntp-accept-process-output process) ;; We assume that whatever we wait for is less than 1000 ;; characters long. (setq limit (max (- (point-max) 1000) (point-min))) - (goto-char (point-max)))) + (goto-char (point-max))) + (setq response (match-string 0)) + (save-current-buffer + (set-buffer nntp-server-buffer) + (setq nntp-process-response response))) (nntp-decode-text (not decode)) (unless discard (save-excursion @@ -724,7 +734,24 @@ If this variable is nil, which is the default, no timers are set.") (deffoo nntp-request-post (&optional server) (nntp-possibly-change-group nil server) (when (nntp-send-command "^[23].*\r?\n" "POST") - (nntp-send-buffer "^[23].*\n"))) + (let ((response (save-current-buffer + (set-buffer nntp-server-buffer) + nntp-process-response)) + server-id) + (when (and response + (string-match "^[23].*\\(<[^\t\n @<>]+@[^\t\n @<>]+>\\)" + response)) + (setq server-id (match-string 1 response)) + (narrow-to-region (goto-char (point-min)) + (if (search-forward "\n\n" nil t) + (1- (point)) + (point-max))) + (unless (mail-fetch-field "Message-ID") + (goto-char (point-min)) + (insert "Message-ID: " server-id "\n")) + (widen)) + (run-hooks 'nntp-prepare-post-hook) + (nntp-send-buffer "^[23].*\n")))) (deffoo nntp-request-type (group article) 'news)