+(defun nnheader-insert-references (references message-id)
+ (if (and (not references) (not message-id))
+ () ; This is illegal, but not all articles have Message-IDs.
+ ;; Fold long references line to follow RFC1036.
+ (mail-position-on-field "References")
+ (let ((begin (save-excursion (beginning-of-line) (point)))
+ (fill-column 78)
+ (fill-prefix "\t"))
+ (if references (insert references))
+ (if (and references message-id) (insert " "))
+ (if message-id (insert message-id))
+ ;; The region must end with a newline to fill the region
+ ;; without inserting extra newline.
+ (fill-region-as-paragraph begin (1+ (point))))))
+
+(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 ":")))
+ (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))))
+ 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)))