(defvoo nnrss-group-max 0)
(defvoo nnrss-group-min 1)
(defvoo nnrss-group nil)
-(defvoo nnrss-group-hashtb nil)
+(defvoo nnrss-group-hashtb (make-hash-table :test 'equal))
(defvoo nnrss-status-string "")
(defconst nnrss-version "nnrss 1.0")
(nth 2 e))))
(insert "\n\n--" boundary "\nContent-Type: text/plain\n\n")
(let ((point (point)))
- (if text
- (progn (insert text)
- (goto-char point)
- (while (re-search-forward "\n" nil t)
- (replace-match " "))
- (goto-char (point-max))
- (insert "\n\n")))
- (if link
- (insert link)))
+ (when text
+ (insert text)
+ (goto-char point)
+ (while (re-search-forward "\n" nil t)
+ (replace-match " "))
+ (goto-char (point-max))
+ (insert "\n\n"))
+ (when link
+ (insert link)))
(insert "\n\n--" boundary "\nContent-Type: text/html\n\n")
(let ((point (point)))
- (if text
- (progn (insert "<html><head></head><body>\n" text "\n</body></html>")
- (goto-char point)
- (while (re-search-forward "\n" nil t)
- (replace-match " "))
- (goto-char (point-max))
- (insert "\n\n")))
- (if link
- (insert "<p><a href=\"" link "\">link</a></p>\n"))))
- (if nnrss-content-function
- (funcall nnrss-content-function e group article)))))
+ (when text
+ (insert "<html><head></head><body>\n" text "\n</body></html>")
+ (goto-char point)
+ (while (re-search-forward "\n" nil t)
+ (replace-match " "))
+ (goto-char (point-max))
+ (insert "\n\n"))
+ (when link
+ (insert "<p><a href=\"" link "\">link</a></p>\n"))))
+ (when nnrss-content-function
+ (funcall nnrss-content-function e group article)))))
(cond
(err
(nnheader-report 'nnrss err))
(setq nnrss-server-data
(delq (assoc group nnrss-server-data) nnrss-server-data))
(nnrss-save-server-data server)
- (let ((file (expand-file-name
- (nnrss-translate-file-chars
- (concat group (and server
- (not (equal server ""))
- "-")
- server ".el")) nnrss-directory)))
- (ignore-errors
- (delete-file file)))
+ (ignore-errors
+ (delete-file (nnrss-make-filename group server)))
t)
(deffoo nnrss-request-list-newsgroups (&optional server)
(defun nnrss-read-server-data (server)
(setq nnrss-server-data nil)
- (let ((file (expand-file-name
- (nnrss-translate-file-chars
- (concat "nnrss" (and server
- (not (equal server ""))
- "-")
- server
- ".el"))
- nnrss-directory)))
+ (let ((file (nnrss-make-filename "nnrss" server)))
(when (file-exists-p file)
- (with-temp-buffer
- (let ((coding-system-for-read 'binary)
- (input-coding-system 'binary)
- emacs-lisp-mode-hook)
- (insert-file-contents file)
- (emacs-lisp-mode)
- (goto-char (point-min))
- (eval-buffer))))))
+ (let ((coding-system-for-read 'binary))
+ (load file nil nil t)))))
(defun nnrss-save-server-data (server)
(gnus-make-directory nnrss-directory)
- (let ((file (expand-file-name
- (nnrss-translate-file-chars
- (concat "nnrss" (and server
- (not (equal server ""))
- "-")
- server ".el"))
- nnrss-directory)))
- (let ((coding-system-for-write 'binary)
- (output-coding-system 'binary)
- print-level print-length)
- (with-temp-file file
- (insert "(setq nnrss-group-alist '"
- (prin1-to-string nnrss-group-alist)
- ")\n")
- (insert "(setq nnrss-server-data '"
- (prin1-to-string nnrss-server-data)
- ")\n")))))
+ (let ((coding-system-for-write 'binary))
+ (with-temp-file (nnrss-make-filename "nnrss" server)
+ (gnus-prin1 `(setq nnrss-group-alist ',nnrss-group-alist))
+ (gnus-prin1 `(setq nnrss-server-data ',nnrss-server-data)))))
(defun nnrss-read-group-data (group server)
(setq nnrss-group-data nil)
- (setq nnrss-group-hashtb (gnus-make-hashtable))
+ (if (hash-table-p nnrss-group-hashtb)
+ (clrhash nnrss-group-hashtb)
+ (setq nnrss-group-hashtb (make-hash-table :test 'equal)))
(let ((pair (assoc group nnrss-server-data)))
(setq nnrss-group-max (or (cadr pair) 0))
(setq nnrss-group-min (+ nnrss-group-max 1)))
- (let ((file (expand-file-name
- (nnrss-translate-file-chars
- (concat group (and server
- (not (equal server ""))
- "-")
- server ".el"))
- nnrss-directory)))
+ (let ((file (nnrss-make-filename group server)))
(when (file-exists-p file)
- (with-temp-buffer
- (let ((coding-system-for-read 'binary)
- (input-coding-system 'binary)
- emacs-lisp-mode-hook)
- (insert-file-contents file)
- (emacs-lisp-mode)
- (goto-char (point-min))
- (eval-buffer)))
+ (let ((coding-system-for-read 'binary))
+ (load file nil t t))
(dolist (e nnrss-group-data)
- (gnus-sethash (nth 2 e) e nnrss-group-hashtb)
- (if (and (car e) (> nnrss-group-min (car e)))
- (setq nnrss-group-min (car e)))
- (if (and (car e) (< nnrss-group-max (car e)))
- (setq nnrss-group-max (car e)))))))
+ (puthash (nth 2 e) e nnrss-group-hashtb)
+ (when (and (car e) (> nnrss-group-min (car e)))
+ (setq nnrss-group-min (car e)))
+ (when (and (car e) (< nnrss-group-max (car e)))
+ (setq nnrss-group-max (car e)))))))
(defun nnrss-save-group-data (group server)
(gnus-make-directory nnrss-directory)
- (let ((file (expand-file-name
- (nnrss-translate-file-chars
- (concat group (and server
- (not (equal server ""))
- "-")
- server ".el"))
- nnrss-directory)))
- (let ((coding-system-for-write 'binary)
- (output-coding-system 'binary)
- print-level print-length)
- (with-temp-file file
- (insert "(setq nnrss-group-data '"
- (prin1-to-string nnrss-group-data)
- ")\n")))))
+ (let ((coding-system-for-write 'binary))
+ (with-temp-file (nnrss-make-filename group server)
+ (gnus-prin1 `(setq nnrss-group-data ',nnrss-group-data )))))
+
+(defun nnrss-make-filename (name server)
+ (expand-file-name
+ (nnrss-translate-file-chars
+ (concat name
+ (and server
+ (not (equal server ""))
+ "-")
+ server
+ ".el"))
+ nnrss-directory))
+
+(gnus-add-shutdown 'nnrss-close 'gnus)
+
+(defun nnrss-close ()
+ "Clear internal nnrss variables."
+ (setq nnrss-group-data nil
+ nnrss-server-data nil
+ nnrss-group-hashtb nil
+ nnrss-group-alist nil))
;;; URL interface
(nnrss-translate-file-chars
(concat group ".xml"))
nnrss-directory))))
- (nnrss-fetch file t)
+ (setq xml (nnrss-fetch file t))
(setq url (or (nth 2 (assoc group nnrss-server-data))
(second (assoc group nnrss-group-alist))))
(unless url
(eq (intern (concat rss-ns "item")) (car item))
(setq url (nnrss-decode-entities-unibyte-string
(nnrss-node-text rss-ns 'link (cddr item))))
- (not (gnus-gethash url nnrss-group-hashtb)))
+ (not (gethash url nnrss-group-hashtb)))
(setq subject (nnrss-node-text rss-ns 'title item))
(setq extra (or (nnrss-node-text content-ns 'encoded item)
(nnrss-node-text rss-ns 'description item)))
(setq author (or (nnrss-node-text rss-ns 'author item)
- (nnrss-node-text dc-ns 'creator item)))
+ (nnrss-node-text dc-ns 'creator item)
+ (nnrss-node-text dc-ns 'contributor item)))
(setq date (or (nnrss-node-text dc-ns 'date item)
(nnrss-node-text rss-ns 'pubDate item)
(message-make-date)))
date
(and extra (nnrss-decode-entities-unibyte-string extra)))
nnrss-group-data)
- (gnus-sethash url (car nnrss-group-data) nnrss-group-hashtb)
+ (puthash url (car nnrss-group-data) nnrss-group-hashtb)
(setq changed t)))
(when changed
(nnrss-save-group-data group server)
large documents!"
(if (listp data)
(mapcar (lambda (bit)
- (if (car-safe bit)
- (progn (if (equal tag (car bit))
- (setq found-list
- (append found-list
- (list bit))))
- (if (and (listp (car-safe (caddr bit)))
- (not (stringp (caddr bit))))
- (setq found-list
- (append found-list
- (nnrss-find-el
- tag (caddr bit))))
- (setq found-list
- (append found-list
- (nnrss-find-el
- tag (cddr bit))))))))
- data))
+ (when (car-safe bit)
+ (when (equal tag (car bit))
+ (setq found-list
+ (append found-list
+ (list bit))))
+ (if (and (listp (car-safe (caddr bit)))
+ (not (stringp (caddr bit))))
+ (setq found-list
+ (append found-list
+ (nnrss-find-el
+ tag (caddr bit))))
+ (setq found-list
+ (append found-list
+ (nnrss-find-el
+ tag (cddr bit)))))))
+ data))
found-list)
(defun nnrss-rsslink-p (el)
(defun nnrss-find-rss-via-syndic8 (url)
"query syndic8 for the rss feeds it has for the url."
- (if (locate-library "xml-rpc")
- (progn (require 'xml-rpc)
- (let ((feedid (xml-rpc-method-call
- "http://www.syndic8.com/xmlrpc.php"
- 'syndic8.FindSites
- url)))
- (if feedid
- (let* ((feedinfo (xml-rpc-method-call
- "http://www.syndic8.com/xmlrpc.php"
- 'syndic8.GetFeedInfo
- feedid))
- (urllist
- (delq nil
- (mapcar
- (lambda (listinfo)
- (if (string-equal
- (cdr (assoc "status" listinfo))
- "Syndicated")
- (cons
- (cdr (assoc "sitename" listinfo))
- (list
- (cons 'title
- (cdr (assoc
- "sitename" listinfo)))
- (cons 'href
- (cdr (assoc
- "dataurl" listinfo)))))))
- feedinfo))))
- (if (> (length urllist) 1)
- (let ((completion-ignore-case t)
- (selection
- (mapcar (lambda (listinfo)
- (cons (cdr (assoc "sitename" listinfo))
- (string-to-int
- (cdr (assoc "feedid" listinfo)))))
- feedinfo)))
- (cdr (assoc
- (completing-read
- "Multiple feeds found. Select one: "
- selection nil t) urllist)))
- (cdar urllist))))))
- (error (message "XML-RPC is not available... not checking Syndic8."))))
+ (if (not (locate-library "xml-rpc"))
+ (progn
+ (message "XML-RPC is not available... not checking Syndic8.")
+ nil)
+ (require 'xml-rpc)
+ (let ((feedid (xml-rpc-method-call
+ "http://www.syndic8.com/xmlrpc.php"
+ 'syndic8.FindSites
+ url)))
+ (when feedid
+ (let* ((feedinfo (xml-rpc-method-call
+ "http://www.syndic8.com/xmlrpc.php"
+ 'syndic8.GetFeedInfo
+ feedid))
+ (urllist
+ (delq nil
+ (mapcar
+ (lambda (listinfo)
+ (if (string-equal
+ (cdr (assoc "status" listinfo))
+ "Syndicated")
+ (cons
+ (cdr (assoc "sitename" listinfo))
+ (list
+ (cons 'title
+ (cdr (assoc
+ "sitename" listinfo)))
+ (cons 'href
+ (cdr (assoc
+ "dataurl" listinfo)))))))
+ feedinfo))))
+ (if (not (> (length urllist) 1))
+ (cdar urllist)
+ (let ((completion-ignore-case t)
+ (selection
+ (mapcar (lambda (listinfo)
+ (cons (cdr (assoc "sitename" listinfo))
+ (string-to-int
+ (cdr (assoc "feedid" listinfo)))))
+ feedinfo)))
+ (cdr (assoc
+ (completing-read
+ "Multiple feeds found. Select one: "
+ selection nil t) urllist)))))))))
(defun nnrss-rss-p (data)
"Test if data is an RSS feed. Simply ensures that the first