[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bug in metamail

From: Masanobu UMEDA
Subject: Re: Bug in metamail
Date: Mon, 9 Dec 2002 20:54:32 +0900

   From: Richard Stallman <address@hidden>
   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 <address@hidden>
;; 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
;; 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)

(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)
    ;; Copy non-pruned headers and body.
        (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.
    (let ((metamail-switches        ;Suppress header fields in a body.
           (append metamail-switches '("-q"))))
      (metamail-interpret-body viewmode))
    ;;(goto-char (point-min))

(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."
    ;; Convert only when it has Mime-Version header field.
    (if (save-restriction
          (narrow-to-region (point-min)
                              (goto-char (point-min))
                              (search-forward "\n\n" nil t)
          (mail-fetch-field "Mime-Version"))

(provide 'rmailmime)

;;; rmailmime.el ends here

reply via email to

[Prev in Thread] Current Thread [Next in Thread]