; ; Slashdot Daily Newsletter ; (defun nndoc-slashdot-type-p nil "Decide whether an article is a Slashdot digest" (let ((case-fold-search nil)) (and (re-search-forward "^Subject: \\(Slashdot Newsletter\\|=\\?utf-8\\?Q\\?Slashdot=20Newsletter\\)" nil t) (search-forward "\n\nSlashdot Daily News" nil t) t))) (defun nndoc-slashdot-article-begin nil "Find the beginning of a Slashdot article, rejecting unwanted areas" (let ((case-fold-search nil) here limit (keep-looking t)) (when first (goto-char (point-min)) (re-search-forward "^Slashdot Daily News") (skip-chars-forward "\n") (search-forward "\n\n\n") (when (looking-at "_\\{70,\\}\n\nSlashback") (forward-line 2) (re-search-forward "^_\\{70,\\}$"))) (while (and keep-looking (re-search-forward "^\n+" nil t) (not (looking-at "See all today's stories"))) (setq here (point)) (re-search-forward "\n\n+") (skip-chars-backward "\n") (forward-char 1) (when (> (count-lines here (point)) 2) (setq keep-looking nil) (goto-char here)) ) (beginning-of-line) (not keep-looking) )) (defun nndoc-slashdot-grab-from nil "Extract a reasonable value for the From: field" (if (not (and (re-search-forward "^>?From " nil t) (re-search-forward "^\\(.*submitter \\)?\\(.*\\) writes " nil t))) "unknown" (match-string 2))) (defun nndoc-generate-slashdot-head (article) "Generate headers for a Slashdot article" (let ((entry (cdr (assq article nndoc-dissection-alist))) (subject "Couldn't find subject") (from "(unknown)")) (save-excursion (set-buffer nndoc-current-buffer) (save-restriction (narrow-to-region (car entry) (nth 3 entry)) (goto-char (point-min)) (search-forward " http://") (goto-char (match-beginning 0)) (setq subject (buffer-substring (point-min) (point))) (setq from (nndoc-slashdot-grab-from)) )) (insert "From: " from "\n" "Subject: " subject "\n" "\n") )) (defun nndoc-transform-slashdot-article (article) "Transform a Slashdot article to a reasonable format" (let ((subject "Couldn't find subject") (from "(unknown)")) (goto-char (point-min)) (re-search-forward " https?://") (goto-char (match-beginning 0)) (setq subject (buffer-substring (point-min) (point))) (setq from (nndoc-slashdot-grab-from)) (goto-char (point-min)) (search-forward "\n\n") (delete-region (point-min) (point)) (insert "From: " from "\n" "Subject: " subject "\n" "\n") )) (nndoc-add-type `(slashdot (article-begin-function . nndoc-slashdot-article-begin) (head-end . "^>?From ") (body-begin . "^>?From ") (body-end . "^$") (file-end . "^See all today's stories") (generate-head-function . nndoc-generate-slashdot-head) (article-transform-function . nndoc-transform-slashdot-article) ) t)