From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/60187 Path: news.gmane.org!not-for-mail From: David Hansen Newsgroups: gmane.emacs.gnus.general Subject: Re: nnrss.el and element Date: Fri, 22 Apr 2005 02:15:43 +0200 Organization: disorganized Message-ID: <87oec7k6og.fsf@robotron.ath.cx> References: <873btkrvkq.fsf@robotron.ath.cx> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: sea.gmane.org 1114129447 25840 80.91.229.2 (22 Apr 2005 00:24:07 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 22 Apr 2005 00:24:07 +0000 (UTC) Original-X-From: ding-owner+M8714@lists.math.uh.edu Fri Apr 22 02:24:05 2005 Return-path: Original-Received: from malifon.math.uh.edu ([129.7.128.13]) by ciao.gmane.org with esmtp (Exim 4.43) id 1DOlxX-00021P-J3 for ding-account@gmane.org; Fri, 22 Apr 2005 02:23:52 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.math.uh.edu ident=lists) by malifon.math.uh.edu with smtp (Exim 3.20 #1) id 1DOlxZ-0004YI-00; Thu, 21 Apr 2005 19:23:53 -0500 Original-Received: from util2.math.uh.edu ([129.7.128.23]) by malifon.math.uh.edu with esmtp (Exim 3.20 #1) id 1DOlxT-0004YD-00 for ding@lists.math.uh.edu; Thu, 21 Apr 2005 19:23:47 -0500 Original-Received: from quimby.gnus.org ([80.91.224.244]) by util2.math.uh.edu with esmtp (Exim 4.30) id 1DOlxT-0005YW-2j for ding@lists.math.uh.edu; Thu, 21 Apr 2005 19:23:47 -0500 Original-Received: from main.gmane.org ([80.91.229.2] helo=ciao.gmane.org) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1DOlxR-00020y-00 for ; Fri, 22 Apr 2005 02:23:45 +0200 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1DOlsv-0001aW-In for ding@gnus.org; Fri, 22 Apr 2005 02:19:05 +0200 Original-Received: from pd9e76d3d.dip.t-dialin.net ([217.231.109.61]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 22 Apr 2005 02:19:05 +0200 Original-Received: from david.hansen by pd9e76d3d.dip.t-dialin.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 22 Apr 2005 02:19:05 +0200 X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: ding@gnus.org Original-To: ding@gnus.org Original-Lines: 120 Original-X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: pd9e76d3d.dip.t-dialin.net Mail-Copies-To: nobody User-Agent: Gnus/5.110003 (No Gnus v0.3) Emacs/22.0.50 (gnu/linux) Cancel-Lock: sha1:M4vwxWgeyW8EZpKzY0jEr3RUY34= X-Spam-Score: -4.2 (----) Precedence: bulk Original-Sender: ding-owner@lists.math.uh.edu Xref: news.gmane.org gmane.emacs.gnus.general:60187 X-Report-Spam: http://spam.gmane.org/gmane.emacs.gnus.general:60187 --=-=-= On Thu, 21 Apr 2005 17:36:05 +0200 David Hansen wrote: > seems like nnrss.el ignores the enclosure element. OK, did it myself, in case someone is interested the attached patch is against current CVS HEAD. But be aware it's the first time i touched gnus code. David --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=nnrss.diff --- cvs-src/gnus/lisp/nnrss.el 2005-04-21 23:37:13.000000000 +0200 +++ share/emacs/site-lisp/nnrss.el 2005-04-22 02:09:15.934656168 +0200 @@ -195,6 +195,7 @@ (delete "" (split-string (nth 6 e) "\n+")) " "))) (link (nth 2 e)) + (enclosure (nth 7 e)) ;; Enable encoding of Newsgroups header in XEmacs. (default-enable-multibyte-characters t) (rfc2047-header-encoding-alist @@ -203,18 +204,21 @@ rfc2047-header-encoding-alist) rfc2047-header-encoding-alist)) rfc2047-encode-encoded-words body) - (when (or text link) + (when (or text link enclosure) (insert "\n") (insert "<#multipart type=alternative>\n" "<#part type=\"text/plain\">\n") (setq body (point)) - (if text - (progn - (insert text "\n") - (when link - (insert "\n" link "\n"))) - (when link - (insert link "\n"))) + (when text + (insert text "\n") + (when (or link enclosure) + (insert "\n"))) + (when link + (insert link "\n")) + (when enclosure + (insert (car enclosure) " " + (nth 2 enclosure) " " + (nth 3 enclosure) "\n")) (setq body (buffer-substring body (point))) (insert "<#/part>\n" "<#part type=\"text/html\">\n" @@ -223,6 +227,10 @@ (insert text "\n")) (when link (insert "

link

\n")) + (when enclosure + (insert "

" + (cadr enclosure) " " (nth 2 enclosure) + " " (nth 3 enclosure) "

\n")) (insert "\n" "<#/part>\n" "<#/multipart>\n")) @@ -519,8 +527,8 @@ ;;; Snarf functions (defun nnrss-check-group (group server) - (let (file xml subject url extra changed author - date rss-ns rdf-ns content-ns dc-ns) + (let (file xml subject url extra changed author date + enclosure rss-ns rdf-ns content-ns dc-ns) (if (and nnrss-use-local (file-exists-p (setq file (expand-file-name (nnrss-translate-file-chars @@ -568,6 +576,27 @@ (setq date (or (nnrss-node-text dc-ns 'date item) (nnrss-node-text rss-ns 'pubDate item) (message-make-date))) + (when (setq enclosure (cadr (assq (intern (concat rss-ns "enclosure")) item))) + (let ((url (cdr (assq 'url enclosure))) + (len (cdr (assq 'length enclosure))) + (type (cdr (assq 'type enclosure))) + (name)) + (setq len + (if (and len (integerp (setq len (string-to-number len)))) + ;; actually already in `ls-lisp-format-file-size' but + ;; probably not worth to require it for one function + (do ((size (/ len 1.0) (/ size 1024.0)) + (post-fixes (list "" "k" "M" "G" "T" "P" "E") + (cdr post-fixes))) + ((< size 1024) + (format "%.1f%s" size (car post-fixes)))) + "0")) + (setq url (or url "")) + (setq name (if (string-match "/\\([^/]*\\)$" url) + (match-string 1 url) + "file")) + (setq type (or type "")) + (setq enclosure (list url name len type)))) (push (list (incf nnrss-group-max) @@ -576,7 +605,8 @@ (and subject (nnrss-mime-encode-string subject)) (and author (nnrss-mime-encode-string author)) date - (and extra (nnrss-decode-entities-string extra))) + (and extra (nnrss-decode-entities-string extra)) + enclosure) nnrss-group-data) (puthash (or url extra) t nnrss-group-hashtb) (setq changed t)) --=-=-=--