Add 2011 to FSF/AIST copyright years.
[bpt/emacs.git] / lisp / gnus / gnus-soup.el
CommitLineData
eec82323 1;;; gnus-soup.el --- SOUP packet writing support for Gnus
16409b0b 2
b6c2d8c6 3;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
5df4f04c 4;; 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
eec82323
LMI
5
6;; Author: Per Abrahamsen <abraham@iesd.auc.dk>
6748645f 7;; Lars Magne Ingebrigtsen <larsi@gnus.org>
eec82323
LMI
8;; Keywords: news, mail
9
10;; This file is part of GNU Emacs.
11
5e809f55 12;; GNU Emacs is free software: you can redistribute it and/or modify
eec82323 13;; it under the terms of the GNU General Public License as published by
5e809f55
GM
14;; the Free Software Foundation, either version 3 of the License, or
15;; (at your option) any later version.
eec82323
LMI
16
17;; GNU Emacs is distributed in the hope that it will be useful,
18;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20;; GNU General Public License for more details.
21
22;; You should have received a copy of the GNU General Public License
5e809f55 23;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
eec82323
LMI
24
25;;; Commentary:
26
27;;; Code:
28
51bab999
RS
29(eval-when-compile (require 'cl))
30
eec82323
LMI
31(require 'gnus)
32(require 'gnus-art)
33(require 'message)
34(require 'gnus-start)
35(require 'gnus-range)
36
d84c3737
RS
37(defgroup gnus-soup nil
38 "SOUP packet writing support for Gnus."
39 :group 'gnus)
40
eec82323
LMI
41;;; User Variables:
42
d84c3737
RS
43(defcustom gnus-soup-directory (nnheader-concat gnus-home-directory "SoupBrew/")
44 "Directory containing an unpacked SOUP packet."
45 :version "22.1" ;; Gnus 5.10.9
40e902eb
RS
46 :type 'directory
47 :group 'gnus-soup)
eec82323 48
d84c3737 49(defcustom gnus-soup-replies-directory
eec82323 50 (nnheader-concat gnus-soup-directory "SoupReplies/")
d84c3737
RS
51 "Directory where Gnus will do processing of replies."
52 :version "22.1" ;; Gnus 5.10.9
40e902eb
RS
53 :type 'directory
54 :group 'gnus-soup)
eec82323 55
d84c3737
RS
56(defcustom gnus-soup-prefix-file "gnus-prefix"
57 "Name of the file where Gnus stores the last used prefix."
58 :version "22.1" ;; Gnus 5.10.9
40e902eb
RS
59 :type 'file
60 :group 'gnus-soup)
eec82323 61
d84c3737 62(defcustom gnus-soup-packer "tar cf - %s | gzip > $HOME/Soupout%d.tgz"
eec82323
LMI
63 "Format string command for packing a SOUP packet.
64The SOUP files will be inserted where the %s is in the string.
65This string MUST contain both %s and %d. The file number will be
d84c3737
RS
66inserted where %d appears."
67 :version "22.1" ;; Gnus 5.10.9
40e902eb
RS
68 :type 'string
69 :group 'gnus-soup)
d84c3737
RS
70
71(defcustom gnus-soup-unpacker "gunzip -c %s | tar xvf -"
72 "Format string command for unpacking a SOUP packet.
73The SOUP packet file name will be inserted at the %s."
74 :version "22.1" ;; Gnus 5.10.9
40e902eb
RS
75 :type 'string
76 :group 'gnus-soup)
d84c3737
RS
77
78(defcustom gnus-soup-packet-directory gnus-home-directory
79 "Where gnus-soup will look for REPLIES packets."
80 :version "22.1" ;; Gnus 5.10.9
40e902eb
RS
81 :type 'directory
82 :group 'gnus-soup)
d84c3737
RS
83
84(defcustom gnus-soup-packet-regexp "Soupin"
85 "Regular expression matching SOUP REPLIES packets in `gnus-soup-packet-directory'."
86 :version "22.1" ;; Gnus 5.10.9
40e902eb
RS
87 :type 'regexp
88 :group 'gnus-soup)
d84c3737
RS
89
90(defcustom gnus-soup-ignored-headers "^Xref:"
91 "Regexp to match headers to be removed when brewing SOUP packets."
92 :version "22.1" ;; Gnus 5.10.9
40e902eb
RS
93 :type 'regexp
94 :group 'gnus-soup)
eec82323
LMI
95
96;;; Internal Variables:
97
16409b0b 98(defvar gnus-soup-encoding-type ?u
eec82323 99 "*Soup encoding type.
16409b0b 100`u' is USENET news format, `m' is Unix mbox format, and `M' is MMDF mailbox
eec82323
LMI
101format.")
102
103(defvar gnus-soup-index-type ?c
104 "*Soup index type.
105`n' means no index file and `c' means standard Cnews overview
106format.")
107
108(defvar gnus-soup-areas nil)
109(defvar gnus-soup-last-prefix nil)
110(defvar gnus-soup-prev-prefix nil)
111(defvar gnus-soup-buffers nil)
112
113;;; Access macros:
114
115(defmacro gnus-soup-area-prefix (area)
116 `(aref ,area 0))
117(defmacro gnus-soup-set-area-prefix (area prefix)
118 `(aset ,area 0 ,prefix))
119(defmacro gnus-soup-area-name (area)
120 `(aref ,area 1))
121(defmacro gnus-soup-area-encoding (area)
122 `(aref ,area 2))
123(defmacro gnus-soup-area-description (area)
124 `(aref ,area 3))
125(defmacro gnus-soup-area-number (area)
126 `(aref ,area 4))
127(defmacro gnus-soup-area-set-number (area value)
128 `(aset ,area 4 ,value))
129
130(defmacro gnus-soup-encoding-format (encoding)
131 `(aref ,encoding 0))
132(defmacro gnus-soup-encoding-index (encoding)
133 `(aref ,encoding 1))
134(defmacro gnus-soup-encoding-kind (encoding)
135 `(aref ,encoding 2))
136
137(defmacro gnus-soup-reply-prefix (reply)
138 `(aref ,reply 0))
139(defmacro gnus-soup-reply-kind (reply)
140 `(aref ,reply 1))
141(defmacro gnus-soup-reply-encoding (reply)
142 `(aref ,reply 2))
143
144;;; Commands:
145
146(defun gnus-soup-send-replies ()
147 "Unpack and send all replies in the reply packet."
148 (interactive)
149 (let ((packets (directory-files
150 gnus-soup-packet-directory t gnus-soup-packet-regexp)))
151 (while packets
152 (when (gnus-soup-send-packet (car packets))
153 (delete-file (car packets)))
154 (setq packets (cdr packets)))))
155
156(defun gnus-soup-add-article (n)
157 "Add the current article to SOUP packet.
158If N is a positive number, add the N next articles.
159If N is a negative number, add the N previous articles.
160If N is nil and any articles have been marked with the process mark,
161move those articles instead."
162 (interactive "P")
eec82323 163 (let* ((articles (gnus-summary-work-articles n))
6748645f 164 (tmp-buf (gnus-get-buffer-create "*soup work*"))
eec82323
LMI
165 (area (gnus-soup-area gnus-newsgroup-name))
166 (prefix (gnus-soup-area-prefix area))
167 headers)
168 (buffer-disable-undo tmp-buf)
169 (save-excursion
170 (while articles
16409b0b
GM
171 ;; Put the article in a buffer.
172 (set-buffer tmp-buf)
173 (when (gnus-request-article-this-buffer
174 (car articles) gnus-newsgroup-name)
175 (setq headers (nnheader-parse-head t))
176 (save-restriction
177 (message-narrow-to-head)
178 (message-remove-header gnus-soup-ignored-headers t))
179 (gnus-soup-store gnus-soup-directory prefix headers
180 gnus-soup-encoding-type
181 gnus-soup-index-type)
182 (gnus-soup-area-set-number
23f87bed
MB
183 area (1+ (or (gnus-soup-area-number area) 0)))
184 ;; Mark article as read.
185 (set-buffer gnus-summary-buffer)
186 (gnus-summary-mark-as-read (car articles) gnus-souped-mark))
eec82323 187 (gnus-summary-remove-process-mark (car articles))
eec82323
LMI
188 (setq articles (cdr articles)))
189 (kill-buffer tmp-buf))
6748645f
LMI
190 (gnus-soup-save-areas)
191 (gnus-set-mode-line 'summary)))
eec82323
LMI
192
193(defun gnus-soup-pack-packet ()
194 "Make a SOUP packet from the SOUP areas."
195 (interactive)
196 (gnus-soup-read-areas)
16409b0b
GM
197 (if (file-exists-p gnus-soup-directory)
198 (if (directory-files gnus-soup-directory nil "\\.MSG$")
199 (gnus-soup-pack gnus-soup-directory gnus-soup-packer)
200 (message "No files to pack."))
201 (message "No such directory: %s" gnus-soup-directory)))
eec82323
LMI
202
203(defun gnus-group-brew-soup (n)
204 "Make a soup packet from the current group.
205Uses the process/prefix convention."
206 (interactive "P")
207 (let ((groups (gnus-group-process-prefix n)))
208 (while groups
209 (gnus-group-remove-mark (car groups))
210 (gnus-soup-group-brew (car groups) t)
211 (setq groups (cdr groups)))
212 (gnus-soup-save-areas)))
213
214(defun gnus-brew-soup (&optional level)
215 "Go through all groups on LEVEL or less and make a soup packet."
216 (interactive "P")
217 (let ((level (or level gnus-level-subscribed))
218 (newsrc (cdr gnus-newsrc-alist)))
219 (while newsrc
220 (when (<= (nth 1 (car newsrc)) level)
221 (gnus-soup-group-brew (caar newsrc) t))
222 (setq newsrc (cdr newsrc)))
223 (gnus-soup-save-areas)))
224
225;;;###autoload
226(defun gnus-batch-brew-soup ()
227 "Brew a SOUP packet from groups mention on the command line.
228Will use the remaining command line arguments as regular expressions
229for matching on group names.
230
231For instance, if you want to brew on all the nnml groups, as well as
232groups with \"emacs\" in the name, you could say something like:
233
6748645f
LMI
234$ emacs -batch -f gnus-batch-brew-soup ^nnml \".*emacs.*\"
235
236Note -- this function hasn't been implemented yet."
eec82323
LMI
237 (interactive)
238 nil)
239
240;;; Internal Functions:
241
242;; Store the current buffer.
243(defun gnus-soup-store (directory prefix headers format index)
244 ;; Create the directory, if needed.
245 (gnus-make-directory directory)
246 (let* ((msg-buf (nnheader-find-file-noselect
247 (concat directory prefix ".MSG")))
248 (idx-buf (if (= index ?n)
249 nil
250 (nnheader-find-file-noselect
251 (concat directory prefix ".IDX"))))
252 (article-buf (current-buffer))
253 from head-line beg type)
254 (setq gnus-soup-buffers (cons msg-buf (delq msg-buf gnus-soup-buffers)))
255 (buffer-disable-undo msg-buf)
256 (when idx-buf
257 (push idx-buf gnus-soup-buffers)
258 (buffer-disable-undo idx-buf))
259 (save-excursion
260 ;; Make sure the last char in the buffer is a newline.
261 (goto-char (point-max))
262 (unless (= (current-column) 0)
263 (insert "\n"))
264 ;; Find the "from".
265 (goto-char (point-min))
266 (setq from
267 (gnus-mail-strip-quoted-names
268 (or (mail-fetch-field "from")
269 (mail-fetch-field "really-from")
270 (mail-fetch-field "sender"))))
271 (goto-char (point-min))
272 ;; Depending on what encoding is supposed to be used, we make
273 ;; a soup header.
274 (setq head-line
275 (cond
16409b0b
GM
276 ((or (= gnus-soup-encoding-type ?u)
277 (= gnus-soup-encoding-type ?n)) ;;Gnus back compatibility.
eec82323
LMI
278 (format "#! rnews %d\n" (buffer-size)))
279 ((= gnus-soup-encoding-type ?m)
280 (while (search-forward "\nFrom " nil t)
281 (replace-match "\n>From " t t))
282 (concat "From " (or from "unknown")
283 " " (current-time-string) "\n"))
284 ((= gnus-soup-encoding-type ?M)
285 "\^a\^a\^a\^a\n")
286 (t (error "Unsupported type: %c" gnus-soup-encoding-type))))
287 ;; Insert the soup header and the article in the MSG buf.
288 (set-buffer msg-buf)
289 (goto-char (point-max))
290 (insert head-line)
291 (setq beg (point))
292 (insert-buffer-substring article-buf)
293 ;; Insert the index in the IDX buf.
294 (cond ((= index ?c)
295 (set-buffer idx-buf)
296 (gnus-soup-insert-idx beg headers))
297 ((/= index ?n)
298 (error "Unknown index type: %c" type)))
299 ;; Return the MSG buf.
300 msg-buf)))
301
302(defun gnus-soup-group-brew (group &optional not-all)
303 "Enter GROUP and add all articles to a SOUP package.
304If NOT-ALL, don't pack ticked articles."
305 (let ((gnus-expert-user t)
306 (gnus-large-newsgroup nil)
01c52d31 307 (entry (gnus-group-entry group)))
eec82323
LMI
308 (when (or (null entry)
309 (eq (car entry) t)
310 (and (car entry)
311 (> (car entry) 0))
312 (and (not not-all)
313 (gnus-range-length (cdr (assq 'tick (gnus-info-marks
314 (nth 2 entry)))))))
315 (when (gnus-summary-read-group group nil t)
316 (setq gnus-newsgroup-processable
317 (reverse
318 (if (not not-all)
319 (append gnus-newsgroup-marked gnus-newsgroup-unreads)
320 gnus-newsgroup-unreads)))
321 (gnus-soup-add-article nil)
322 (gnus-summary-exit)))))
323
324(defun gnus-soup-insert-idx (offset header)
325 ;; [number subject from date id references chars lines xref]
326 (goto-char (point-max))
327 (insert
328 (format "%d\t%s\t%s\t%s\t%s\t%s\t%d\t%s\t\t\n"
329 offset
330 (or (mail-header-subject header) "(none)")
331 (or (mail-header-from header) "(nobody)")
332 (or (mail-header-date header) "")
333 (or (mail-header-id header)
334 (concat "soup-dummy-id-"
335 (mapconcat
336 (lambda (time) (int-to-string time))
337 (current-time) "-")))
338 (or (mail-header-references header) "")
339 (or (mail-header-chars header) 0)
340 (or (mail-header-lines header) "0"))))
341
342(defun gnus-soup-save-areas ()
6748645f
LMI
343 "Write all SOUP buffers."
344 (interactive)
eec82323
LMI
345 (gnus-soup-write-areas)
346 (save-excursion
347 (let (buf)
348 (while gnus-soup-buffers
349 (setq buf (car gnus-soup-buffers)
350 gnus-soup-buffers (cdr gnus-soup-buffers))
351 (if (not (buffer-name buf))
352 ()
353 (set-buffer buf)
354 (when (buffer-modified-p)
355 (save-buffer))
356 (kill-buffer (current-buffer)))))
357 (gnus-soup-write-prefixes)))
358
359(defun gnus-soup-write-prefixes ()
360 (let ((prefixes gnus-soup-last-prefix)
361 prefix)
362 (save-excursion
363 (gnus-set-work-buffer)
364 (while (setq prefix (pop prefixes))
365 (erase-buffer)
366 (insert (format "(setq gnus-soup-prev-prefix %d)\n" (cdr prefix)))
16409b0b
GM
367 (let ((coding-system-for-write mm-text-coding-system))
368 (gnus-write-buffer (concat (car prefix) gnus-soup-prefix-file)))))))
eec82323
LMI
369
370(defun gnus-soup-pack (dir packer)
371 (let* ((files (mapconcat 'identity
372 '("AREAS" "*.MSG" "*.IDX" "INFO"
373 "LIST" "REPLIES" "COMMANDS" "ERRORS")
374 " "))
375 (packer (if (< (string-match "%s" packer)
376 (string-match "%d" packer))
377 (format packer files
e9bd5782 378 (string-to-number (gnus-soup-unique-prefix dir)))
eec82323 379 (format packer
e9bd5782 380 (string-to-number (gnus-soup-unique-prefix dir))
eec82323
LMI
381 files)))
382 (dir (expand-file-name dir)))
383 (gnus-make-directory dir)
384 (setq gnus-soup-areas nil)
385 (gnus-message 4 "Packing %s..." packer)
23f87bed
MB
386 (if (eq 0 (call-process shell-file-name
387 nil nil nil shell-command-switch
388 (concat "cd " dir " ; " packer)))
eec82323
LMI
389 (progn
390 (call-process shell-file-name nil nil nil shell-command-switch
391 (concat "cd " dir " ; rm " files))
392 (gnus-message 4 "Packing...done" packer))
a8151ef7 393 (error "Couldn't pack packet"))))
eec82323
LMI
394
395(defun gnus-soup-parse-areas (file)
396 "Parse soup area file FILE.
397The result is a of vectors, each containing one entry from the AREA file.
398The vector contain five strings,
399 [prefix name encoding description number]
400though the two last may be nil if they are missing."
401 (let (areas)
6748645f
LMI
402 (when (file-exists-p file)
403 (save-excursion
404 (set-buffer (nnheader-find-file-noselect file 'force))
16409b0b 405 (buffer-disable-undo)
6748645f
LMI
406 (goto-char (point-min))
407 (while (not (eobp))
408 (push (vector (gnus-soup-field)
409 (gnus-soup-field)
410 (gnus-soup-field)
411 (and (eq (preceding-char) ?\t)
412 (gnus-soup-field))
413 (and (eq (preceding-char) ?\t)
e9bd5782 414 (string-to-number (gnus-soup-field))))
6748645f
LMI
415 areas)
416 (when (eq (preceding-char) ?\t)
417 (beginning-of-line 2)))
418 (kill-buffer (current-buffer))))
eec82323
LMI
419 areas))
420
421(defun gnus-soup-parse-replies (file)
422 "Parse soup REPLIES file FILE.
423The result is a of vectors, each containing one entry from the REPLIES
424file. The vector contain three strings, [prefix name encoding]."
425 (let (replies)
426 (save-excursion
427 (set-buffer (nnheader-find-file-noselect file))
16409b0b 428 (buffer-disable-undo)
eec82323
LMI
429 (goto-char (point-min))
430 (while (not (eobp))
431 (push (vector (gnus-soup-field) (gnus-soup-field)
432 (gnus-soup-field))
433 replies)
434 (when (eq (preceding-char) ?\t)
435 (beginning-of-line 2)))
436 (kill-buffer (current-buffer)))
437 replies))
438
439(defun gnus-soup-field ()
440 (prog1
441 (buffer-substring (point) (progn (skip-chars-forward "^\t\n") (point)))
442 (forward-char 1)))
443
444(defun gnus-soup-read-areas ()
445 (or gnus-soup-areas
446 (setq gnus-soup-areas
447 (gnus-soup-parse-areas (concat gnus-soup-directory "AREAS")))))
448
449(defun gnus-soup-write-areas ()
450 "Write the AREAS file."
451 (interactive)
452 (when gnus-soup-areas
16409b0b 453 (with-temp-file (concat gnus-soup-directory "AREAS")
eec82323
LMI
454 (let ((areas gnus-soup-areas)
455 area)
456 (while (setq area (pop areas))
457 (insert
458 (format
459 "%s\t%s\t%s%s\n"
460 (gnus-soup-area-prefix area)
461 (gnus-soup-area-name area)
462 (gnus-soup-area-encoding area)
463 (if (or (gnus-soup-area-description area)
464 (gnus-soup-area-number area))
465 (concat "\t" (or (gnus-soup-area-description
466 area) "")
467 (if (gnus-soup-area-number area)
468 (concat "\t" (int-to-string
469 (gnus-soup-area-number area)))
470 "")) ""))))))))
471
472(defun gnus-soup-write-replies (dir areas)
473 "Write a REPLIES file in DIR containing AREAS."
16409b0b 474 (with-temp-file (concat dir "REPLIES")
eec82323
LMI
475 (let (area)
476 (while (setq area (pop areas))
477 (insert (format "%s\t%s\t%s\n"
478 (gnus-soup-reply-prefix area)
479 (gnus-soup-reply-kind area)
480 (gnus-soup-reply-encoding area)))))))
481
482(defun gnus-soup-area (group)
483 (gnus-soup-read-areas)
484 (let ((areas gnus-soup-areas)
485 (real-group (gnus-group-real-name group))
486 area result)
487 (while areas
488 (setq area (car areas)
489 areas (cdr areas))
490 (when (equal (gnus-soup-area-name area) real-group)
491 (setq result area)))
492 (unless result
493 (setq result
494 (vector (gnus-soup-unique-prefix)
495 real-group
496 (format "%c%c%c"
497 gnus-soup-encoding-type
498 gnus-soup-index-type
499 (if (gnus-member-of-valid 'mail group) ?m ?n))
500 nil nil)
501 gnus-soup-areas (cons result gnus-soup-areas)))
502 result))
503
504(defun gnus-soup-unique-prefix (&optional dir)
505 (let* ((dir (file-name-as-directory (or dir gnus-soup-directory)))
506 (entry (assoc dir gnus-soup-last-prefix))
507 gnus-soup-prev-prefix)
508 (if entry
509 ()
510 (when (file-exists-p (concat dir gnus-soup-prefix-file))
511 (ignore-errors
512 (load (concat dir gnus-soup-prefix-file) nil t t)))
513 (push (setq entry (cons dir (or gnus-soup-prev-prefix 0)))
514 gnus-soup-last-prefix))
515 (setcdr entry (1+ (cdr entry)))
516 (gnus-soup-write-prefixes)
517 (int-to-string (cdr entry))))
518
519(defun gnus-soup-unpack-packet (dir unpacker packet)
520 "Unpack PACKET into DIR using UNPACKER.
521Return whether the unpacking was successful."
522 (gnus-make-directory dir)
523 (gnus-message 4 "Unpacking: %s" (format unpacker packet))
524 (prog1
23f87bed
MB
525 (eq 0 (call-process
526 shell-file-name nil nil nil shell-command-switch
527 (format "cd %s ; %s" (expand-file-name dir)
528 (format unpacker packet))))
eec82323
LMI
529 (gnus-message 4 "Unpacking...done")))
530
531(defun gnus-soup-send-packet (packet)
532 (gnus-soup-unpack-packet
533 gnus-soup-replies-directory gnus-soup-unpacker packet)
534 (let ((replies (gnus-soup-parse-replies
535 (concat gnus-soup-replies-directory "REPLIES"))))
536 (save-excursion
537 (while replies
538 (let* ((msg-file (concat gnus-soup-replies-directory
539 (gnus-soup-reply-prefix (car replies))
540 ".MSG"))
541 (msg-buf (and (file-exists-p msg-file)
542 (nnheader-find-file-noselect msg-file)))
6748645f 543 (tmp-buf (gnus-get-buffer-create " *soup send*"))
eec82323
LMI
544 beg end)
545 (cond
16409b0b
GM
546 ((and (/= (gnus-soup-encoding-format
547 (gnus-soup-reply-encoding (car replies)))
548 ?u)
549 (/= (gnus-soup-encoding-format
550 (gnus-soup-reply-encoding (car replies)))
551 ?n)) ;; Gnus back compatibility.
eec82323
LMI
552 (error "Unsupported encoding"))
553 ((null msg-buf)
554 t)
555 (t
556 (buffer-disable-undo msg-buf)
eec82323
LMI
557 (set-buffer msg-buf)
558 (goto-char (point-min))
559 (while (not (eobp))
560 (unless (looking-at "#! *rnews +\\([0-9]+\\)")
a8151ef7 561 (error "Bad header"))
eec82323
LMI
562 (forward-line 1)
563 (setq beg (point)
e9bd5782 564 end (+ (point) (string-to-number
eec82323
LMI
565 (buffer-substring
566 (match-beginning 1) (match-end 1)))))
567 (switch-to-buffer tmp-buf)
568 (erase-buffer)
23f87bed 569 (mm-disable-multibyte)
eec82323 570 (insert-buffer-substring msg-buf beg end)
eec82323
LMI
571 (cond
572 ((string= (gnus-soup-reply-kind (car replies)) "news")
573 (gnus-message 5 "Sending news message to %s..."
574 (mail-fetch-field "newsgroups"))
575 (sit-for 1)
576 (let ((message-syntax-checks
23f87bed
MB
577 'dont-check-for-anything-just-trust-me)
578 (method (if (functionp message-post-method)
579 (funcall message-post-method)
580 message-post-method))
581 result)
582 (run-hooks 'message-send-news-hook)
583 (gnus-open-server method)
584 (message "Sending news via %s..."
585 (gnus-server-string method))
586 (unless (let ((mail-header-separator ""))
587 (gnus-request-post method))
588 (message "Couldn't send message via news: %s"
589 (nnheader-get-report (car method))))))
eec82323
LMI
590 ((string= (gnus-soup-reply-kind (car replies)) "mail")
591 (gnus-message 5 "Sending mail to %s..."
592 (mail-fetch-field "to"))
593 (sit-for 1)
23f87bed 594 (let ((mail-header-separator ""))
f5fcf556
SM
595 (funcall (or message-send-mail-real-function
596 message-send-mail-function))))
eec82323
LMI
597 (t
598 (error "Unknown reply kind")))
599 (set-buffer msg-buf)
600 (goto-char end))
601 (delete-file (buffer-file-name))
602 (kill-buffer msg-buf)
603 (kill-buffer tmp-buf)
604 (gnus-message 4 "Sent packet"))))
605 (setq replies (cdr replies)))
606 t)))
607
608(provide 'gnus-soup)
609
f5fcf556 610;; arch-tag: eddfa69d-13e8-4aea-84ef-62a526ef185c
eec82323 611;;; gnus-soup.el ends here