X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=lisp%2Fnnsoup.el;h=d6177cc1ece887b8858da517d3562e1c95ebd26f;hb=932f3ecb09dd43ecf5d3bc7d03c9d7787b1961ba;hp=4ccb28c2b2d22d2f3f4b475c7ce4c314a979b121;hpb=cda270b73d89201b8072b013dfde919798b168d6;p=elisp%2Fgnus.git- diff --git a/lisp/nnsoup.el b/lisp/nnsoup.el index 4ccb28c..d6177cc 100644 --- a/lisp/nnsoup.el +++ b/lisp/nnsoup.el @@ -1,8 +1,10 @@ ;;; nnsoup.el --- SOUP access for Gnus -;; Copyright (C) 1995,96,97,98 Free Software Foundation, Inc. + +;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 +;; Free Software Foundation, Inc. ;; Author: Lars Magne Ingebrigtsen -;; Masanobu UMEDA +;; Masanobu UMEDA ;; Keywords: news, mail ;; This file is part of GNU Emacs. @@ -26,31 +28,35 @@ ;;; Code: +(eval-when-compile (require 'cl)) + (require 'nnheader) (require 'nnmail) (require 'gnus-soup) (require 'gnus-msg) (require 'nnoo) -(eval-when-compile (require 'cl)) (nnoo-declare nnsoup) (defvoo nnsoup-directory "~/SOUP/" "*SOUP packet directory.") -(defvoo nnsoup-tmp-directory "/tmp/" +(defvoo nnsoup-tmp-directory + (cond ((fboundp 'temp-directory) (temp-directory)) + ((boundp 'temporary-file-directory) temporary-file-directory) + ("/tmp/")) "*Where nnsoup will store temporary files.") -(defvoo nnsoup-replies-directory (concat nnsoup-directory "replies/") +(defvoo nnsoup-replies-directory (expand-file-name "replies/" nnsoup-directory) "*Directory where outgoing packets will be composed.") -(defvoo nnsoup-replies-format-type ?n +(defvoo nnsoup-replies-format-type ?u ;; u is USENET news format. "*Format of the replies packages.") (defvoo nnsoup-replies-index-type ?n "*Index type of the replies packages.") -(defvoo nnsoup-active-file (concat nnsoup-directory "active") +(defvoo nnsoup-active-file (expand-file-name "active" nnsoup-directory) "Active file.") (defvoo nnsoup-packer "tar cf - %s | gzip > $HOME/Soupin%d.tgz" @@ -70,8 +76,8 @@ The SOUP packet file name will be inserted at the %s.") "*Regular expression matching SOUP packets in `nnsoup-packet-directory'.") (defvoo nnsoup-always-save t - "If non nil commit the reply buffer on each message send. -This is necessary if using message mode outside Gnus with nnsoup as a + "If non nil commit the reply buffer on each message send. +This is necessary if using message mode outside Gnus with nnsoup as a backend for the messages.") @@ -109,7 +115,7 @@ backend for the messages.") ;; articles in SEQUENCE come from. (while (and areas sequence) ;; Peel off areas that are below sequence. - (while (and areas (< (cdaar areas) (car sequence))) + (while (and areas (< (cdar (car areas)) (car sequence))) (setq areas (cdr areas))) (when areas ;; This is a useful area. @@ -125,7 +131,7 @@ backend for the messages.") (setq use-nov nil)) ;; We assign the portion of `sequence' that is relevant to ;; this MSG packet to this packet. - (while (and sequence (<= (car sequence) (cdaar areas))) + (while (and sequence (<= (car sequence) (cdar (car areas)))) (push (car sequence) this-area-seq) (setq sequence (cdr sequence))) (setcar useful-areas (cons (nreverse this-area-seq) @@ -153,7 +159,7 @@ backend for the messages.") (when index-buffer (insert-buffer-substring index-buffer) (goto-char b) - ;; We have to remove the index number entires and + ;; We have to remove the index number entries and ;; insert article numbers instead. (while (looking-at "[0-9]+") (replace-match (int-to-string number) t t) @@ -244,7 +250,7 @@ backend for the messages.") ;; Try to guess the type based on the first article in the group. (when (not article) (setq article - (cdaar (cddr (assoc group nnsoup-group-alist))))) + (cdar (car (cddr (assoc group nnsoup-group-alist)))))) (if (not article) 'unknown (let ((kind (gnus-soup-encoding-kind @@ -310,7 +316,7 @@ backend for the messages.") (setq info (pop infolist) range-list (gnus-uncompress-range (car info)) prefix (gnus-soup-area-prefix (nth 1 info))) - (when ;; All the articles in this file are marked for expiry. + (when;; All the articles in this file are marked for expiry. (and (or (setq mod-time (nth 5 (file-attributes (nnsoup-file prefix)))) (setq mod-time (nth 5 (file-attributes @@ -332,7 +338,7 @@ backend for the messages.") (delete-file (nnsoup-file prefix t))) t) (setcdr (cdr total-infolist) (delq info (cddr total-infolist))) - (setq articles (gnus-sorted-complement articles range-list)))) + (setq articles (gnus-sorted-difference articles range-list)))) (when (not mod-time) (setcdr (cdr total-infolist) (delq info (cddr total-infolist))))) (if (cddr total-infolist) @@ -366,7 +372,7 @@ backend for the messages.") (setq min (caaar e)) (while (cdr e) (setq e (cdr e))) - (setq max (cdaar e)) + (setq max (cdar (car e))) (setcdr entry (cons (cons min max) (cdr entry))))) (setq nnsoup-group-alist-touched t)) nnsoup-group-alist)) @@ -419,12 +425,15 @@ backend for the messages.") (setq cur-prefix (nnsoup-next-prefix)) (nnheader-message 5 "Incorporating file %s..." cur-prefix) (when (file-exists-p - (setq file (concat nnsoup-tmp-directory - (gnus-soup-area-prefix area) ".IDX"))) + (setq file + (expand-file-name + (concat (gnus-soup-area-prefix area) ".IDX") + nnsoup-tmp-directory))) (rename-file file (nnsoup-file cur-prefix))) (when (file-exists-p - (setq file (concat nnsoup-tmp-directory - (gnus-soup-area-prefix area) ".MSG"))) + (setq file (expand-file-name + (concat (gnus-soup-area-prefix area) ".MSG") + nnsoup-tmp-directory))) (rename-file file (nnsoup-file cur-prefix t)) (gnus-soup-set-area-prefix area cur-prefix) ;; Find the number of new articles in this area. @@ -473,7 +482,8 @@ backend for the messages.") (goto-char (point-min)) (cond ;; rnews batch format - ((= format ?n) + ((or (= format ?u) + (= format ?n)) ;; Gnus back compatibility. (while (looking-at "^#! *rnews \\(+[0-9]+\\) *$") (forward-line 1) (push (list @@ -527,17 +537,19 @@ backend for the messages.") (let* ((file (concat prefix (if message ".MSG" ".IDX"))) (buffer-name (concat " *nnsoup " file "*"))) (or (get-buffer buffer-name) ; File already loaded. - (when (file-exists-p (concat nnsoup-directory file)) + (when (file-exists-p (expand-file-name file nnsoup-directory)) (save-excursion ; Load the file. (set-buffer (get-buffer-create buffer-name)) - (buffer-disable-undo (current-buffer)) + (buffer-disable-undo) (push (cons nnsoup-current-group (current-buffer)) nnsoup-buffers) - (nnheader-insert-file-contents (concat nnsoup-directory file)) + (nnheader-insert-file-contents + (expand-file-name file nnsoup-directory)) (current-buffer)))))) (defun nnsoup-file (prefix &optional message) (expand-file-name - (concat nnsoup-directory prefix (if message ".MSG" ".IDX")))) + (concat prefix (if message ".MSG" ".IDX")) + nnsoup-directory)) (defun nnsoup-message-buffer (prefix) (nnsoup-index-buffer prefix 'msg)) @@ -587,7 +599,7 @@ backend for the messages.") (let ((format (gnus-soup-encoding-format (gnus-soup-area-encoding (nth 1 area))))) (goto-char end) - (when (or (= format ?n) (= format ?m)) + (when (or (= format ?u) (= format ?n) (= format ?m)) (setq end (progn (forward-line -1) (point)))))) (set-buffer msg-buf)) (widen) @@ -640,25 +652,25 @@ backend for the messages.") (defun nnsoup-article-to-area (article group) "Return the area that ARTICLE in GROUP is located in." (let ((areas (cddr (assoc group nnsoup-group-alist)))) - (while (and areas (< (cdaar areas) article)) + (while (and areas (< (cdar (car areas)) article)) (setq areas (cdr areas))) (and areas (car areas)))) (defvar nnsoup-old-functions - (list message-send-mail-function message-send-news-function)) + (list message-send-mail-real-function message-send-news-function)) ;;;###autoload (defun nnsoup-set-variables () "Use the SOUP methods for posting news and mailing mail." (interactive) (setq message-send-news-function 'nnsoup-request-post) - (setq message-send-mail-function 'nnsoup-request-mail)) + (setq message-send-mail-real-function 'nnsoup-request-mail)) ;;;###autoload (defun nnsoup-revert-variables () "Revert posting and mailing methods to the standard Emacs methods." (interactive) - (setq message-send-mail-function (car nnsoup-old-functions)) + (setq message-send-mail-real-function (car nnsoup-old-functions)) (setq message-send-news-function (cadr nnsoup-old-functions))) (defun nnsoup-store-reply (kind) @@ -666,8 +678,6 @@ backend for the messages.") (require 'mail-utils) (let ((tembuf (generate-new-buffer " message temp")) (case-fold-search nil) - (real-header-separator mail-header-separator) - (mail-header-separator "") delimline (mailbuf (current-buffer))) (unwind-protect @@ -693,15 +703,11 @@ backend for the messages.") ;; Change header-delimiter to be what sendmail expects. (goto-char (point-min)) (re-search-forward - (concat "^" (regexp-quote real-header-separator) "\n")) + (concat "^" (regexp-quote mail-header-separator) "\n")) (replace-match "\n") (backward-char 1) (setq delimline (point-marker)) - ;; Insert an extra newline if we need it to work around - ;; Sun's bug that swallows newlines. (goto-char (1+ delimline)) - (when (eval message-mailer-swallows-blank-line) - (newline)) (let ((msg-buf (gnus-soup-store nnsoup-replies-directory @@ -724,7 +730,7 @@ backend for the messages.") (unless nnsoup-replies-list (setq nnsoup-replies-list (gnus-soup-parse-replies - (concat nnsoup-replies-directory "REPLIES")))) + (expand-file-name "REPLIES" nnsoup-replies-directory)))) (let ((replies nnsoup-replies-list)) (while (and replies (not (string= kind (gnus-soup-reply-kind (car replies))))) @@ -752,7 +758,6 @@ backend for the messages.") (string-to-int (match-string 1 f2))))))) active group lines ident elem min) (set-buffer (get-buffer-create " *nnsoup work*")) - (buffer-disable-undo (current-buffer)) (while files (nnheader-message 5 "Doing %s..." (car files)) (erase-buffer) @@ -770,13 +775,13 @@ backend for the messages.") (if (not (setq elem (assoc group active))) (push (list group (cons 1 lines) (list (cons 1 lines) - (vector ident group "ncm" "" lines))) + (vector ident group "ucm" "" lines))) active) (nconc elem (list (list (cons (1+ (setq min (cdadr elem))) (+ min lines)) - (vector ident group "ncm" "" lines)))) + (vector ident group "ucm" "" lines)))) (setcdr (cadr elem) (+ min lines))) (setq files (cdr files))) (nnheader-message 5 "") @@ -804,7 +809,8 @@ backend for the messages.") ;; Sort and delete the files. (setq non-files (sort non-files 'string<)) (map-y-or-n-p "Delete file %s? " - (lambda (file) (delete-file (concat nnsoup-directory file))) + (lambda (file) (delete-file + (expand-file-name file nnsoup-directory))) non-files))) (provide 'nnsoup)