From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Masanobu UMEDA Newsgroups: gmane.emacs.devel Subject: Re: Bug in metamail Date: Mon, 9 Dec 2002 20:54:32 +0900 Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <200212091154.UAA08391@latour.mse.kyutech.ac.jp> References: <200210101501.AAA01028@latour.mse.kyutech.ac.jp> Reply-To: umerin@mse.kyutech.ac.jp NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-2022-JP-2 X-Trace: main.gmane.org 1039459727 4374 80.91.224.249 (9 Dec 2002 18:48:47 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Mon, 9 Dec 2002 18:48:47 +0000 (UTC) Cc: akopps@Math.Berkeley.EDU Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 18LSxQ-00018O-00 for ; Mon, 09 Dec 2002 19:48:44 +0100 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.12 #1 (Debian)) id 18LT7c-0007CP-01 for ; Mon, 09 Dec 2002 19:59:16 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 18LS2J-0007Wc-04 for emacs-devel@quimby.gnus.org; Mon, 09 Dec 2002 12:49:43 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10.13) id 18LS1x-0007Vu-00 for emacs-devel@gnu.org; Mon, 09 Dec 2002 12:49:21 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10.13) id 18LS1s-0007UA-00 for emacs-devel@gnu.org; Mon, 09 Dec 2002 12:49:20 -0500 Original-Received: from gnudist.gnu.org ([199.232.41.7]) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 18LRSr-0000sI-00; Mon, 09 Dec 2002 12:13:05 -0500 Original-Received: from latour.mse.kyutech.ac.jp ([131.206.67.77]) by gnudist.gnu.org with esmtp (Exim 4.10.13) id 18LMVq-0001nF-00; Mon, 09 Dec 2002 06:55:50 -0500 Original-Received: (from umerin@localhost) by latour.mse.kyutech.ac.jp (8.9.3+3.2W/3.7W) id UAA08391; Mon, 9 Dec 2002 20:54:32 +0900 Original-To: rms@gnu.org In-reply-to: (message from Richard Stallman on Fri, 11 Oct 2002 19:46:05 -0400) Original-cc: emacs-devel@gnu.org X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Emacs development discussions. List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:10006 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:10006 From: Richard Stallman Date: Fri, 11 Oct 2002 19:46:05 -0400 This is because rmail-ignored-headers includes MIME related headers, such as "Content-Type:". Simple user level solution is to put the following code in .emacs. It is much better to remove these headers from rmail-ignored-headers in the next release of emacs distribution. Hiding these headers is useful. Most users don't use metamail, and it would be a shame to give up the useful feature for them. I think the right fix is that metamail should temporarily unhide the headers. This is not terribly hard to do--see rmail-redecode-body for an example: Unfortunately, metamail.el was not only designed for rmail, but also for other MUAs. It is not good idea to add such rmail-specific logics to metamail.el. But instead, I would like you to add the following two functions which act as interfaces to metamail.el for rmail. If you think metamail.el is now existing only for rmail, your proposals could be a solution. Masanobu UMEDA ---------------------------------------------------------------------- ;;; rmailmime.el --- Rmail: MIME message reading. ;; Copyright (C) 1993-1995, 2002 Masanobu UMEDA ;; Author: Masanobu UMEDA ;; Version: $Header: /a/khaki/usrs/usr2/home/umerin/src/emacs/RCS/rmailmime.el,v 1.13 2002/12/09 11:49:25 umerin Exp $ ;; Keywords: mail, mime ;; This file is not part of GNU Emacs. ;; GNU Emacs is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation; either version 2, or (at your option) ;; any later version. ;; GNU Emacs is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs; see the file COPYING. If not, write to ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. ;;; Commentary: ;; Usage examples: ;; First of all, define the following autoload entries: ;; ;; (autoload 'rmail-show-mime "rmailmime" "Show MIME messages." t) ;; (autoload 'rmail-convert-mime-header "rmailmime" "Convert MIME header." nil) ;; ;; To convert MIME headers into readable form automatically in Rmail, ;; set the variable rmail-message-filter to the function ;; rmail-convert-mime-header as follows: ;; ;; (setq rmail-message-filter 'rmail-convert-mime-header) ;; ;; To show MIME messages using metamail program in Rmail, bind the ;; command rmail-show-mime to some key in rmail mode. The following ;; example binds it to the key `!': ;; ;; (setq rmail-mode-hook ;; (list ;; (function ;; (lambda () ;; (local-set-key "!" 'rmail-show-mime) ;; )))) ;;; Code: (require 'metamail) ;;;###autoload (defun rmail-show-mime (&optional viewmode) "Show a MIME message in current buffer using a View mode. Optional 1st argument VIEWMODE specifies the value of the EMACS_VIEW_MODE environment variable (defaulted to 1). The contents of current buffer are not changed at all." (interactive "p") (let ((curbuf (current-buffer)) (tmpbuf (get-buffer-create "*metamail*"))) ;; Reset a working buffer. (set-buffer tmpbuf) (setq buffer-read-only nil) (erase-buffer) ;; Copy non-pruned headers and body. (save-excursion (save-restriction (set-buffer curbuf) (let ((msgbeg (rmail-msgbeg rmail-current-message)) (msgend (rmail-msgend rmail-current-message))) (narrow-to-region msgbeg msgend) (goto-char (point-min)) (forward-line 2) (setq msgbeg (point)) (search-forward "\n\n" msgend t) (copy-to-buffer tmpbuf msgbeg (point)) (set-buffer tmpbuf) (goto-char (point-max)) (set-buffer curbuf) ;; Skip pruned headers. (if (search-forward "*** EOOH ***\n") (search-forward "\n\n" msgend t)) ;; Append a body. (prepend-to-buffer tmpbuf (point) msgend)) )) (view-buffer (current-buffer)) ;; We have to process a header part because it has not been ;; processed at all. (metamail-interpret-header) (let ((metamail-switches ;Suppress header fields in a body. (append metamail-switches '("-q")))) (metamail-interpret-body viewmode)) ;;(goto-char (point-min)) )) ;;;###autoload (defun rmail-convert-mime-header () "Convert MIME header fields of current message into a readable form. It is expected to be used as rmail-message-filter in Rmail and vm-message-filter in VM. Original header is preserved in Rmail." (interactive) (save-excursion ;; Convert only when it has Mime-Version header field. (if (save-restriction (narrow-to-region (point-min) (progn (goto-char (point-min)) (search-forward "\n\n" nil t) (point))) (mail-fetch-field "Mime-Version")) (metamail-interpret-header)))) (provide 'rmailmime) ;;; rmailmime.el ends here