; ; SANS PrivacyBits and NewsBites Digests ; (defun nndoc-sans-digest-type-p nil "Decide whether an article is a SANS digest" (let ((case-fold-search nil)) (not (not (and (re-search-forward "^From: The SANS Institute" nil t) (re-search-forward "^SANS PrivacyBits\\|SANS NewsBites" nil t)) ))) ) (defun nndoc-generate-sans-digest-head (article) "Generate headers for a SANS digest article" (let ((entry (cdr (assq article nndoc-dissection-alist))) (subject "Couldn't find subject")) (save-excursion (set-buffer nndoc-current-buffer) (save-restriction (narrow-to-region (car entry) (nth 3 entry)) (goto-char (point-min)) (while (looking-at "^[_*]*$") (forward-line 1)) ; Following test is a huge kludge (if (let ((case-fold-search nil)) (looking-at "^[A-Z ']+$")) (forward-line 2)) (if (looking-at "^ +-- *\\(.*\\)$") (progn (setq subject (match-string 1)) (while (and (forward-line 1) (looking-at "^ +\\([^ ].*\\)$")) (setq subject (concat subject " " (match-string 1)))) )) )) (insert "Subject: " subject "\n") )) (defun nndoc-transform-sans-digest-article (article) "Transform a SANS digest article so that it matches nndoc expectations." (goto-char (point-min)) (while (eq (following-char) ?\n) (delete-char 1)) (if (looking-at "^ +--") (progn (delete-char 3) (insert "Subject: ") (end-of-line) (while (looking-at "\n +[^ ]") (delete-char 1) (just-one-space) (end-of-line)) (insert "\n"))) ) (nndoc-add-type '(sans-digest ; (first-article . "^TOP OF THE NEWS\\(.*\n\\)*TOP OF THE NEWS\\s-+--") (first-article . "^ +--") (article-begin . "^ +--") (head-end . "$") (body-begin . "^") (body-end . "^ *$") (file-end . "^==end==$") (generate-head-function . nndoc-generate-sans-digest-head) (article-transform-function . nndoc-transform-sans-digest-article) ))