(defvar gnus-soup-packer "tar cf - %s | gzip > $HOME/Soupout%d.tgz"
"Format string command for packing a SOUP packet.
The SOUP files will be inserted where the %s is in the string.
-This string MUST contain both %s and %d. The file number will be
+This string MUST contain both %s and %d. The file number will be
inserted where %d appears.")
(defvar gnus-soup-unpacker "gunzip -c %s | tar xvf -"
(defvar gnus-soup-index-type ?c
"*Soup index type.
`n' means no index file and `c' means standard Cnews overview
-format.")
+format.")
(defvar gnus-soup-areas nil)
(defvar gnus-soup-last-prefix nil)
(let ((packets (directory-files
gnus-soup-packet-directory t gnus-soup-packet-regexp)))
(while packets
- (and (gnus-soup-send-packet (car packets))
- (delete-file (car packets)))
+ (when (gnus-soup-send-packet (car packets))
+ (delete-file (car packets)))
(setq packets (cdr packets)))))
(defun gnus-soup-add-article (n)
(let ((level (or level gnus-level-subscribed))
(newsrc (cdr gnus-newsrc-alist)))
(while newsrc
- (and (<= (nth 1 (car newsrc)) level)
- (gnus-soup-group-brew (caar newsrc) t))
+ (when (<= (nth 1 (car newsrc)) level)
+ (gnus-soup-group-brew (caar newsrc) t))
(setq newsrc (cdr newsrc)))
(gnus-soup-save-areas)))
from head-line beg type)
(setq gnus-soup-buffers (cons msg-buf (delq msg-buf gnus-soup-buffers)))
(buffer-disable-undo msg-buf)
- (and idx-buf
- (progn
- (setq gnus-soup-buffers (cons idx-buf gnus-soup-buffers))
- (buffer-disable-undo idx-buf)))
+ (when idx-buf
+ (push idx-buf gnus-soup-buffers)
+ (buffer-disable-undo idx-buf))
(save-excursion
;; Make sure the last char in the buffer is a newline.
(goto-char (point-max))
- (or (= (current-column) 0)
- (insert "\n"))
+ (unless (= (current-column) 0)
+ (insert "\n"))
;; Find the "from".
(goto-char (point-min))
(setq from
(lambda (time) (int-to-string time))
(current-time) "-")))
(or (mail-header-references header) "")
- (or (mail-header-chars header) 0)
+ (or (mail-header-chars header) 0)
(or (mail-header-lines header) "0"))))
(defun gnus-soup-save-areas ()
(if (not (buffer-name buf))
()
(set-buffer buf)
- (and (buffer-modified-p) (save-buffer))
+ (when (buffer-modified-p)
+ (save-buffer))
(kill-buffer (current-buffer)))))
(gnus-soup-write-prefixes)))
(defun gnus-soup-write-prefixes ()
- (let ((prefix gnus-soup-last-prefix))
+ (let ((prefixes gnus-soup-last-prefix)
+ prefix)
(save-excursion
- (while prefix
- (gnus-set-work-buffer)
- (insert (format "(setq gnus-soup-prev-prefix %d)\n" (cdar prefix)))
- (gnus-make-directory (caar prefix))
- (write-region (point-min) (point-max)
- (concat (caar prefix) gnus-soup-prefix-file)
- nil 'nomesg)
- (setq prefix (cdr prefix))))))
+ (gnus-set-work-buffer)
+ (while (setq prefix (pop prefixes))
+ (erase-buffer)
+ (insert (format "(setq gnus-soup-prev-prefix %d)\n" (cdr prefix)))
+ (gnus-write-buffer (concat (car prefix) gnus-soup-prefix-file))))))
(defun gnus-soup-pack (dir packer)
(let* ((files (mapconcat 'identity
(buffer-disable-undo (current-buffer))
(goto-char (point-min))
(while (not (eobp))
- (setq areas
- (cons (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))
- (if (eq (preceding-char) ?\t)
- (beginning-of-line 2)))
+ (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)
"Parse soup REPLIES file FILE.
The result is a of vectors, each containing one entry from the REPLIES
-file. The vector contain three strings, [prefix name encoding]."
+file. The vector contain three strings, [prefix name encoding]."
(let (replies)
(save-excursion
(set-buffer (find-file-noselect file))
(buffer-disable-undo (current-buffer))
(goto-char (point-min))
(while (not (eobp))
- (setq replies
- (cons (vector (gnus-soup-field) (gnus-soup-field)
- (gnus-soup-field))
- replies))
- (if (eq (preceding-char) ?\t)
- (beginning-of-line 2)))
+ (push (vector (gnus-soup-field) (gnus-soup-field)
+ (gnus-soup-field))
+ replies)
+ (when (eq (preceding-char) ?\t)
+ (beginning-of-line 2)))
(kill-buffer (current-buffer)))
replies))
(format
"%s\t%s\t%s%s\n"
(gnus-soup-area-prefix area)
- (gnus-soup-area-name area)
+ (gnus-soup-area-name area)
(gnus-soup-area-encoding area)
- (if (or (gnus-soup-area-description area)
+ (if (or (gnus-soup-area-description area)
(gnus-soup-area-number area))
(concat "\t" (or (gnus-soup-area-description
area) "")
(while (setq area (pop areas))
(insert (format "%s\t%s\t%s\n"
(gnus-soup-reply-prefix area)
- (gnus-soup-reply-kind area)
+ (gnus-soup-reply-kind area)
(gnus-soup-reply-encoding area)))))))
(defun gnus-soup-area (group)
(while areas
(setq area (car areas)
areas (cdr areas))
- (if (equal (gnus-soup-area-name area) real-group)
- (setq result area)))
- (or result
- (setq result
- (vector (gnus-soup-unique-prefix)
- real-group
- (format "%c%c%c"
- gnus-soup-encoding-type
- gnus-soup-index-type
- (if (gnus-member-of-valid 'mail group) ?m ?n))
- nil nil)
- gnus-soup-areas (cons result gnus-soup-areas)))
+ (when (equal (gnus-soup-area-name area) real-group)
+ (setq result area)))
+ (unless result
+ (setq result
+ (vector (gnus-soup-unique-prefix)
+ real-group
+ (format "%c%c%c"
+ gnus-soup-encoding-type
+ gnus-soup-index-type
+ (if (gnus-member-of-valid 'mail group) ?m ?n))
+ nil nil)
+ gnus-soup-areas (cons result gnus-soup-areas)))
result))
(defun gnus-soup-unique-prefix (&optional dir)
gnus-soup-prev-prefix)
(if entry
()
- (and (file-exists-p (concat dir gnus-soup-prefix-file))
- (condition-case nil
- (load (concat dir gnus-soup-prefix-file) nil t t)
- (error nil)))
- (setq gnus-soup-last-prefix
- (cons (setq entry (cons dir (or gnus-soup-prev-prefix 0)))
- gnus-soup-last-prefix)))
+ (when (file-exists-p (concat dir gnus-soup-prefix-file))
+ (condition-case nil
+ (load (concat dir gnus-soup-prefix-file) nil t t)
+ (error nil)))
+ (push (setq entry (cons dir (or gnus-soup-prev-prefix 0)))
+ gnus-soup-last-prefix))
(setcdr entry (1+ (cdr entry)))
(gnus-soup-write-prefixes)
(int-to-string (cdr entry))))
(prog1
(zerop (call-process
shell-file-name nil nil nil shell-command-switch
- (format "cd %s ; %s" (expand-file-name dir)
+ (format "cd %s ; %s" (expand-file-name dir)
(format unpacker packet))))
(gnus-message 4 "Unpacking...done")))
beg end)
(cond
((/= (gnus-soup-encoding-format
- (gnus-soup-reply-encoding (car replies))) ?n)
+ (gnus-soup-reply-encoding (car replies)))
+ ?n)
(error "Unsupported encoding"))
((null msg-buf)
t)
(set-buffer msg-buf)
(goto-char (point-min))
(while (not (eobp))
- (or (looking-at "#! *rnews +\\([0-9]+\\)")
- (error "Bad header."))
+ (unless (looking-at "#! *rnews +\\([0-9]+\\)")
+ (error "Bad header."))
(forward-line 1)
(setq beg (point)
end (+ (point) (string-to-int
(funcall message-send-news-function)))
((string= (gnus-soup-reply-kind (car replies)) "mail")
(gnus-message 5 "Sending mail to %s..."
- (mail-fetch-field "to"))
+ (mail-fetch-field "to"))
(sit-for 1)
(message-send-mail))
(t