From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/67752 Path: news.gmane.org!not-for-mail From: Kevin Ryde Newsgroups: gmane.emacs.gnus.general Subject: Content-Location for w3m display (was: Using nnrss very actively) Date: Tue, 04 Nov 2008 10:43:16 +1100 Organization: Bah Humbug Message-ID: <87d4hc2x63.fsf_-_@blah.blah> References: <87k5c5lcic.fsf@blah.blah> <87tzb1tua9.fsf@blah.blah> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1225755866 559 80.91.229.12 (3 Nov 2008 23:44:26 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 3 Nov 2008 23:44:26 +0000 (UTC) To: ding@gnus.org Original-X-From: ding-owner+M16203@lists.math.uh.edu Tue Nov 04 00:45:28 2008 connect(): Connection refused Return-path: Envelope-to: ding-account@gmane.org Original-Received: from util0.math.uh.edu ([129.7.128.18]) by lo.gmane.org with esmtp (Exim 4.50) id 1Kx96p-0002f5-0J for ding-account@gmane.org; Tue, 04 Nov 2008 00:45:23 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.math.uh.edu) by util0.math.uh.edu with smtp (Exim 4.63) (envelope-from ) id 1Kx95a-00026q-Au; Mon, 03 Nov 2008 17:44:06 -0600 Original-Received: from mx1.math.uh.edu ([129.7.128.32]) by util0.math.uh.edu with esmtps (TLSv1:AES256-SHA:256) (Exim 4.63) (envelope-from ) id 1Kx95Z-00026h-24 for ding@lists.math.uh.edu; Mon, 03 Nov 2008 17:44:05 -0600 Original-Received: from quimby.gnus.org ([80.91.231.51]) by mx1.math.uh.edu with esmtp (Exim 4.69) (envelope-from ) id 1Kx95V-0005Xv-I7 for ding@lists.math.uh.edu; Mon, 03 Nov 2008 17:44:04 -0600 Original-Received: from mailout2-5.pacific.net.au ([61.8.2.228] helo=mailout2.pacific.net.au) by quimby.gnus.org with esmtp (Exim 3.36 #1 (Debian)) id 1Kx95b-0003S6-00 for ; Tue, 04 Nov 2008 00:44:08 +0100 Original-Received: from mailproxy2.pacific.net.au (mailproxy2.pacific.net.au [61.8.2.163]) by mailout2.pacific.net.au (Postfix) with ESMTP id 2C0FDBDA25 for ; Tue, 4 Nov 2008 10:43:54 +1100 (EST) Original-Received: from blah.blah (ppp2E5C.dyn.pacific.net.au [61.8.46.92]) by mailproxy2.pacific.net.au (Postfix) with ESMTP id E5AD42743E for ; Tue, 4 Nov 2008 10:43:52 +1100 (EST) Original-Received: from gg by blah.blah with local (Exim 4.69) (envelope-from ) id 1Kx94m-00010S-AP for ding@gnus.org; Tue, 04 Nov 2008 10:43:16 +1100 In-Reply-To: <87tzb1tua9.fsf@blah.blah> (Kevin Ryde's message of "Sat, 25 Oct 2008 11:03:58 +1100") User-Agent: Gnus/5.110011 (No Gnus v0.11) Emacs/22.2 (gnu/linux) X-Spam-Score: -2.6 (--) List-ID: Precedence: bulk Xref: news.gmane.org gmane.emacs.gnus.general:67752 Archived-At: --=-=-= Speaking of Content-Location, I see w3m-region in mm-inline-text-html-render-with-w3m can be passed a url location so relative links and images go to the right place. I wonder if something like below could pass that through from RFC2557 mhtml parts. The decode bit is fairly nasty, because I believe in a multipart it's necessary to propagate the Content-Location down into subparts (if they don't have their own Content-Location). Or at least that's my reading of the rfc and the sample messages at http://people.dsv.su.se/~jpalme/ietf/mhtml-test/mhtml.html On those samples you can see the relative links for the images come out right with w3m-region passed the Content-Location urls. (Looking just with describe-char if you've got image display disabled, as I do, and without worrying, yet, whether w3m can pick out the image contents from the multipart/related parts instead of downloading ...) --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=mm-view.el.content-location.diff --- mm-view.el 04 Nov 2008 10:26:46 +1100 7.59 +++ mm-view.el 04 Nov 2008 10:26:55 +1100 @@ -257,7 +257,8 @@ (insert (mm-decode-string text charset)))) (let ((w3m-safe-url-regexp mm-w3m-safe-url-regexp) w3m-force-redisplay) - (w3m-region (point-min) (point-max) nil charset)) + (w3m-region (point-min) (point-max) + (mm-handle-content-location handle) charset)) (when (and mm-inline-text-html-with-w3m-keymap (boundp 'w3m-minor-mode-map) w3m-minor-mode-map) --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=mm-decode.el.content-location.diff --- mm-decode.el 04 Nov 2008 10:27:16 +1100 7.68 +++ mm-decode.el 04 Nov 2008 10:27:23 +1100 @@ -89,6 +89,8 @@ `(setcar (nthcdr 6 ,handle) ,contents)) (defmacro mm-handle-id (handle) `(nth 7 ,handle)) +(defmacro mm-handle-content-location (handle) + `(nth 8 ,handle)) (defmacro mm-handle-multipart-original-buffer (handle) `(get-text-property 0 'buffer (car ,handle))) (defmacro mm-handle-multipart-from (handle) @@ -98,9 +100,9 @@ (defmacro mm-make-handle (&optional buffer type encoding undisplayer disposition description cache - id) + id content-location) `(list ,buffer ,type ,encoding ,undisplayer - ,disposition ,description ,cache ,id)) + ,disposition ,description ,cache ,id ,content-location)) (defcustom mm-text-html-renderer (cond ((executable-find "w3m") @@ -550,7 +552,7 @@ (message "Destroying external MIME viewers") (mm-destroy-parts mm-postponed-undisplay-list))) -(defun mm-dissect-buffer (&optional no-strict-mime loose-mime from) +(defun mm-dissect-buffer (&optional no-strict-mime loose-mime from content-location) "Dissect the current buffer and return a list of MIME handles." (save-excursion (let (ct ctl type subtype cte cd description id result) @@ -564,7 +566,9 @@ cte (mail-fetch-field "content-transfer-encoding") cd (mail-fetch-field "content-disposition") description (mail-fetch-field "content-description") - id (mail-fetch-field "content-id")) + id (mail-fetch-field "content-id") + content-location (or (mail-fetch-field "content-location") + content-location)) (unless from (setq from (mail-fetch-field "from"))) ;; FIXME: In some circumstances, this code is running within @@ -583,7 +587,7 @@ (and cte (intern (downcase (mail-header-strip cte)))) no-strict-mime (and cd (mail-header-parse-content-disposition cd)) - description) + description content-location) (setq type (split-string (car ctl) "/")) (setq subtype (cadr type) type (car type)) @@ -608,7 +612,7 @@ 'from from 'start start) (car ctl)) - (cons (car ctl) (mm-dissect-multipart ctl from)))) + (cons (car ctl) (mm-dissect-multipart ctl from content-location)))) (t (mm-possibly-verify-or-decrypt (mm-dissect-singlepart @@ -616,7 +620,7 @@ (and cte (intern (downcase (mail-header-strip cte)))) no-strict-mime (and cd (mail-header-parse-content-disposition cd)) - description id) + description id content-location) ctl)))) (when id (when (string-match " *<\\(.*\\)> *" id) @@ -624,15 +628,15 @@ (push (cons id result) mm-content-id-alist)) result)))) -(defun mm-dissect-singlepart (ctl cte &optional force cdl description id) +(defun mm-dissect-singlepart (ctl cte &optional force cdl description id content-location) (when (or force (if (equal "text/plain" (car ctl)) (assoc 'format ctl) t)) (mm-make-handle - (mm-copy-to-buffer) ctl cte nil cdl description nil id))) + (mm-copy-to-buffer) ctl cte nil cdl description nil id content-location))) -(defun mm-dissect-multipart (ctl from) +(defun mm-dissect-multipart (ctl from content-location) (goto-char (point-min)) (let* ((boundary (concat "\n--" (mail-content-type-get ctl 'boundary))) (close-delimiter (concat (regexp-quote boundary) "--[ \t]*$")) @@ -649,7 +653,7 @@ (save-excursion (save-restriction (narrow-to-region start (point)) - (setq parts (nconc (list (mm-dissect-buffer t nil from)) parts))))) + (setq parts (nconc (list (mm-dissect-buffer t nil from content-location)) parts))))) (end-of-line 2) (or (looking-at boundary) (forward-line 1)) @@ -658,7 +662,7 @@ (save-excursion (save-restriction (narrow-to-region start end) - (setq parts (nconc (list (mm-dissect-buffer t nil from)) parts))))) + (setq parts (nconc (list (mm-dissect-buffer t nil from content-location)) parts))))) (mm-possibly-verify-or-decrypt (nreverse parts) ctl))) (defun mm-copy-to-buffer () --=-=-=--