Function: nnrss-request-article
nnrss-request-article is a byte-compiled function defined in
nnrss.el.gz.
Signature
(nnrss-request-article ARTICLE &optional GROUP SERVER BUFFER)
Source Code
;; Defined in /usr/src/emacs/lisp/gnus/nnrss.el.gz
(deffoo nnrss-request-article (article &optional group server buffer)
(setq group (nnrss-decode-group-name group))
(when (stringp article)
(setq article (if (string-match "\\`<\\([0-9]+\\)@" article)
(string-to-number (match-string 1 article))
0)))
(nnrss-possibly-change-group group server)
(let ((e (assq article nnrss-group-data))
(nntp-server-buffer (or buffer nntp-server-buffer))
) ;; err post
(when e
(with-current-buffer nntp-server-buffer
(erase-buffer)
(if group
(insert "Newsgroups: " group "\n"))
(if (nth 3 e)
(insert "Subject: " (nth 3 e) "\n"))
(if (nth 4 e)
(insert "From: " (nth 4 e) "\n"))
(if (nth 5 e)
(insert "Date: " (nnrss-format-string (nth 5 e)) "\n"))
(let ((header (buffer-string))
(text (nth 6 e))
(link (nth 2 e))
(enclosure (nth 7 e))
(comments (nth 8 e))
(rfc2047-header-encoding-alist
(if (mm-coding-system-p 'utf-8)
(cons '("Newsgroups" . utf-8)
rfc2047-header-encoding-alist)
rfc2047-header-encoding-alist))
rfc2047-encode-encoded-words body) ;; fn
(when (or text link enclosure comments)
(insert "\n")
(insert "<#multipart type=alternative>\n"
"<#part type=\"text/plain\">\n")
(setq body (point))
(when text
(insert text)
(goto-char body)
(while (re-search-forward "\n+" nil t)
(replace-match " "))
(goto-char body)
;; See `nnrss-check-group', which inserts "<br /><br />".
(when (search-forward "<br /><br />" nil t)
(if (eobp)
(replace-match "\n")
(replace-match "\n\n")))
(unless (eobp)
(let ((fill-column (default-value 'fill-column))
(window (get-buffer-window nntp-server-buffer)))
(when window
(setq fill-column
(max 1 (/ (* (window-width window) 7) 8))))
(fill-region (point) (point-max))
(goto-char (point-max))
(unless (bolp)
(insert "\n"))))
(when (or link enclosure)
(insert "\n")))
(when link
(insert link "\n"))
(when enclosure
(insert (car enclosure) " "
(nth 2 enclosure) " "
(nth 3 enclosure) "\n"))
(when comments
(insert comments "\n"))
(setq body (buffer-substring body (point)))
(insert "<#/part>\n"
"<#part type=\"text/html\">\n"
"<html><head></head><body>\n")
(when text
(insert text "\n"))
(when link
(insert "<p><a href=\"" link "\">link</a></p>\n"))
(when enclosure
(insert "<p><a href=\"" (car enclosure) "\">"
(cadr enclosure) "</a> " (nth 2 enclosure)
" " (nth 3 enclosure) "</p>\n"))
(when comments
(insert "<p><a href=\"" comments "\">comments</a></p>\n"))
(insert "</body></html>\n"
"<#/part>\n"
"<#/multipart>\n"))
(condition-case nil
;; Allow `mml-to-mime' to generate MIME article without
;; making inquiry to a user for unknown encoding.
(let ((mml-confirmation-set
(cons 'unknown-encoding mml-confirmation-set)))
(mml-to-mime))
(error
(erase-buffer)
(insert header
"Content-Type: text/plain; charset=gnus-decoded\n"
"Content-Transfer-Encoding: 8bit\n\n"
body)
(nnheader-message
3 "Warning - there might be invalid characters"))))
(goto-char (point-min))
(search-forward "\n\n")
(forward-line -1)
(insert (format "Message-ID: <%d@%s.nnrss>\n"
(car e)
(let ((rfc2047-encoding-type 'mime)
rfc2047-encode-max-chars)
(rfc2047-encode-string
(replace-regexp-in-string "[\t\n ]+" "_" group)))))
(when nnrss-content-function
(funcall nnrss-content-function e group article))))
(cond
;; (err (nnheader-report 'nnrss err))
((not e)
(nnheader-report 'nnrss "no such id: %d" article))
(t
(nnheader-report 'nnrss "article %s retrieved" (car e))
;; we return the article number.
(cons nnrss-group (car e))))))