From marcooliva@sapo.pt Tue Aug 25 11:37:23 2009 Received: (at submit) by emacsbugs.donarmstrong.com; 25 Aug 2009 18:37:23 +0000 X-Spam-Checker-Version: SpamAssassin 3.2.5-bugs.debian.org_2005_01_02 (2008-06-10) on rzlab.ucr.edu X-Spam-Level: X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. X-Spam-Status: No, score=0.0 required=4.0 tests=none autolearn=ham version=3.2.5-bugs.debian.org_2005_01_02 Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id n7PIbLFu010180 for ; Tue, 25 Aug 2009 11:37:23 -0700 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Mg0tV-0001Aj-9g for bug-gnu-emacs@gnu.org; Tue, 25 Aug 2009 14:37:21 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Mg0tQ-00018o-En for bug-gnu-emacs@gnu.org; Tue, 25 Aug 2009 14:37:20 -0400 Received: from [199.232.76.173] (port=41855 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mg0tQ-00018i-9u for bug-gnu-emacs@gnu.org; Tue, 25 Aug 2009 14:37:16 -0400 Received: from relay1.ptmail.sapo.pt ([212.55.154.21]:41642) by monty-python.gnu.org with smtp (Exim 4.60) (envelope-from ) id 1Mg0tP-000468-OC for bug-gnu-emacs@gnu.org; Tue, 25 Aug 2009 14:37:16 -0400 Received: (qmail 23275 invoked from network); 25 Aug 2009 18:37:12 -0000 Received: from unknown (HELO sapo.pt) (10.134.37.162) by relay1 with SMTP; 25 Aug 2009 18:37:12 -0000 Received: (qmail 1659 invoked from network); 25 Aug 2009 18:37:14 -0000 X-AntiVirus: PTMail-AV 0.3-0.95.1 X-Scan-Status: AV clean (0.00576 seconds); AS clean (0.00034 seconds); Received: from unknown (HELO [95.95.152.234]) (marcooliva@sapo.pt@[95.95.152.234]) (envelope-sender ) by mta12 (qmail-ldap-1.03) with AES256-SHA encrypted SMTP for ; 25 Aug 2009 18:37:14 -0000 From: Marco Oliva To: bug-gnu-emacs@gnu.org Subject: Feature Request - Rmail - Html Date: Tue, 25 Aug 2009 19:36:10 +0100 User-Agent: KMail/1.9.10 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200908251936.10632.marcooliva@sapo.pt> X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.4-2.6 Please, include in rmail, support for html. Thanks in advance. From rgm@gnu.org Tue Aug 25 18:16:28 2009 Received: (at control) by emacsbugs.donarmstrong.com; 26 Aug 2009 01:16:28 +0000 X-Spam-Checker-Version: SpamAssassin 3.2.5-bugs.debian.org_2005_01_02 (2008-06-10) on rzlab.ucr.edu X-Spam-Level: X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. X-Spam-Status: No, score=-3.4 required=4.0 tests=AWL,ONEWORD autolearn=no version=3.2.5-bugs.debian.org_2005_01_02 Received: from fencepost.gnu.org (fencepost.gnu.org [140.186.70.10]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id n7Q1GRmv015364 for ; Tue, 25 Aug 2009 18:16:28 -0700 Received: from rgm by fencepost.gnu.org with local (Exim 4.67) (envelope-from ) id 1Mg77i-0001ZA-B6; Tue, 25 Aug 2009 21:16:26 -0400 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <19092.36074.258388.516156@fencepost.gnu.org> Date: Tue, 25 Aug 2009 21:16:26 -0400 From: Glenn Morris To: control Subject: control close 4208 merge 4240 4037 severity 4258 wishlist severity 4257 minor reassign 4166 spam reassign 4167 spam reassign 4168 spam reassign 4171 spam reassign 4173 spam reassign 4174 spam reassign 4181 spam reassign 4182 spam reassign 4189 spam reassign 4205 spam reassign 4212 spam reassign 4213 spam reassign 4214 spam reassign 4220 spam reassign 4223 spam reassign 4224 spam reassign 4225 spam reassign 4232 spam reassign 4241 spam reassign 4245 spam reassign 4247 spam reassign 4248 spam From debbugs-submit-bounces@debbugs.gnu.org Tue Jan 07 14:12:02 2014 Received: (at 4258) by debbugs.gnu.org; 7 Jan 2014 19:12:02 +0000 Received: from localhost ([127.0.0.1]:41449 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1W0c4D-00081S-VB for submit@debbugs.gnu.org; Tue, 07 Jan 2014 14:12:01 -0500 Received: from fencepost.gnu.org ([208.118.235.10]:38587) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1W0c47-00081C-UC for 4258@debbugs.gnu.org; Tue, 07 Jan 2014 14:11:55 -0500 Received: from rgm by fencepost.gnu.org with local (Exim 4.71) (envelope-from ) id 1W0c47-0006lE-LS for 4258@debbugs.gnu.org; Tue, 07 Jan 2014 14:11:51 -0500 From: Ken Olum To: 4258@debbugs.gnu.org Subject: [patch] HTML mail in rmail In-Reply-To: <87hacl9ypc.fsf@gnu.org> (message from Kenichi Handa on Sun, 13 Oct 2013 20:50:39 +0900) Date: Fri, 27 Dec 2013 15:10:59 -0500 Lines: 315 X-From-Line: emacs-devel-bounces+rgm=gnu.org@gnu.org Fri Dec 27 15:11:37 2013 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39143) by fencepost.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1Vwdkv-0007us-2N for rgm@gnu.org; Fri, 27 Dec 2013 15:11:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vwdkp-0006oA-EO for rgm@gnu.org; Fri, 27 Dec 2013 15:11:36 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=BAYES_50,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:46174) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vwdkp-0006o6-BR for rgm@gnu.org; Fri, 27 Dec 2013 15:11:31 -0500 Received: from localhost ([::1]:50181 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vwdkp-0005wV-9S for rgm@gnu.org; Fri, 27 Dec 2013 15:11:31 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43059) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VwdkU-0005vz-Tu for emacs-devel@gnu.org; Fri, 27 Dec 2013 15:11:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VwdkO-0006hh-Pl for emacs-devel@gnu.org; Fri, 27 Dec 2013 15:11:10 -0500 Received: from cosmos.phy.tufts.edu ([130.64.83.16]:38828) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VwdkO-0006hD-MA for emacs-devel@gnu.org; Fri, 27 Dec 2013 15:11:04 -0500 Received: from kdo by cosmos.phy.tufts.edu ([local]:local) with local id 1VwdkJ-0007gq-9T - Using Exim-4.80.1 (MandrivaLinux) MTA (return-path ); Fri, 27 Dec 2013 15:10:59 -0500 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 Message-ID: User-Agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 4258 X-BeenThere: debbugs-submit@debbugs.gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) --=-=-= Here is some code for handling HTML parts. To show the part it funcalls rmail-mime-render-html-function, which defaults to using shr if libxml is available, or lynx if you have that. Other methods could be written. In the long run it would probably be better to integrate rmail mime handling with gnus mime handling, but that seems like a big job. Even if you use shr, if it does not render images called for by the html part, because asynchronous retrieving of images gets confused by rmail's buffer-swapping. (Personally, I'm using lynx, because I don't want my email to look like a web page. I just want to figure out what the sender had to say.) If the message is only HTML, it just renders it. But if there is an alternative text/plain part, it prefers that and you have to use the "Show" button to get the HTML rendered. It does not render HTML on searching, so searching looks through the actual HTML. Otherwise it would be very slow if you have a large mail file. Here is a bazaar bundle. Ken --=-=-= Content-Disposition: attachment; filename=html-patch.text # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: kdo@cosmos.phy.tufts.edu-20131227194350-\ # g3o5h6bnyg8yntf2 # target_branch: bzr://bzr.savannah.gnu.org/emacs/trunk/ # testament_sha1: dc810978fb73db2f3fdc77450d771642e5e60cfb # timestamp: 2013-12-27 14:44:04 -0500 # source_branch: rmail # base_revision_id: eggert@cs.ucla.edu-20131227191410-z9ibc5kpdv0wj3ub # # Begin patch === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2013-12-27 15:43:54 +0000 +++ lisp/ChangeLog 2013-12-27 19:28:08 +0000 @@ -1,3 +1,19 @@ +2013-12-27 Ken Olum + + * mail/rmail.el (rmail-mime-process): Handle text/html + separately from other text/ types. Suppress tagline for + multipart body. + (rmail-mime-parse): Don't change visibility of tagline here. + (rmail-mime-set-bulk-data, rmail-mime-insert-bulk): + Handle text/html specially. + (rmail-mime-render-html-function): New variable. + (rmail-mime-insert-html, rmail-mime-render-html-shr) + (rmail-mime-render-html-lynx): New functions. + (rmail-mime-fix-inserted-faces): New function. + (rmail-mime-searching): New variable. + (rmail-search-mime-message): Bind rmail-mime-searching to + suppress rendering while searching. + 2013-12-27 Lars Ingebrigtsen * net/shr.el (shr-insert): Don't infloop if the width is zero. === modified file 'lisp/mail/rmail.el' --- lisp/mail/rmail.el 2013-10-30 16:29:36 +0000 +++ lisp/mail/rmail.el 2013-12-27 19:28:08 +0000 @@ -4668,7 +4668,7 @@ ;;;*** -;;;### (autoloads nil "rmailmm" "rmailmm.el" "8c14f4cf6e7dacb0c94fd300d814caf7") +;;;### (autoloads nil "rmailmm" "rmailmm.el" "9ac7864956507a43015757329f12895a") ;;; Generated autoloads from rmailmm.el (autoload 'rmail-mime "rmailmm" "\ === modified file 'lisp/mail/rmailmm.el' --- lisp/mail/rmailmm.el 2013-09-18 03:47:11 +0000 +++ lisp/mail/rmailmm.el 2013-12-27 19:28:08 +0000 @@ -131,6 +131,17 @@ :version "23.2" :group 'rmail-mime) +(defcustom rmail-mime-render-html-function + (cond ((fboundp 'libxml-parse-html-region) 'rmail-mime-render-html-shr) + ((executable-find "lynx") 'rmail-mime-render-html-lynx) + (t nil)) + "Function to convert HTML to text. Called with buffer containing HTML +extracted from message in a temporary buffer. Converts to text in current +buffer. If NIL, display HTML source." + :group 'rmail + :version "24.4" + :type '(choice function (const nil))) + ;;; End of user options. ;;; Global variables that always have let-binding when referred. @@ -150,6 +161,10 @@ The value is usually nil, and bound to non-nil while inserting MIME entities.") +(defvar rmail-mime-searching nil + "Bound to T inside `rmail-search-mime-message' to suppress expensive +operations such as HTML decoding") + ;;; MIME-entity object (defun rmail-mime-entity (type disposition transfer-encoding @@ -636,6 +651,57 @@ (insert-image (create-image data (cdr bulk-data) t)) (insert "\n"))) +(defun rmail-mime-insert-html (entity) + "Decode, render, and insert html from MIME-entity ENTITY." + (let ((body (rmail-mime-entity-body entity)) + (transfer-encoding (rmail-mime-entity-transfer-encoding entity)) + (buffer (current-buffer))) + (with-temp-buffer + (set-buffer-multibyte nil) + (setq buffer-undo-list t) + (insert-buffer-substring rmail-mime-mbox-buffer + (aref body 0) (aref body 1)) + (cond ((string= transfer-encoding "base64") + (ignore-errors (base64-decode-region (point-min) (point-max)))) + ((string= transfer-encoding "quoted-printable") + (quoted-printable-decode-region (point-min) (point-max)))) + ;; Convert html in temporary buffer to text and insert in original buffer + (let ((source-buffer (current-buffer))) + (with-current-buffer buffer + (let ((start (point))) + (if rmail-mime-render-html-function + (funcall rmail-mime-render-html-function source-buffer) + (insert-buffer-substring source-buffer)) + (rmail-mime-fix-inserted-faces start))))))) + +(defun rmail-mime-render-html-shr (source-buffer) + (let ((dom (with-current-buffer source-buffer + (libxml-parse-html-region (point-min) (point-max)))) + ;; Image retrieval happens asynchronously, but meanwhile + ;; `rmail-swap-buffers' may have been run, leaving + ;; `shr-image-fetched' trying to insert the image in the wrong buffer. + (shr-inhibit-images t)) + (shr-insert-document dom))) + +(defun rmail-mime-render-html-lynx (source-buffer) + (let ((destination-buffer (current-buffer))) + (with-current-buffer source-buffer + (call-process-region (point-min) (point-max) + "lynx" nil destination-buffer nil + "-stdin" "-dump" "-force_html" + "-dont_wrap_pre" "-width=70")))) + +;; Put font-lock-face properties matching face properties on text +;; inserted, e.g., by shr, in text from START to point. +(defun rmail-mime-fix-inserted-faces (start) + (while (< start (point)) + (let ((face (get-text-property start 'face)) + (next (next-single-property-change + start 'face (current-buffer) (point)))) + (if face ; anything to do? + (put-text-property start next 'font-lock-face face)) + (setq start next)))) + (defun rmail-mime-toggle-button (button) "Hide or show the body of the MIME-entity associated with BUTTON." (save-excursion @@ -680,6 +746,8 @@ (setq size (/ (* size 7) 3))))))) (cond + ((string-match "text/html" content-type) + (setq type 'html)) ((string-match "text/" content-type) (setq type 'text)) ((string-match "image/\\(.*\\)" content-type) @@ -789,6 +857,12 @@ (if (rmail-mime-display-body new) (cond ((eq (cdr bulk-data) 'text) (rmail-mime-insert-decoded-text entity)) + ((eq (cdr bulk-data) 'html) + ;; Render HTML if display single message, but if searching + ;; don't render but just search HTML itself. + (if rmail-mime-searching + (rmail-mime-insert-decoded-text entity) + (rmail-mime-insert-html entity))) ((cdr bulk-data) (rmail-mime-insert-image entity)) (t @@ -1119,6 +1193,8 @@ (cond ((string-match "multipart/.*" (car content-type)) (save-restriction (narrow-to-region (1- end) (point-max)) + (if (zerop (length parse-tag)) ; top level of message + (aset new 1 (aset tagline 2 nil))) ; don't show tagline (setq children (rmail-mime-process-multipart content-type content-disposition @@ -1139,6 +1215,12 @@ (aset (rmail-mime-entity-tagline msg) 2 nil) (setq children (list msg) handler 'rmail-mime-insert-multipart)))) + ((and is-inline (string-match "text/html" (car content-type))) + ;; Display tagline, so part can be detached + (aset new 1 (aset tagline 2 t)) + (aset new 2 (aset body 2 t)) ; display body also. + (setq handler 'rmail-mime-insert-bulk)) + ;; Inline non-HTML text ((and is-inline (string-match "text/" (car content-type))) ;; Don't need a tagline. (aset new 1 (aset tagline 2 nil)) @@ -1191,10 +1273,6 @@ (new (aref (rmail-mime-entity-display entity) 1))) ;; Show header. (aset new 0 (aset (rmail-mime-entity-header entity) 2 t)) - ;; Show tagline if and only if body is not shown. - (if (aref new 2) - (aset new 1 (aset (rmail-mime-entity-tagline entity) 2 nil)) - (aset new 1 (aset (rmail-mime-entity-tagline entity) 2 t))) entity))) (error (format "%s" err))))) @@ -1395,7 +1473,8 @@ "Function to set in `rmail-search-mime-message-function' (which see)." (save-restriction (narrow-to-region (rmail-msgbeg msg) (rmail-msgend msg)) - (let* ((rmail-mime-mbox-buffer (current-buffer)) + (let* ((rmail-mime-searching t) ; mark inside search + (rmail-mime-mbox-buffer (current-buffer)) (rmail-mime-view-buffer rmail-view-buffer) (header-end (save-excursion (re-search-forward "^$" nil 'move) (point))) # Begin bundle IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWQ0LF3sAC83fgHwwWPf///9v 3CD////wYBO82u7u+87mm3hb3pXt6+noouwGvoroc+q++D7vi7ZzgxIPbC+YAM47lOj5K9db7YSR EaJgjQCZqNNAMp5SNNNN6kAANDQEkgTE000ITEk8JPVHkQAyeoGgAGgBKASDSap6Gpqej1Gj1RtJ p6nqeiMgwgyMBAEmlImkpsnqm2oGifqjah6E8oMPU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scPtkkmD0R5BgetxPiGibGttSa6p99HJv4RywH/i7kinChIBoWLvYA== --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Wed Aug 20 10:19:43 2014 Received: (at 4258) by debbugs.gnu.org; 20 Aug 2014 14:19:43 +0000 Received: from localhost ([127.0.0.1]:48270 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XK6jm-0006M4-J4 for submit@debbugs.gnu.org; Wed, 20 Aug 2014 10:19:43 -0400 Received: from ironport2-out.teksavvy.com ([206.248.154.181]:36426) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XK6jj-0006Lq-U9 for 4258@debbugs.gnu.org; Wed, 20 Aug 2014 10:19:40 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ArYGAIDvNVPAqyKr/2dsb2JhbABZDoJ4O4MPwD2BFxd0giUBAQEBAgFWIwULCw4mEhQYDSSIBAgN0gwXjnoHhDgEmgGRAoJwXCE X-IPAS-Result: ArYGAIDvNVPAqyKr/2dsb2JhbABZDoJ4O4MPwD2BFxd0giUBAQEBAgFWIwULCw4mEhQYDSSIBAgN0gwXjnoHhDgEmgGRAoJwXCE X-IronPort-AV: E=Sophos;i="4.97,753,1389762000"; d="scan'208";a="87271780" Received: from 192-171-34-171.cpe.pppoe.ca (HELO pastel.home) ([192.171.34.171]) by ironport2-out.teksavvy.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 20 Aug 2014 10:19:34 -0400 Received: by pastel.home (Postfix, from userid 20848) id 5472464141; Wed, 20 Aug 2014 10:19:33 -0400 (EDT) From: Stefan Monnier To: Ken Olum Subject: Re: Your Emacs contributions Message-ID: References: Date: Wed, 20 Aug 2014 10:19:33 -0400 In-Reply-To: (Ken Olum's message of "Tue, 19 Aug 2014 11:18:47 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.3 (/) X-Debbugs-Envelope-To: 4258 Cc: 4258@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.3 (/) > The main thing that I've been trying to contribute (besides > miscellaneous small enhancements and bug fixes) is some code for HTML > rendering in rmail. The patch is in > http://debbugs.gnu.org/cgi/bugreport.cgi?bug=4258 already. Oh, right I see it. Hmm... it seems noone has reviewed it. The patch looks fairly good to me, but not knowing much if anything about Rmail's rendering, I'd appreciate some comment from someone a bit more familiar with this code. > I guess in addition to the now completed legal paperwork it is waiting > for the freeze to be lifted. The freeze was lifted several months ago already, Stefan From debbugs-submit-bounces@debbugs.gnu.org Wed Aug 20 10:48:32 2014 Received: (at 4258) by debbugs.gnu.org; 20 Aug 2014 14:48:32 +0000 Received: from localhost ([127.0.0.1]:48278 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XK7Bf-00075V-G0 for submit@debbugs.gnu.org; Wed, 20 Aug 2014 10:48:31 -0400 Received: from mtaout22.012.net.il ([80.179.55.172]:45737) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XK7Ba-00075C-9K for 4258@debbugs.gnu.org; Wed, 20 Aug 2014 10:48:28 -0400 Received: from conversion-daemon.a-mtaout22.012.net.il by a-mtaout22.012.net.il (HyperSendmail v2007.08) id <0NAM00B000ZDYQ00@a-mtaout22.012.net.il> for 4258@debbugs.gnu.org; Wed, 20 Aug 2014 17:48:19 +0300 (IDT) Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout22.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0NAM00B6114IKP70@a-mtaout22.012.net.il>; Wed, 20 Aug 2014 17:48:19 +0300 (IDT) Date: Wed, 20 Aug 2014 17:48:15 +0300 From: Eli Zaretskii Subject: Re: bug#4258: Your Emacs contributions In-reply-to: X-012-Sender: halo1@inter.net.il To: Stefan Monnier Message-id: <8338crcj4g.fsf@gnu.org> References: X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: 4258 Cc: 4258@debbugs.gnu.org, kdo@cosmos.phy.tufts.edu X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Eli Zaretskii List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.0 (+) > From: Stefan Monnier > Date: Wed, 20 Aug 2014 10:19:33 -0400 > Cc: 4258@debbugs.gnu.org > > > The main thing that I've been trying to contribute (besides > > miscellaneous small enhancements and bug fixes) is some code for HTML > > rendering in rmail. The patch is in > > http://debbugs.gnu.org/cgi/bugreport.cgi?bug=4258 already. > > Oh, right I see it. Hmm... it seems noone has reviewed it. I did. > The patch looks fairly good to me, but not knowing much if anything > about Rmail's rendering, I'd appreciate some comment from someone a bit > more familiar with this code. I plan on starting to use it soon, and if it does a good job, I will commit it. Thanks for your contribution, Ken, and sorry for being so slow in installing it. From debbugs-submit-bounces@debbugs.gnu.org Tue Aug 26 14:45:35 2014 Received: (at 4258) by debbugs.gnu.org; 26 Aug 2014 18:45:35 +0000 Received: from localhost ([127.0.0.1]:52740 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XMLkM-0005dR-9u for submit@debbugs.gnu.org; Tue, 26 Aug 2014 14:45:35 -0400 Received: from mtaout27.012.net.il ([80.179.55.183]:34639) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XMLkH-0005d9-Lt for 4258@debbugs.gnu.org; Tue, 26 Aug 2014 14:45:31 -0400 Received: from conversion-daemon.mtaout27.012.net.il by mtaout27.012.net.il (HyperSendmail v2007.08) id <0NAX00L00FE3XZ00@mtaout27.012.net.il> for 4258@debbugs.gnu.org; Tue, 26 Aug 2014 21:40:02 +0300 (IDT) Received: from HOME-C4E4A596F7 ([87.69.4.28]) by mtaout27.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0NAX00G5KFUQKM70@mtaout27.012.net.il>; Tue, 26 Aug 2014 21:40:02 +0300 (IDT) Date: Tue, 26 Aug 2014 21:45:33 +0300 From: Eli Zaretskii Subject: Re: bug#4258: Your Emacs contributions In-reply-to: <8338crcj4g.fsf@gnu.org> X-012-Sender: halo1@inter.net.il To: kdo@cosmos.phy.tufts.edu Message-id: <83wq9vjdiq.fsf@gnu.org> References: <8338crcj4g.fsf@gnu.org> X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: 4258 Cc: 4258@debbugs.gnu.org, monnier@iro.umontreal.ca X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Eli Zaretskii List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.0 (+) > Date: Wed, 20 Aug 2014 17:48:15 +0300 > From: Eli Zaretskii > Cc: 4258@debbugs.gnu.org, kdo@cosmos.phy.tufts.edu > > I plan on starting to use it soon, and if it does a good job, I will > commit it. So far it looks very good, but I do have one question: when a mail has both a text and an HTML form, is there any way to show HTML in preference to text, rather than the other way around? I think HTML should be the default with this patch installed. Thanks. From debbugs-submit-bounces@debbugs.gnu.org Wed Aug 27 10:30:13 2014 Received: (at 4258) by debbugs.gnu.org; 27 Aug 2014 14:30:13 +0000 Received: from localhost ([127.0.0.1]:53720 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XMeEl-0002Pg-EN for submit@debbugs.gnu.org; Wed, 27 Aug 2014 10:30:11 -0400 Received: from cosmos.phy.tufts.edu ([130.64.83.16]:35385) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XMeEi-0002PX-5W for 4258@debbugs.gnu.org; Wed, 27 Aug 2014 10:30:08 -0400 Received: from kdo by cosmos.phy.tufts.edu ([local]:local) with local id 1XMeEg-0003E1-Tz - Using Exim-4.80.1 (MandrivaLinux) MTA (return-path ); Wed, 27 Aug 2014 10:30:06 -0400 From: Ken Olum To: Eli Zaretskii Subject: Re: bug#4258: Your Emacs contributions In-Reply-To: <83wq9vjdiq.fsf@gnu.org> (message from Eli Zaretskii on Tue, 26 Aug 2014 21:45:33 +0300) Date: Wed, 27 Aug 2014 10:30:06 -0400 Message-ID: MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 4258 Cc: 4258@debbugs.gnu.org, monnier@iro.umontreal.ca X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) From: Eli Zaretskii Date: Tue, 26 Aug 2014 21:45:33 +0300 ...when a mail has both a text and an HTML form, is there any way to show HTML in preference to text, rather than the other way around? I think HTML should be the default with this patch installed. Not at the moment, but I agree there should be. Sometimes you get messages with text segments that say "go read the html instead" and even when the text is a converted copy of the HTML it is often inferior to what you could get by rendering it yourself. On the other hand, this seems like it should be a user preference, so how about a switch rmail-mime-prefer-html? Would you like a second patch to add this functionality or a new patch including what I sent before with this enhancement? Ken From debbugs-submit-bounces@debbugs.gnu.org Wed Aug 27 10:58:42 2014 Received: (at 4258) by debbugs.gnu.org; 27 Aug 2014 14:58:42 +0000 Received: from localhost ([127.0.0.1]:53727 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XMegM-00037x-64 for submit@debbugs.gnu.org; Wed, 27 Aug 2014 10:58:42 -0400 Received: from mtaout27.012.net.il ([80.179.55.183]:53787) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XMegH-00037h-2B for 4258@debbugs.gnu.org; Wed, 27 Aug 2014 10:58:38 -0400 Received: from conversion-daemon.mtaout27.012.net.il by mtaout27.012.net.il (HyperSendmail v2007.08) id <0NAY00M00ZY4SX00@mtaout27.012.net.il> for 4258@debbugs.gnu.org; Wed, 27 Aug 2014 17:53:08 +0300 (IDT) Received: from HOME-C4E4A596F7 ([87.69.4.28]) by mtaout27.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0NAZ00N0Q00K4B00@mtaout27.012.net.il>; Wed, 27 Aug 2014 17:53:08 +0300 (IDT) Date: Wed, 27 Aug 2014 17:58:42 +0300 From: Eli Zaretskii Subject: Re: bug#4258: Your Emacs contributions In-reply-to: X-012-Sender: halo1@inter.net.il To: Ken Olum Message-id: <83ppfmj7x9.fsf@gnu.org> References: X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: 4258 Cc: 4258@debbugs.gnu.org, monnier@iro.umontreal.ca X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Eli Zaretskii List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.0 (+) > From: Ken Olum > Cc: monnier@iro.umontreal.ca, 4258@debbugs.gnu.org > Date: Wed, 27 Aug 2014 10:30:06 -0400 > > how about a switch rmail-mime-prefer-html? Fine with me. > Would you like a second patch to add this functionality or a new patch > including what I sent before with this enhancement? Whatever is easier for you, I will cope with either. Thanks. From debbugs-submit-bounces@debbugs.gnu.org Thu Aug 28 11:18:15 2014 Received: (at 4258) by debbugs.gnu.org; 28 Aug 2014 15:18:15 +0000 Received: from localhost ([127.0.0.1]:54549 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XN1So-0000Tv-Sp for submit@debbugs.gnu.org; Thu, 28 Aug 2014 11:18:15 -0400 Received: from mtaout20.012.net.il ([80.179.55.166]:55428) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XN1Sl-0000Tf-Gw for 4258@debbugs.gnu.org; Thu, 28 Aug 2014 11:18:12 -0400 Received: from conversion-daemon.a-mtaout20.012.net.il by a-mtaout20.012.net.il (HyperSendmail v2007.08) id <0NB000700VOHTF00@a-mtaout20.012.net.il> for 4258@debbugs.gnu.org; Thu, 28 Aug 2014 18:18:04 +0300 (IDT) Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout20.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0NB0007KUVU4T810@a-mtaout20.012.net.il>; Thu, 28 Aug 2014 18:18:04 +0300 (IDT) Date: Thu, 28 Aug 2014 18:18:19 +0300 From: Eli Zaretskii Subject: Re: bug#4258: Your Emacs contributions In-reply-to: <83wq9vjdiq.fsf@gnu.org> X-012-Sender: halo1@inter.net.il To: kdo@cosmos.phy.tufts.edu Message-id: <83y4u8iqx0.fsf@gnu.org> References: <8338crcj4g.fsf@gnu.org> <83wq9vjdiq.fsf@gnu.org> X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: 4258 Cc: 4258@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Eli Zaretskii List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.0 (+) > Date: Tue, 26 Aug 2014 21:45:33 +0300 > From: Eli Zaretskii > Cc: 4258@debbugs.gnu.org > > So far it looks very good Here's one problem I found: if the HTML includes non-ASCII characters (in the case I saw, the entire HTML part was quoted-printable encoded), Rmail shows the HTML, but does not decode the non-ASCII text. From debbugs-submit-bounces@debbugs.gnu.org Thu Sep 04 11:52:09 2014 Received: (at 4258) by debbugs.gnu.org; 4 Sep 2014 15:52:09 +0000 Received: from localhost ([127.0.0.1]:58939 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XPZKR-0003Qk-Nu for submit@debbugs.gnu.org; Thu, 04 Sep 2014 11:52:08 -0400 Received: from cosmos.phy.tufts.edu ([130.64.83.16]:36195) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XPZKP-0003Qc-93 for 4258@debbugs.gnu.org; Thu, 04 Sep 2014 11:52:06 -0400 Received: from kdo by cosmos.phy.tufts.edu ([local]:local) with local id 1XPZKO-00008W-VO - Using Exim-4.80.1 (MandrivaLinux) MTA (return-path ); Thu, 04 Sep 2014 11:52:05 -0400 From: Ken Olum To: Eli Zaretskii Subject: Preferring HTML parts In-Reply-To: <83y4u8iqx0.fsf@gnu.org> (message from Eli Zaretskii on Thu, 28 Aug 2014 18:18:19 +0300) Date: Thu, 04 Sep 2014 11:52:04 -0400 Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -4.0 (----) X-Debbugs-Envelope-To: 4258 Cc: 4258@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.0 (----) --=-=-= Content-Type: text/plain Here's a patch with all my HTML rendering code, including preferring to render an html part rather than showing the alternative text part, if the variable rmail-mime-prefer-html is set, which is the default. I don't know too much about non-ASCII characters, so maybe this patch could be installed and someone who knows what they're doing could try to address that issue. Ken --=-=-= Content-Type: text/plain Content-Disposition: attachment; filename=html-patch-new.text *** trunk/lisp/ChangeLog 2014-08-27 13:46:08.509697000 -0400 --- new/lisp/ChangeLog 2014-09-04 11:40:20.490492186 -0400 *************** *** 1,3 **** --- 1,21 ---- + 2013-12-27 Ken Olum + + * mail/rmailmm.el (rmail-mime-process): Handle text/html + separately from other text/ types. Suppress tagline for + multipart body. + (rmail-mime-parse): Don't change visibility of tagline here. + (rmail-mime-set-bulk-data, rmail-mime-insert-bulk): + Handle text/html specially. + (rmail-mime-render-html-function,rmail-mime-prefer-html): New variables. + (rmail-mime-insert-html, rmail-mime-render-html-shr) + (rmail-mime-render-html-lynx): New functions. + (rmail-mime-fix-inserted-faces): New function. + (rmail-mime-process-multipart): Find best part to show + following rmail-mime-prefer-html if set. + (rmail-mime-searching): New variable. + (rmail-search-mime-message): Bind rmail-mime-searching to + suppress rendering while searching. + 2014-08-27 Dmitry Antipov * startup.el (normal-top-level): Now use internal--top-level-message. *** trunk/lisp/mail/rmailmm.el 2014-05-21 12:32:30.125349000 -0400 --- new/lisp/mail/rmailmm.el 2014-08-28 13:52:36.835398492 -0400 *************** *** 131,136 **** --- 131,155 ---- :version "23.2" :group 'rmail-mime) + (defcustom rmail-mime-render-html-function + (cond ((fboundp 'libxml-parse-html-region) 'rmail-mime-render-html-shr) + ((executable-find "lynx") 'rmail-mime-render-html-lynx) + (t nil)) + "Function to convert HTML to text. Called with buffer containing HTML + extracted from message in a temporary buffer. Converts to text in current + buffer. If NIL, display HTML source." + :group 'rmail + :version "24.5" + :type '(choice function (const nil))) + + (defcustom rmail-mime-prefer-html + t + "If non-nil, default to showing HTML part rather than text part + when both are available" + :group 'rmail + :version "24.5" + :type 'boolean) + ;;; End of user options. ;;; Global variables that always have let-binding when referred. *************** *** 150,155 **** --- 169,178 ---- The value is usually nil, and bound to non-nil while inserting MIME entities.") + (defvar rmail-mime-searching nil + "Bound to T inside `rmail-search-mime-message' to suppress expensive + operations such as HTML decoding") + ;;; MIME-entity object (defun rmail-mime-entity (type disposition transfer-encoding *************** *** 631,636 **** --- 654,710 ---- (insert-image (create-image data (cdr bulk-data) t)) (insert "\n"))) + (defun rmail-mime-insert-html (entity) + "Decode, render, and insert html from MIME-entity ENTITY." + (let ((body (rmail-mime-entity-body entity)) + (transfer-encoding (rmail-mime-entity-transfer-encoding entity)) + (buffer (current-buffer))) + (with-temp-buffer + (set-buffer-multibyte nil) + (setq buffer-undo-list t) + (insert-buffer-substring rmail-mime-mbox-buffer + (aref body 0) (aref body 1)) + (cond ((string= transfer-encoding "base64") + (ignore-errors (base64-decode-region (point-min) (point-max)))) + ((string= transfer-encoding "quoted-printable") + (quoted-printable-decode-region (point-min) (point-max)))) + ;; Convert html in temporary buffer to text and insert in original buffer + (let ((source-buffer (current-buffer))) + (with-current-buffer buffer + (let ((start (point))) + (if rmail-mime-render-html-function + (funcall rmail-mime-render-html-function source-buffer) + (insert-buffer-substring source-buffer)) + (rmail-mime-fix-inserted-faces start))))))) + + (defun rmail-mime-render-html-shr (source-buffer) + (let ((dom (with-current-buffer source-buffer + (libxml-parse-html-region (point-min) (point-max)))) + ;; Image retrieval happens asynchronously, but meanwhile + ;; `rmail-swap-buffers' may have been run, leaving + ;; `shr-image-fetched' trying to insert the image in the wrong buffer. + (shr-inhibit-images t)) + (shr-insert-document dom))) + + (defun rmail-mime-render-html-lynx (source-buffer) + (let ((destination-buffer (current-buffer))) + (with-current-buffer source-buffer + (call-process-region (point-min) (point-max) + "lynx" nil destination-buffer nil + "-stdin" "-dump" "-force_html" + "-dont_wrap_pre" "-width=70")))) + + ;; Put font-lock-face properties matching face properties on text + ;; inserted, e.g., by shr, in text from START to point. + (defun rmail-mime-fix-inserted-faces (start) + (while (< start (point)) + (let ((face (get-text-property start 'face)) + (next (next-single-property-change + start 'face (current-buffer) (point)))) + (if face ; anything to do? + (put-text-property start next 'font-lock-face face)) + (setq start next)))) + (defun rmail-mime-toggle-button (button) "Hide or show the body of the MIME-entity associated with BUTTON." (save-excursion *************** *** 675,680 **** --- 749,756 ---- (setq size (/ (* size 7) 3))))))) (cond + ((string-match "text/html" content-type) + (setq type 'html)) ((string-match "text/" content-type) (setq type 'text)) ((string-match "image/\\(.*\\)" content-type) *************** *** 784,789 **** --- 860,871 ---- (if (rmail-mime-display-body new) (cond ((eq (cdr bulk-data) 'text) (rmail-mime-insert-decoded-text entity)) + ((eq (cdr bulk-data) 'html) + ;; Render HTML if display single message, but if searching + ;; don't render but just search HTML itself. + (if rmail-mime-searching + (rmail-mime-insert-decoded-text entity) + (rmail-mime-insert-html entity))) ((cdr bulk-data) (rmail-mime-insert-image entity)) (t *************** *** 918,935 **** (setq entities (nreverse entities)) (if (string-match "alternative" subtype) ;; Find the best entity to show, and hide all the others. ! (let (best second) (dolist (child entities) (if (string= (or (car (rmail-mime-entity-disposition child)) (car content-disposition)) "inline") ! (if (string-match "text/plain" ! (car (rmail-mime-entity-type child))) ! (setq best child) ! (if (string-match "text/.*" ! (car (rmail-mime-entity-type child))) ! (setq second child))))) ! (or best (not second) (setq best second)) (dolist (child entities) (unless (eq best child) (aset (rmail-mime-entity-body child) 2 nil) --- 1000,1027 ---- (setq entities (nreverse entities)) (if (string-match "alternative" subtype) ;; Find the best entity to show, and hide all the others. ! ;; If rmail-mime-prefer-html is set, html is best, then plain. ! ;; If not, plain is best, then html. ! ;; Then comes any other text part. ! ;; If thereto of the same type, earlier entities in the message (later ! ;; in the reverse list) are preferred. ! (let (best best-priority) (dolist (child entities) (if (string= (or (car (rmail-mime-entity-disposition child)) (car content-disposition)) "inline") ! (let ((type (car (rmail-mime-entity-type child)))) ! (if (string-match "text/" type) ! ;; Consider all inline text parts ! (let ((priority ! (cond ((string-match "text/html" type) ! (if rmail-mime-prefer-html 1 2)) ! ((string-match "text/plain" type) ! (if rmail-mime-prefer-html 2 1)) ! (t 3)))) ! (if (or (null best) (<= priority best-priority)) ! (setq best child ! best-priority priority))))))) (dolist (child entities) (unless (eq best child) (aset (rmail-mime-entity-body child) 2 nil) *************** *** 1114,1119 **** --- 1206,1213 ---- (cond ((string-match "multipart/.*" (car content-type)) (save-restriction (narrow-to-region (1- end) (point-max)) + (if (zerop (length parse-tag)) ; top level of message + (aset new 1 (aset tagline 2 nil))) ; don't show tagline (setq children (rmail-mime-process-multipart content-type content-disposition *************** *** 1134,1139 **** --- 1228,1239 ---- (aset (rmail-mime-entity-tagline msg) 2 nil) (setq children (list msg) handler 'rmail-mime-insert-multipart)))) + ((and is-inline (string-match "text/html" (car content-type))) + ;; Display tagline, so part can be detached + (aset new 1 (aset tagline 2 t)) + (aset new 2 (aset body 2 t)) ; display body also. + (setq handler 'rmail-mime-insert-bulk)) + ;; Inline non-HTML text ((and is-inline (string-match "text/" (car content-type))) ;; Don't need a tagline. (aset new 1 (aset tagline 2 nil)) *************** *** 1186,1195 **** (new (aref (rmail-mime-entity-display entity) 1))) ;; Show header. (aset new 0 (aset (rmail-mime-entity-header entity) 2 t)) - ;; Show tagline if and only if body is not shown. - (if (aref new 2) - (aset new 1 (aset (rmail-mime-entity-tagline entity) 2 nil)) - (aset new 1 (aset (rmail-mime-entity-tagline entity) 2 t))) entity))) (error (format "%s" err))))) --- 1286,1291 ---- *************** *** 1390,1396 **** "Function to set in `rmail-search-mime-message-function' (which see)." (save-restriction (narrow-to-region (rmail-msgbeg msg) (rmail-msgend msg)) ! (let* ((rmail-mime-mbox-buffer (current-buffer)) (rmail-mime-view-buffer rmail-view-buffer) (header-end (save-excursion (re-search-forward "^$" nil 'move) (point))) --- 1486,1493 ---- "Function to set in `rmail-search-mime-message-function' (which see)." (save-restriction (narrow-to-region (rmail-msgbeg msg) (rmail-msgend msg)) ! (let* ((rmail-mime-searching t) ; mark inside search ! (rmail-mime-mbox-buffer (current-buffer)) (rmail-mime-view-buffer rmail-view-buffer) (header-end (save-excursion (re-search-forward "^$" nil 'move) (point))) --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Thu Sep 04 12:28:42 2014 Received: (at 4258) by debbugs.gnu.org; 4 Sep 2014 16:28:43 +0000 Received: from localhost ([127.0.0.1]:58965 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XPZtq-0005a7-BJ for submit@debbugs.gnu.org; Thu, 04 Sep 2014 12:28:42 -0400 Received: from relais.videotron.ca ([24.201.245.36]:64042) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XPZtn-0005Zr-QW for 4258@debbugs.gnu.org; Thu, 04 Sep 2014 12:28:40 -0400 MIME-version: 1.0 Content-transfer-encoding: 7BIT Content-type: text/plain; CHARSET=US-ASCII Received: from ceviche.home ([24.201.170.218]) by VL-VM-MR002.ip.videotron.ca (Oracle Communications Messaging Exchange Server 7u4-22.01 64bit (built Apr 21 2011)) with ESMTP id <0NBD00II3XRM5T70@VL-VM-MR002.ip.videotron.ca> for 4258@debbugs.gnu.org; Thu, 04 Sep 2014 12:28:34 -0400 (EDT) Received: by ceviche.home (Postfix, from userid 20848) id 02D06660C4; Thu, 04 Sep 2014 12:28:34 -0400 (EDT) From: Stefan Monnier To: Ken Olum Subject: Re: bug#4258: Preferring HTML parts Message-id: References: <200908251936.10632.marcooliva@sapo.pt> Date: Thu, 04 Sep 2014 12:28:34 -0400 In-reply-to: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux) X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: 4258 Cc: Eli Zaretskii , 4258@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.0 (+) > + (defcustom rmail-mime-prefer-html > + t We should only prefer html if we have a renderer (i.e. if rmail-mime-render-html-function is non-nil). I skipped the rest of the patch since I'm not familiar with Rmail and even less with Rmail's MIME handling. Stefan From debbugs-submit-bounces@debbugs.gnu.org Thu Sep 04 13:59:44 2014 Received: (at 4258) by debbugs.gnu.org; 4 Sep 2014 17:59:44 +0000 Received: from localhost ([127.0.0.1]:58992 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XPbJv-0007qY-QX for submit@debbugs.gnu.org; Thu, 04 Sep 2014 13:59:44 -0400 Received: from cosmos.phy.tufts.edu ([130.64.83.16]:37325) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XPbJt-0007qQ-5l for 4258@debbugs.gnu.org; Thu, 04 Sep 2014 13:59:42 -0400 Received: from kdo by cosmos.phy.tufts.edu ([local]:local) with local id 1XPbJs-0000zb-EV - Using Exim-4.80.1 (MandrivaLinux) MTA (return-path ); Thu, 04 Sep 2014 13:59:40 -0400 From: Ken Olum To: Stefan Monnier Subject: Re: bug#4258: Preferring HTML parts In-Reply-To: (message from Stefan Monnier on Thu, 04 Sep 2014 12:28:34 -0400) Date: Thu, 04 Sep 2014 13:59:40 -0400 Message-ID: MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -4.0 (----) X-Debbugs-Envelope-To: 4258 Cc: eliz@gnu.org, 4258@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.0 (----) Good point. I can't see why anyone would ever want to preferentially display the unrendered html, so I think if rmail-mime-render-html-function is nil we should ignore rmail-mime-prefer-html and always prefer plain text. I'll send a new patch after I see if anyone else has comments. Ken From debbugs-submit-bounces@debbugs.gnu.org Thu Sep 04 16:28:02 2014 Received: (at 4258) by debbugs.gnu.org; 4 Sep 2014 20:28:02 +0000 Received: from localhost ([127.0.0.1]:59057 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XPddS-00038j-2H for submit@debbugs.gnu.org; Thu, 04 Sep 2014 16:28:02 -0400 Received: from relais.videotron.ca ([24.201.245.36]:32829) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XPddQ-00038P-9s for 4258@debbugs.gnu.org; Thu, 04 Sep 2014 16:28:00 -0400 MIME-version: 1.0 Content-transfer-encoding: 7BIT Content-type: text/plain; CHARSET=US-ASCII Received: from ceviche.home ([24.201.170.218]) by VL-VM-MR005.ip.videotron.ca (Oracle Communications Messaging Exchange Server 7u4-22.01 64bit (built Apr 21 2011)) with ESMTP id <0NBE0093F8UH0C80@VL-VM-MR005.ip.videotron.ca> for 4258@debbugs.gnu.org; Thu, 04 Sep 2014 16:27:53 -0400 (EDT) Received: by ceviche.home (Postfix, from userid 20848) id 5CD7E660C4; Thu, 04 Sep 2014 16:27:54 -0400 (EDT) From: Stefan Monnier To: Ken Olum Subject: Re: bug#4258: Preferring HTML parts Message-id: References: Date: Thu, 04 Sep 2014 16:27:54 -0400 In-reply-to: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux) X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: 4258 Cc: eliz@gnu.org, 4258@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.0 (+) > Good point. I can't see why anyone would ever want to preferentially > display the unrendered html, Maybe that's just a lack of imagination. FWIW I used to do just that (and then manually pipe the text through some external html2txt filter). > so I think if rmail-mime-render-html-function is nil we should ignore > rmail-mime-prefer-html and always prefer plain text. I think it's simpler to default to nil if rmail-mime-render-html-function is nil, but still obey rmail-mime-prefer-html if the user set it to t. No need to second guess the user. Stefan From debbugs-submit-bounces@debbugs.gnu.org Sat Sep 06 11:19:57 2014 Received: (at 4258) by debbugs.gnu.org; 6 Sep 2014 15:19:57 +0000 Received: from localhost ([127.0.0.1]:60734 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XQHmP-0005Xf-4B for submit@debbugs.gnu.org; Sat, 06 Sep 2014 11:19:57 -0400 Received: from mtaout23.012.net.il ([80.179.55.175]:63192) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XQHmL-0005XO-Na for 4258@debbugs.gnu.org; Sat, 06 Sep 2014 11:19:55 -0400 Received: from conversion-daemon.a-mtaout23.012.net.il by a-mtaout23.012.net.il (HyperSendmail v2007.08) id <0NBH00J00IX5CL00@a-mtaout23.012.net.il> for 4258@debbugs.gnu.org; Sat, 06 Sep 2014 18:19:47 +0300 (IDT) Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout23.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0NBH00JAKJWY1Y90@a-mtaout23.012.net.il>; Sat, 06 Sep 2014 18:19:47 +0300 (IDT) Date: Sat, 06 Sep 2014 18:19:49 +0300 From: Eli Zaretskii Subject: Re: Preferring HTML parts In-reply-to: X-012-Sender: halo1@inter.net.il To: Ken Olum Message-id: <83mwacdbe2.fsf@gnu.org> References: X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: 4258 Cc: 4258@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Eli Zaretskii List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.0 (+) > From: Ken Olum > Cc: 4258@debbugs.gnu.org > Date: Thu, 04 Sep 2014 11:52:04 -0400 > > Here's a patch with all my HTML rendering code, including preferring to > render an html part rather than showing the alternative text part, if > the variable rmail-mime-prefer-html is set, which is the default. Thanks. I started using it, and so far the results are very good. > I don't know too much about non-ASCII characters, so maybe this patch > could be installed and someone who knows what they're doing could try to > address that issue. I did that as well. So when you send a new patch, I will commit it together with my additions for decoding non-ASCII HTML text. From debbugs-submit-bounces@debbugs.gnu.org Sat Sep 06 20:11:08 2014 Received: (at 4258) by debbugs.gnu.org; 7 Sep 2014 00:11:08 +0000 Received: from localhost ([127.0.0.1]:60806 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XQQ4R-0001eq-7V for submit@debbugs.gnu.org; Sat, 06 Sep 2014 20:11:08 -0400 Received: from cosmos.phy.tufts.edu ([130.64.83.16]:43435) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XQQ4O-0001ed-91 for 4258@debbugs.gnu.org; Sat, 06 Sep 2014 20:11:05 -0400 Received: from kdo by cosmos.phy.tufts.edu ([local]:local) with local id 1XQQ4N-0000s6-RD - Using Exim-4.80.1 (MandrivaLinux) MTA (return-path ); Sat, 06 Sep 2014 20:11:03 -0400 From: Ken Olum To: Eli Zaretskii Subject: Re: Preferring HTML parts In-Reply-To: <83mwacdbe2.fsf@gnu.org> (message from Eli Zaretskii on Sat, 06 Sep 2014 18:19:49 +0300) Date: Sat, 06 Sep 2014 20:11:03 -0400 Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -4.0 (----) X-Debbugs-Envelope-To: 4258 Cc: 4258@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.0 (----) --=-=-= Content-Type: text/plain OK, here is a new version of the patch including the change to only default rmail-mime-prefer-html to t if we have a renderer. Ken --=-=-= Content-Type: text/plain Content-Disposition: attachment; filename=html-patch-new.text *** trunk/lisp/ChangeLog 2014-08-27 13:46:08.509697000 -0400 --- new/lisp/ChangeLog 2014-09-04 11:40:20.490492186 -0400 *************** *** 1,3 **** --- 1,21 ---- + 2013-12-27 Ken Olum + + * mail/rmailmm.el (rmail-mime-process): Handle text/html + separately from other text/ types. Suppress tagline for + multipart body. + (rmail-mime-parse): Don't change visibility of tagline here. + (rmail-mime-set-bulk-data, rmail-mime-insert-bulk): + Handle text/html specially. + (rmail-mime-render-html-function,rmail-mime-prefer-html): New variables. + (rmail-mime-insert-html, rmail-mime-render-html-shr) + (rmail-mime-render-html-lynx): New functions. + (rmail-mime-fix-inserted-faces): New function. + (rmail-mime-process-multipart): Find best part to show + following rmail-mime-prefer-html if set. + (rmail-mime-searching): New variable. + (rmail-search-mime-message): Bind rmail-mime-searching to + suppress rendering while searching. + 2014-08-27 Dmitry Antipov * startup.el (normal-top-level): Now use internal--top-level-message. *** trunk/lisp/mail/rmailmm.el Wed May 21 12:32:30 2014 --- new/lisp/mail/rmailmm.el Fri Sep 5 12:00:31 2014 *************** *** 131,136 **** --- 131,156 ---- :version "23.2" :group 'rmail-mime) + (defcustom rmail-mime-render-html-function + (cond ((fboundp 'libxml-parse-html-region) 'rmail-mime-render-html-shr) + ((executable-find "lynx") 'rmail-mime-render-html-lynx) + (t nil)) + "Function to convert HTML to text. Called with buffer containing HTML + extracted from message in a temporary buffer. Converts to text in current + buffer. If NIL, display HTML source." + :group 'rmail + :version "24.5" + :type '(choice function (const nil))) + + (defcustom rmail-mime-prefer-html + ;; Default to preferring HTML parts, but only if we have a renderer + (if rmail-mime-render-html-function t nil) + "If non-nil, default to showing HTML part rather than text part + when both are available" + :group 'rmail + :version "24.5" + :type 'boolean) + ;;; End of user options. ;;; Global variables that always have let-binding when referred. *************** *** 150,155 **** --- 170,179 ---- The value is usually nil, and bound to non-nil while inserting MIME entities.") + (defvar rmail-mime-searching nil + "Bound to T inside `rmail-search-mime-message' to suppress expensive + operations such as HTML decoding") + ;;; MIME-entity object (defun rmail-mime-entity (type disposition transfer-encoding *************** *** 631,636 **** --- 655,711 ---- (insert-image (create-image data (cdr bulk-data) t)) (insert "\n"))) + (defun rmail-mime-insert-html (entity) + "Decode, render, and insert html from MIME-entity ENTITY." + (let ((body (rmail-mime-entity-body entity)) + (transfer-encoding (rmail-mime-entity-transfer-encoding entity)) + (buffer (current-buffer))) + (with-temp-buffer + (set-buffer-multibyte nil) + (setq buffer-undo-list t) + (insert-buffer-substring rmail-mime-mbox-buffer + (aref body 0) (aref body 1)) + (cond ((string= transfer-encoding "base64") + (ignore-errors (base64-decode-region (point-min) (point-max)))) + ((string= transfer-encoding "quoted-printable") + (quoted-printable-decode-region (point-min) (point-max)))) + ;; Convert html in temporary buffer to text and insert in original buffer + (let ((source-buffer (current-buffer))) + (with-current-buffer buffer + (let ((start (point))) + (if rmail-mime-render-html-function + (funcall rmail-mime-render-html-function source-buffer) + (insert-buffer-substring source-buffer)) + (rmail-mime-fix-inserted-faces start))))))) + + (defun rmail-mime-render-html-shr (source-buffer) + (let ((dom (with-current-buffer source-buffer + (libxml-parse-html-region (point-min) (point-max)))) + ;; Image retrieval happens asynchronously, but meanwhile + ;; `rmail-swap-buffers' may have been run, leaving + ;; `shr-image-fetched' trying to insert the image in the wrong buffer. + (shr-inhibit-images t)) + (shr-insert-document dom))) + + (defun rmail-mime-render-html-lynx (source-buffer) + (let ((destination-buffer (current-buffer))) + (with-current-buffer source-buffer + (call-process-region (point-min) (point-max) + "lynx" nil destination-buffer nil + "-stdin" "-dump" "-force_html" + "-dont_wrap_pre" "-width=70")))) + + ;; Put font-lock-face properties matching face properties on text + ;; inserted, e.g., by shr, in text from START to point. + (defun rmail-mime-fix-inserted-faces (start) + (while (< start (point)) + (let ((face (get-text-property start 'face)) + (next (next-single-property-change + start 'face (current-buffer) (point)))) + (if face ; anything to do? + (put-text-property start next 'font-lock-face face)) + (setq start next)))) + (defun rmail-mime-toggle-button (button) "Hide or show the body of the MIME-entity associated with BUTTON." (save-excursion *************** *** 675,680 **** --- 750,757 ---- (setq size (/ (* size 7) 3))))))) (cond + ((string-match "text/html" content-type) + (setq type 'html)) ((string-match "text/" content-type) (setq type 'text)) ((string-match "image/\\(.*\\)" content-type) *************** *** 784,789 **** --- 861,872 ---- (if (rmail-mime-display-body new) (cond ((eq (cdr bulk-data) 'text) (rmail-mime-insert-decoded-text entity)) + ((eq (cdr bulk-data) 'html) + ;; Render HTML if display single message, but if searching + ;; don't render but just search HTML itself. + (if rmail-mime-searching + (rmail-mime-insert-decoded-text entity) + (rmail-mime-insert-html entity))) ((cdr bulk-data) (rmail-mime-insert-image entity)) (t *************** *** 918,935 **** (setq entities (nreverse entities)) (if (string-match "alternative" subtype) ;; Find the best entity to show, and hide all the others. ! (let (best second) (dolist (child entities) (if (string= (or (car (rmail-mime-entity-disposition child)) (car content-disposition)) "inline") ! (if (string-match "text/plain" ! (car (rmail-mime-entity-type child))) ! (setq best child) ! (if (string-match "text/.*" ! (car (rmail-mime-entity-type child))) ! (setq second child))))) ! (or best (not second) (setq best second)) (dolist (child entities) (unless (eq best child) (aset (rmail-mime-entity-body child) 2 nil) --- 1001,1028 ---- (setq entities (nreverse entities)) (if (string-match "alternative" subtype) ;; Find the best entity to show, and hide all the others. ! ;; If rmail-mime-prefer-html is set, html is best, then plain. ! ;; If not, plain is best, then html. ! ;; Then comes any other text part. ! ;; If thereto of the same type, earlier entities in the message (later ! ;; in the reverse list) are preferred. ! (let (best best-priority) (dolist (child entities) (if (string= (or (car (rmail-mime-entity-disposition child)) (car content-disposition)) "inline") ! (let ((type (car (rmail-mime-entity-type child)))) ! (if (string-match "text/" type) ! ;; Consider all inline text parts ! (let ((priority ! (cond ((string-match "text/html" type) ! (if rmail-mime-prefer-html 1 2)) ! ((string-match "text/plain" type) ! (if rmail-mime-prefer-html 2 1)) ! (t 3)))) ! (if (or (null best) (<= priority best-priority)) ! (setq best child ! best-priority priority))))))) (dolist (child entities) (unless (eq best child) (aset (rmail-mime-entity-body child) 2 nil) *************** *** 1114,1119 **** --- 1207,1214 ---- (cond ((string-match "multipart/.*" (car content-type)) (save-restriction (narrow-to-region (1- end) (point-max)) + (if (zerop (length parse-tag)) ; top level of message + (aset new 1 (aset tagline 2 nil))) ; don't show tagline (setq children (rmail-mime-process-multipart content-type content-disposition *************** *** 1134,1139 **** --- 1229,1240 ---- (aset (rmail-mime-entity-tagline msg) 2 nil) (setq children (list msg) handler 'rmail-mime-insert-multipart)))) + ((and is-inline (string-match "text/html" (car content-type))) + ;; Display tagline, so part can be detached + (aset new 1 (aset tagline 2 t)) + (aset new 2 (aset body 2 t)) ; display body also. + (setq handler 'rmail-mime-insert-bulk)) + ;; Inline non-HTML text ((and is-inline (string-match "text/" (car content-type))) ;; Don't need a tagline. (aset new 1 (aset tagline 2 nil)) *************** *** 1186,1195 **** (new (aref (rmail-mime-entity-display entity) 1))) ;; Show header. (aset new 0 (aset (rmail-mime-entity-header entity) 2 t)) - ;; Show tagline if and only if body is not shown. - (if (aref new 2) - (aset new 1 (aset (rmail-mime-entity-tagline entity) 2 nil)) - (aset new 1 (aset (rmail-mime-entity-tagline entity) 2 t))) entity))) (error (format "%s" err))))) --- 1287,1292 ---- *************** *** 1390,1396 **** "Function to set in `rmail-search-mime-message-function' (which see)." (save-restriction (narrow-to-region (rmail-msgbeg msg) (rmail-msgend msg)) ! (let* ((rmail-mime-mbox-buffer (current-buffer)) (rmail-mime-view-buffer rmail-view-buffer) (header-end (save-excursion (re-search-forward "^$" nil 'move) (point))) --- 1487,1494 ---- "Function to set in `rmail-search-mime-message-function' (which see)." (save-restriction (narrow-to-region (rmail-msgbeg msg) (rmail-msgend msg)) ! (let* ((rmail-mime-searching t) ; mark inside search ! (rmail-mime-mbox-buffer (current-buffer)) (rmail-mime-view-buffer rmail-view-buffer) (header-end (save-excursion (re-search-forward "^$" nil 'move) (point))) --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sat Sep 13 05:29:46 2014 Received: (at 4258-done) by debbugs.gnu.org; 13 Sep 2014 09:29:46 +0000 Received: from localhost ([127.0.0.1]:39900 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XSjeL-00049b-OD for submit@debbugs.gnu.org; Sat, 13 Sep 2014 05:29:46 -0400 Received: from mtaout22.012.net.il ([80.179.55.172]:51217) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XSjeH-00049Q-RV for 4258-done@debbugs.gnu.org; Sat, 13 Sep 2014 05:29:43 -0400 Received: from conversion-daemon.a-mtaout22.012.net.il by a-mtaout22.012.net.il (HyperSendmail v2007.08) id <0NBU00G001PJ0P00@a-mtaout22.012.net.il> for 4258-done@debbugs.gnu.org; Sat, 13 Sep 2014 12:29:40 +0300 (IDT) Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout22.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0NBU00F1S2DFMB80@a-mtaout22.012.net.il>; Sat, 13 Sep 2014 12:29:40 +0300 (IDT) Date: Sat, 13 Sep 2014 12:29:29 +0300 From: Eli Zaretskii Subject: Re: Preferring HTML parts In-reply-to: X-012-Sender: halo1@inter.net.il To: Ken Olum Message-id: <831trf7ts6.fsf@gnu.org> References: X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: 4258-done Cc: 4258-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Eli Zaretskii List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.0 (+) > From: Ken Olum > Cc: 4258@debbugs.gnu.org > Date: Sat, 06 Sep 2014 20:11:03 -0400 > > OK, here is a new version of the patch including the change to only > default rmail-mime-prefer-html to t if we have a renderer. Thanks. Installed as trunk revision 117871. I followed up with 2 additional commits: one to decode the HTML using the transfer-encoding specified by the mail message, and another to bind shr-width to nil during HTML rendering, so that the rendered lines are not broken too early (which screws up display of many HTML messages, e.g., the parts that cite messages being replied to). Thank you for all your hard work. I'm now closing this bug. From debbugs-submit-bounces@debbugs.gnu.org Sat Sep 13 12:45:04 2014 Received: (at 4258) by debbugs.gnu.org; 13 Sep 2014 16:45:04 +0000 Received: from localhost ([127.0.0.1]:40353 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XSqRb-0007d4-Mr for submit@debbugs.gnu.org; Sat, 13 Sep 2014 12:45:04 -0400 Received: from fencepost.gnu.org ([208.118.235.10]:43846) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XSqRY-0007cc-Om for 4258@debbugs.gnu.org; Sat, 13 Sep 2014 12:45:01 -0400 Received: from rgm by fencepost.gnu.org with local (Exim 4.71) (envelope-from ) id 1XSqRX-0007Js-7w; Sat, 13 Sep 2014 12:44:59 -0400 From: Glenn Morris To: 4258@debbugs.gnu.org Subject: Re: bug#4258: Preferring HTML parts References: <831trf7ts6.fsf@gnu.org> X-Spook: MD5 Fortezza weapons of mass destruction Chobetsu Rubin X-Ran: I!s7X2' (Eli Zaretskii's message of "Sat, 13 Sep 2014 12:29:29 +0300") Message-ID: <2uvbormpv8.fsf@fencepost.gnu.org> User-Agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Score: -7.5 (-------) X-Debbugs-Envelope-To: 4258 Cc: eliz@gnu.org, marcooliva@sapo.pt X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -7.5 (-------) Worth a mention in NEWS? From debbugs-submit-bounces@debbugs.gnu.org Sat Sep 13 15:03:33 2014 Received: (at 4258) by debbugs.gnu.org; 13 Sep 2014 19:03:33 +0000 Received: from localhost ([127.0.0.1]:40422 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XSsbc-0003sq-1j for submit@debbugs.gnu.org; Sat, 13 Sep 2014 15:03:32 -0400 Received: from mtaout27.012.net.il ([80.179.55.183]:34174) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XSsbW-0003se-Dw for 4258@debbugs.gnu.org; Sat, 13 Sep 2014 15:03:30 -0400 Received: from conversion-daemon.mtaout27.012.net.il by mtaout27.012.net.il (HyperSendmail v2007.08) id <0NBU00G00SGEHB00@mtaout27.012.net.il> for 4258@debbugs.gnu.org; Sat, 13 Sep 2014 21:57:43 +0300 (IDT) Received: from HOME-C4E4A596F7 ([87.69.4.28]) by mtaout27.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0NBU00872SO7GB80@mtaout27.012.net.il>; Sat, 13 Sep 2014 21:57:43 +0300 (IDT) Date: Sat, 13 Sep 2014 22:03:14 +0300 From: Eli Zaretskii Subject: Re: bug#4258: Preferring HTML parts In-reply-to: <2uvbormpv8.fsf@fencepost.gnu.org> X-012-Sender: halo1@inter.net.il To: Glenn Morris Message-id: <83sijv5onh.fsf@gnu.org> References: <831trf7ts6.fsf@gnu.org> <2uvbormpv8.fsf@fencepost.gnu.org> X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: 4258 Cc: marcooliva@sapo.pt, 4258@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Eli Zaretskii List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.0 (+) > From: Glenn Morris > Cc: eliz@gnu.org, marcooliva@sapo.pt > Date: Sat, 13 Sep 2014 12:44:59 -0400 > > > Worth a mention in NEWS? Definitely; done. Thanks. From unknown Sun Sep 07 18:03:26 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sun, 12 Oct 2014 11:24:04 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator