*** empty log message ***
[gnus] / lisp / gnus-soup.el
index 10d143f..0d95f4c 100644 (file)
@@ -1,8 +1,8 @@
 ;;; gnus-soup.el --- SOUP packet writing support for Gnus
-;; Copyright (C) 1995,96,97 Free Software Foundation, Inc.
+;; Copyright (C) 1995,96,97,98 Free Software Foundation, Inc.
 
 ;; Author: Per Abrahamsen <abraham@iesd.auc.dk>
-;;     Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
+;;     Lars Magne Ingebrigtsen <larsi@gnus.org>
 ;; Keywords: news, mail
 
 ;; This file is part of GNU Emacs.
@@ -26,6 +26,8 @@
 
 ;;; Code:
 
+(eval-when-compile (require 'cl))
+
 (require 'gnus)
 (require 'gnus-art)
 (require 'message)
 
 ;;; User Variables:
 
-(defvar gnus-soup-directory "~/SoupBrew/"
+(defvar gnus-soup-directory (nnheader-concat gnus-home-directory "SoupBrew/")
   "*Directory containing an unpacked SOUP packet.")
 
-(defvar gnus-soup-replies-directory (concat gnus-soup-directory "SoupReplies/")
+(defvar gnus-soup-replies-directory
+  (nnheader-concat gnus-soup-directory "SoupReplies/")
   "*Directory where Gnus will do processing of replies.")
 
 (defvar gnus-soup-prefix-file "gnus-prefix"
@@ -53,7 +56,7 @@ inserted where %d appears.")
   "*Format string command for unpacking a SOUP packet.
 The SOUP packet file name will be inserted at the %s.")
 
-(defvar gnus-soup-packet-directory "~/"
+(defvar gnus-soup-packet-directory gnus-home-directory
   "*Where gnus-soup will look for REPLIES packets.")
 
 (defvar gnus-soup-packet-regexp "Soupin"
@@ -129,7 +132,6 @@ If N is a negative number, add the N previous articles.
 If N is nil and any articles have been marked with the process mark,
 move those articles instead."
   (interactive "P")
-  (gnus-set-global-variables)
   (let* ((articles (gnus-summary-work-articles n))
         (tmp-buf (get-buffer-create "*soup work*"))
         (area (gnus-soup-area gnus-newsgroup-name))
@@ -159,7 +161,8 @@ move those articles instead."
        (gnus-summary-mark-as-read (car articles) gnus-souped-mark)
        (setq articles (cdr articles)))
       (kill-buffer tmp-buf))
-    (gnus-soup-save-areas)))
+    (gnus-soup-save-areas)
+    (gnus-set-mode-line 'summary)))
 
 (defun gnus-soup-pack-packet ()
   "Make a SOUP packet from the SOUP areas."
@@ -202,7 +205,9 @@ for matching on group names.
 For instance, if you want to brew on all the nnml groups, as well as
 groups with \"emacs\" in the name, you could say something like:
 
-$ emacs -batch -f gnus-batch-brew-soup ^nnml \".*emacs.*\""
+$ emacs -batch -f gnus-batch-brew-soup ^nnml \".*emacs.*\"
+
+Note -- this function hasn't been implemented yet."
   (interactive)
   nil)
 
@@ -308,6 +313,8 @@ If NOT-ALL, don't pack ticked articles."
           (or (mail-header-lines header) "0"))))
 
 (defun gnus-soup-save-areas ()
+  "Write all SOUP buffers."
+  (interactive)
   (gnus-soup-write-areas)
   (save-excursion
     (let (buf)
@@ -355,7 +362,7 @@ If NOT-ALL, don't pack ticked articles."
          (call-process shell-file-name nil nil nil shell-command-switch
                        (concat "cd " dir " ; rm " files))
          (gnus-message 4 "Packing...done" packer))
-      (error "Couldn't pack packet."))))
+      (error "Couldn't pack packet"))))
 
 (defun gnus-soup-parse-areas (file)
   "Parse soup area file FILE.
@@ -364,22 +371,23 @@ The vector contain five strings,
   [prefix name encoding description number]
 though the two last may be nil if they are missing."
   (let (areas)
-    (save-excursion
-      (set-buffer (nnheader-find-file-noselect file 'force))
-      (buffer-disable-undo (current-buffer))
-      (goto-char (point-min))
-      (while (not (eobp))
-       (push (vector (gnus-soup-field)
-                     (gnus-soup-field)
-                     (gnus-soup-field)
-                     (and (eq (preceding-char) ?\t)
-                          (gnus-soup-field))
-                     (and (eq (preceding-char) ?\t)
-                          (string-to-int (gnus-soup-field))))
-             areas)
-       (when (eq (preceding-char) ?\t)
-         (beginning-of-line 2)))
-      (kill-buffer (current-buffer)))
+    (when (file-exists-p file)
+      (save-excursion
+       (set-buffer (nnheader-find-file-noselect file 'force))
+       (buffer-disable-undo (current-buffer))
+       (goto-char (point-min))
+       (while (not (eobp))
+         (push (vector (gnus-soup-field)
+                       (gnus-soup-field)
+                       (gnus-soup-field)
+                       (and (eq (preceding-char) ?\t)
+                            (gnus-soup-field))
+                       (and (eq (preceding-char) ?\t)
+                            (string-to-int (gnus-soup-field))))
+               areas)
+         (when (eq (preceding-char) ?\t)
+           (beginning-of-line 2)))
+       (kill-buffer (current-buffer))))
     areas))
 
 (defun gnus-soup-parse-replies (file)
@@ -515,12 +523,11 @@ Return whether the unpacking was successful."
            t)
           (t
            (buffer-disable-undo msg-buf)
-           (buffer-disable-undo tmp-buf)
            (set-buffer msg-buf)
            (goto-char (point-min))
            (while (not (eobp))
              (unless (looking-at "#! *rnews +\\([0-9]+\\)")
-               (error "Bad header."))
+               (error "Bad header"))
              (forward-line 1)
              (setq beg (point)
                    end (+ (point) (string-to-int