Mercurial > hg > xemacs-beta
comparison lisp/gnus/gnus-soup.el @ 108:360340f9fd5f r20-1b6
Import from CVS: tag r20-1b6
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:18:39 +0200 |
parents | 0d2f883870bc |
children | fe104dbd9147 |
comparison
equal
deleted
inserted
replaced
107:523141596bda | 108:360340f9fd5f |
---|---|
141 ;; Find the header of the article. | 141 ;; Find the header of the article. |
142 (set-buffer gnus-summary-buffer) | 142 (set-buffer gnus-summary-buffer) |
143 (when (setq headers (gnus-summary-article-header (car articles))) | 143 (when (setq headers (gnus-summary-article-header (car articles))) |
144 ;; Put the article in a buffer. | 144 ;; Put the article in a buffer. |
145 (set-buffer tmp-buf) | 145 (set-buffer tmp-buf) |
146 (when (gnus-request-article-this-buffer | 146 (when (gnus-request-article-this-buffer |
147 (car articles) gnus-newsgroup-name) | 147 (car articles) gnus-newsgroup-name) |
148 (save-restriction | 148 (save-restriction |
149 (message-narrow-to-head) | 149 (message-narrow-to-head) |
150 (message-remove-header gnus-soup-ignored-headers t)) | 150 (message-remove-header gnus-soup-ignored-headers t)) |
151 (gnus-soup-store gnus-soup-directory prefix headers | 151 (gnus-soup-store gnus-soup-directory prefix headers |
152 gnus-soup-encoding-type | 152 gnus-soup-encoding-type |
153 gnus-soup-index-type) | 153 gnus-soup-index-type) |
154 (gnus-soup-area-set-number | 154 (gnus-soup-area-set-number |
155 area (1+ (or (gnus-soup-area-number area) 0))))) | 155 area (1+ (or (gnus-soup-area-number area) 0))))) |
156 ;; Mark article as read. | 156 ;; Mark article as read. |
157 (set-buffer gnus-summary-buffer) | 157 (set-buffer gnus-summary-buffer) |
158 (gnus-summary-remove-process-mark (car articles)) | 158 (gnus-summary-remove-process-mark (car articles)) |
159 (gnus-summary-mark-as-read (car articles) gnus-souped-mark) | 159 (gnus-summary-mark-as-read (car articles) gnus-souped-mark) |
160 (setq articles (cdr articles))) | 160 (setq articles (cdr articles))) |
161 (kill-buffer tmp-buf)) | 161 (kill-buffer tmp-buf)) |
203 groups with \"emacs\" in the name, you could say something like: | 203 groups with \"emacs\" in the name, you could say something like: |
204 | 204 |
205 $ emacs -batch -f gnus-batch-brew-soup ^nnml \".*emacs.*\"" | 205 $ emacs -batch -f gnus-batch-brew-soup ^nnml \".*emacs.*\"" |
206 (interactive) | 206 (interactive) |
207 nil) | 207 nil) |
208 | 208 |
209 ;;; Internal Functions: | 209 ;;; Internal Functions: |
210 | 210 |
211 ;; Store the current buffer. | 211 ;; Store the current buffer. |
212 (defun gnus-soup-store (directory prefix headers format index) | 212 (defun gnus-soup-store (directory prefix headers format index) |
213 ;; Create the directory, if needed. | 213 ;; Create the directory, if needed. |
214 (gnus-make-directory directory) | 214 (gnus-make-directory directory) |
215 (let* ((msg-buf (nnheader-find-file-noselect | 215 (let* ((msg-buf (nnheader-find-file-noselect |
216 (concat directory prefix ".MSG"))) | 216 (concat directory prefix ".MSG"))) |
217 (idx-buf (if (= index ?n) | 217 (idx-buf (if (= index ?n) |
218 nil | 218 nil |
220 (concat directory prefix ".IDX")))) | 220 (concat directory prefix ".IDX")))) |
221 (article-buf (current-buffer)) | 221 (article-buf (current-buffer)) |
222 from head-line beg type) | 222 from head-line beg type) |
223 (setq gnus-soup-buffers (cons msg-buf (delq msg-buf gnus-soup-buffers))) | 223 (setq gnus-soup-buffers (cons msg-buf (delq msg-buf gnus-soup-buffers))) |
224 (buffer-disable-undo msg-buf) | 224 (buffer-disable-undo msg-buf) |
225 (when idx-buf | 225 (when idx-buf |
226 (push idx-buf gnus-soup-buffers) | 226 (push idx-buf gnus-soup-buffers) |
227 (buffer-disable-undo idx-buf)) | 227 (buffer-disable-undo idx-buf)) |
228 (save-excursion | 228 (save-excursion |
229 ;; Make sure the last char in the buffer is a newline. | 229 ;; Make sure the last char in the buffer is a newline. |
230 (goto-char (point-max)) | 230 (goto-char (point-max)) |
237 (or (mail-fetch-field "from") | 237 (or (mail-fetch-field "from") |
238 (mail-fetch-field "really-from") | 238 (mail-fetch-field "really-from") |
239 (mail-fetch-field "sender")))) | 239 (mail-fetch-field "sender")))) |
240 (goto-char (point-min)) | 240 (goto-char (point-min)) |
241 ;; Depending on what encoding is supposed to be used, we make | 241 ;; Depending on what encoding is supposed to be used, we make |
242 ;; a soup header. | 242 ;; a soup header. |
243 (setq head-line | 243 (setq head-line |
244 (cond | 244 (cond |
245 ((= gnus-soup-encoding-type ?n) | 245 ((= gnus-soup-encoding-type ?n) |
246 (format "#! rnews %d\n" (buffer-size))) | 246 (format "#! rnews %d\n" (buffer-size))) |
247 ((= gnus-soup-encoding-type ?m) | 247 ((= gnus-soup-encoding-type ?m) |
248 (while (search-forward "\nFrom " nil t) | 248 (while (search-forward "\nFrom " nil t) |
249 (replace-match "\n>From " t t)) | 249 (replace-match "\n>From " t t)) |
276 (when (or (null entry) | 276 (when (or (null entry) |
277 (eq (car entry) t) | 277 (eq (car entry) t) |
278 (and (car entry) | 278 (and (car entry) |
279 (> (car entry) 0)) | 279 (> (car entry) 0)) |
280 (and (not not-all) | 280 (and (not not-all) |
281 (gnus-range-length (cdr (assq 'tick (gnus-info-marks | 281 (gnus-range-length (cdr (assq 'tick (gnus-info-marks |
282 (nth 2 entry))))))) | 282 (nth 2 entry))))))) |
283 (when (gnus-summary-read-group group nil t) | 283 (when (gnus-summary-read-group group nil t) |
284 (setq gnus-newsgroup-processable | 284 (setq gnus-newsgroup-processable |
285 (reverse | 285 (reverse |
286 (if (not not-all) | 286 (if (not not-all) |
297 offset | 297 offset |
298 (or (mail-header-subject header) "(none)") | 298 (or (mail-header-subject header) "(none)") |
299 (or (mail-header-from header) "(nobody)") | 299 (or (mail-header-from header) "(nobody)") |
300 (or (mail-header-date header) "") | 300 (or (mail-header-date header) "") |
301 (or (mail-header-id header) | 301 (or (mail-header-id header) |
302 (concat "soup-dummy-id-" | 302 (concat "soup-dummy-id-" |
303 (mapconcat | 303 (mapconcat |
304 (lambda (time) (int-to-string time)) | 304 (lambda (time) (int-to-string time)) |
305 (current-time) "-"))) | 305 (current-time) "-"))) |
306 (or (mail-header-references header) "") | 306 (or (mail-header-references header) "") |
307 (or (mail-header-chars header) 0) | 307 (or (mail-header-chars header) 0) |
308 (or (mail-header-lines header) "0")))) | 308 (or (mail-header-lines header) "0")))) |
339 " ")) | 339 " ")) |
340 (packer (if (< (string-match "%s" packer) | 340 (packer (if (< (string-match "%s" packer) |
341 (string-match "%d" packer)) | 341 (string-match "%d" packer)) |
342 (format packer files | 342 (format packer files |
343 (string-to-int (gnus-soup-unique-prefix dir))) | 343 (string-to-int (gnus-soup-unique-prefix dir))) |
344 (format packer | 344 (format packer |
345 (string-to-int (gnus-soup-unique-prefix dir)) | 345 (string-to-int (gnus-soup-unique-prefix dir)) |
346 files))) | 346 files))) |
347 (dir (expand-file-name dir))) | 347 (dir (expand-file-name dir))) |
348 (gnus-make-directory dir) | 348 (gnus-make-directory dir) |
349 (setq gnus-soup-areas nil) | 349 (setq gnus-soup-areas nil) |
350 (gnus-message 4 "Packing %s..." packer) | 350 (gnus-message 4 "Packing %s..." packer) |
351 (if (zerop (call-process shell-file-name | 351 (if (zerop (call-process shell-file-name |
352 nil nil nil shell-command-switch | 352 nil nil nil shell-command-switch |
353 (concat "cd " dir " ; " packer))) | 353 (concat "cd " dir " ; " packer))) |
354 (progn | 354 (progn |
355 (call-process shell-file-name nil nil nil shell-command-switch | 355 (call-process shell-file-name nil nil nil shell-command-switch |
356 (concat "cd " dir " ; rm " files)) | 356 (concat "cd " dir " ; rm " files)) |
357 (gnus-message 4 "Packing...done" packer)) | 357 (gnus-message 4 "Packing...done" packer)) |
358 (error "Couldn't pack packet.")))) | 358 (error "Couldn't pack packet.")))) |
359 | 359 |
360 (defun gnus-soup-parse-areas (file) | 360 (defun gnus-soup-parse-areas (file) |
361 "Parse soup area file FILE. | 361 "Parse soup area file FILE. |
362 The result is a of vectors, each containing one entry from the AREA file. | 362 The result is a of vectors, each containing one entry from the AREA file. |
363 The vector contain five strings, | 363 The vector contain five strings, |
364 [prefix name encoding description number] | 364 [prefix name encoding description number] |
365 though the two last may be nil if they are missing." | 365 though the two last may be nil if they are missing." |
366 (let (areas) | 366 (let (areas) |
367 (save-excursion | 367 (save-excursion |
368 (set-buffer (nnheader-find-file-noselect file 'force)) | 368 (set-buffer (nnheader-find-file-noselect file 'force)) |
417 (nnheader-temp-write (concat gnus-soup-directory "AREAS") | 417 (nnheader-temp-write (concat gnus-soup-directory "AREAS") |
418 (let ((areas gnus-soup-areas) | 418 (let ((areas gnus-soup-areas) |
419 area) | 419 area) |
420 (while (setq area (pop areas)) | 420 (while (setq area (pop areas)) |
421 (insert | 421 (insert |
422 (format | 422 (format |
423 "%s\t%s\t%s%s\n" | 423 "%s\t%s\t%s%s\n" |
424 (gnus-soup-area-prefix area) | 424 (gnus-soup-area-prefix area) |
425 (gnus-soup-area-name area) | 425 (gnus-soup-area-name area) |
426 (gnus-soup-area-encoding area) | 426 (gnus-soup-area-encoding area) |
427 (if (or (gnus-soup-area-description area) | 427 (if (or (gnus-soup-area-description area) |
428 (gnus-soup-area-number area)) | 428 (gnus-soup-area-number area)) |
429 (concat "\t" (or (gnus-soup-area-description | 429 (concat "\t" (or (gnus-soup-area-description |
430 area) "") | 430 area) "") |
431 (if (gnus-soup-area-number area) | 431 (if (gnus-soup-area-number area) |
432 (concat "\t" (int-to-string | 432 (concat "\t" (int-to-string |
433 (gnus-soup-area-number area))) | 433 (gnus-soup-area-number area))) |
434 "")) "")))))))) | 434 "")) "")))))))) |
435 | 435 |
436 (defun gnus-soup-write-replies (dir areas) | 436 (defun gnus-soup-write-replies (dir areas) |
437 "Write a REPLIES file in DIR containing AREAS." | 437 "Write a REPLIES file in DIR containing AREAS." |
454 (when (equal (gnus-soup-area-name area) real-group) | 454 (when (equal (gnus-soup-area-name area) real-group) |
455 (setq result area))) | 455 (setq result area))) |
456 (unless result | 456 (unless result |
457 (setq result | 457 (setq result |
458 (vector (gnus-soup-unique-prefix) | 458 (vector (gnus-soup-unique-prefix) |
459 real-group | 459 real-group |
460 (format "%c%c%c" | 460 (format "%c%c%c" |
461 gnus-soup-encoding-type | 461 gnus-soup-encoding-type |
462 gnus-soup-index-type | 462 gnus-soup-index-type |
463 (if (gnus-member-of-valid 'mail group) ?m ?n)) | 463 (if (gnus-member-of-valid 'mail group) ?m ?n)) |
464 nil nil) | 464 nil nil) |
491 (format "cd %s ; %s" (expand-file-name dir) | 491 (format "cd %s ; %s" (expand-file-name dir) |
492 (format unpacker packet)))) | 492 (format unpacker packet)))) |
493 (gnus-message 4 "Unpacking...done"))) | 493 (gnus-message 4 "Unpacking...done"))) |
494 | 494 |
495 (defun gnus-soup-send-packet (packet) | 495 (defun gnus-soup-send-packet (packet) |
496 (gnus-soup-unpack-packet | 496 (gnus-soup-unpack-packet |
497 gnus-soup-replies-directory gnus-soup-unpacker packet) | 497 gnus-soup-replies-directory gnus-soup-unpacker packet) |
498 (let ((replies (gnus-soup-parse-replies | 498 (let ((replies (gnus-soup-parse-replies |
499 (concat gnus-soup-replies-directory "REPLIES")))) | 499 (concat gnus-soup-replies-directory "REPLIES")))) |
500 (save-excursion | 500 (save-excursion |
501 (while replies | 501 (while replies |
502 (let* ((msg-file (concat gnus-soup-replies-directory | 502 (let* ((msg-file (concat gnus-soup-replies-directory |
503 (gnus-soup-reply-prefix (car replies)) | 503 (gnus-soup-reply-prefix (car replies)) |
504 ".MSG")) | 504 ".MSG")) |
505 (msg-buf (and (file-exists-p msg-file) | 505 (msg-buf (and (file-exists-p msg-file) |
506 (nnheader-find-file-noselect msg-file))) | 506 (nnheader-find-file-noselect msg-file))) |
507 (tmp-buf (get-buffer-create " *soup send*")) | 507 (tmp-buf (get-buffer-create " *soup send*")) |
508 beg end) | 508 beg end) |
509 (cond | 509 (cond |
510 ((/= (gnus-soup-encoding-format | 510 ((/= (gnus-soup-encoding-format |
511 (gnus-soup-reply-encoding (car replies))) | 511 (gnus-soup-reply-encoding (car replies))) |
512 ?n) | 512 ?n) |
513 (error "Unsupported encoding")) | 513 (error "Unsupported encoding")) |
514 ((null msg-buf) | 514 ((null msg-buf) |
515 t) | 515 t) |
521 (while (not (eobp)) | 521 (while (not (eobp)) |
522 (unless (looking-at "#! *rnews +\\([0-9]+\\)") | 522 (unless (looking-at "#! *rnews +\\([0-9]+\\)") |
523 (error "Bad header.")) | 523 (error "Bad header.")) |
524 (forward-line 1) | 524 (forward-line 1) |
525 (setq beg (point) | 525 (setq beg (point) |
526 end (+ (point) (string-to-int | 526 end (+ (point) (string-to-int |
527 (buffer-substring | 527 (buffer-substring |
528 (match-beginning 1) (match-end 1))))) | 528 (match-beginning 1) (match-end 1))))) |
529 (switch-to-buffer tmp-buf) | 529 (switch-to-buffer tmp-buf) |
530 (erase-buffer) | 530 (erase-buffer) |
531 (insert-buffer-substring msg-buf beg end) | 531 (insert-buffer-substring msg-buf beg end) |
532 (goto-char (point-min)) | 532 (goto-char (point-min)) |
533 (search-forward "\n\n") | 533 (search-forward "\n\n") |
534 (forward-char -1) | 534 (forward-char -1) |
535 (insert mail-header-separator) | 535 (insert mail-header-separator) |
536 (setq message-newsreader (setq message-mailer | 536 (setq message-newsreader (setq message-mailer |
537 (gnus-extended-version))) | 537 (gnus-extended-version))) |
538 (cond | 538 (cond |
539 ((string= (gnus-soup-reply-kind (car replies)) "news") | 539 ((string= (gnus-soup-reply-kind (car replies)) "news") |
540 (gnus-message 5 "Sending news message to %s..." | 540 (gnus-message 5 "Sending news message to %s..." |
541 (mail-fetch-field "newsgroups")) | 541 (mail-fetch-field "newsgroups")) |
542 (sit-for 1) | 542 (sit-for 1) |
543 (let ((message-syntax-checks | 543 (let ((message-syntax-checks |
556 (kill-buffer msg-buf) | 556 (kill-buffer msg-buf) |
557 (kill-buffer tmp-buf) | 557 (kill-buffer tmp-buf) |
558 (gnus-message 4 "Sent packet")))) | 558 (gnus-message 4 "Sent packet")))) |
559 (setq replies (cdr replies))) | 559 (setq replies (cdr replies))) |
560 t))) | 560 t))) |
561 | 561 |
562 (provide 'gnus-soup) | 562 (provide 'gnus-soup) |
563 | 563 |
564 ;;; gnus-soup.el ends here | 564 ;;; gnus-soup.el ends here |