*** empty log message ***
[gnus] / lisp / nnheader.el
index daa8e8b..901643c 100644 (file)
@@ -37,6 +37,8 @@
 ;;; Code:
 
 (require 'mail-utils)
+(require 'sendmail)
+(eval-when-compile (require 'cl))
 
 (defvar nnheader-max-head-length 4096
   "*Max length of the head of articles.")
@@ -364,24 +366,60 @@ The buffer is not selected, just returned to the caller."
        ;; without inserting extra newline.
        (fill-region-as-paragraph begin (1+ (point))))))
 
-(defun nnheader-remove-header (header &optional is-regexp)
+(defun nnheader-remove-header (header &optional is-regexp first)
+  "Remove HEADER.
+If FIRST, only remove the first instance if the header.
+Return the number of headers removed."
   (goto-char (point-min))
   (let ((regexp (if is-regexp header (concat "^" header ":")))
-       (case-fold-search t))
-    (while (re-search-forward regexp nil t)
+       (number 0)
+       (case-fold-search t)
+       last)
+    (while (and (re-search-forward regexp nil t)
+               (not last))
+      (incf number)
+      (when first
+       (setq last t))
       (delete-region
        (match-beginning 0) 
        ;; There might be a continuation header, so we have to search
        ;; until we find a new non-continuation line.
        (if (re-search-forward "^[^ \t]" nil t)
           (match-beginning 0)
-        (point-max))))))
+        (point-max))))
+    number))
 
 (defun nnheader-set-temp-buffer (name)
   (set-buffer (get-buffer-create name))
   (buffer-disable-undo (current-buffer))
   (erase-buffer))
 
+(defvar jka-compr-compression-info-list)
+(defvar nnheader-numerical-files
+  (if (boundp 'jka-compr-compression-info-list)
+      (concat "\\([0-9]+\\)\\(" 
+             (mapconcat (lambda (i) (aref i 0))
+                        jka-compr-compression-info-list "\\|")
+             "\\)?")
+    "[0-9]+$")
+  "Regexp that match numerical files.")
+
+(defvar nnheader-numerical-short-files (concat "^" nnheader-numerical-files)
+  "Regexp that matches numerical file names.")
+
+(defvar nnheader-numerical-full-files (concat "/" nnheader-numerical-files)
+  "Regexp that matches numerical full file paths.")
+
+(defun nnheader-file-to-number (file)
+  (if (not (boundp 'jka-compr-compression-info-list))
+      (string-to-int file)
+    (string-match nnheader-numerical-short-files file)
+    (match-string 1 file)))
+
+(defun nnheader-directory-articles (dir)
+  (mapcar 'nnheader-file-to-number
+         (directory-files dir nil nnheader-numerical-short-files t)))
+
 (provide 'nnheader)
 
 ;;; nnheader.el ends here