unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Bug in metamail
@ 2002-10-10  8:43 Richard Stallman
  2002-10-10 15:01 ` Masanobu UMEDA
  0 siblings, 1 reply; 4+ messages in thread
From: Richard Stallman @ 2002-10-10  8:43 UTC (permalink / raw)
  Cc: akopps, emacs-devel

Would you please fix this bug in metamail.el in the latest Emacs?
(Are you still maintaining it?)


Envelope-to: rms@gnu.org
Delivery-date: Mon, 07 Oct 2002 22:27:11 -0400
From: Akop Pogosian <akopps@Math.Berkeley.EDU>
To: bug-gnu-emacs@gnu.org
Subject: metamail commands don't work
Sender: bug-gnu-emacs-admin@gnu.org
Date: Mon, 7 Oct 2002 19:26:10 -0700 (PDT)

This bug report will be sent to the Free Software Foundation,
not to your local site managers!
Please write in English, because the Emacs maintainers do not have
translators to read other languages for them.

Your bug report will be posted to the bug-gnu-emacs@gnu.org mailing list,
and to the gnu.emacs.bug news group.

In GNU Emacs 21.2.1 (sparc-sun-solaris2.6, X toolkit)
 of 2002-03-27 on gold
configured using `configure  --prefix=/local/sol/2.6/depot/emacs-21.2'
Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: nil
  locale-coding-system: nil
  default-enable-multibyte-characters: t

Please describe exactly what actions triggered the bug
and the precise symptoms of the bug:

In the older versions of emacs, if you run M-x metamail-interpret-body,
the metamail program would be run to inspect the message body and
perform the appropriate actions according to how the mailcap file setup
(e.g. usually extract and attachment and launch some program to view it).
Starting with emacs 21.x this command stopped working. When I run M-x
metamail-interpret-body, or M-x metamail-buffer, I simply see the
message text scrolling before me and nothing else happens. If I save a
message in a separate file and run metamail on it, it works as
expected, so it is possible that emacs is doing something odd. I
replaced the metamail program with a shell script that saves the file
that's passed to it with arguments somewhere so that emacs doesn't
delete it when metamail returns. I looked at that file and I noticed
that the header "Content-Type: MULTIPART/MIXED;" is missing in it. For
some reason emacs removes it before running metamail. I am getting
this when I run M-x metamail-buffer or M-x metamail-interpret-body.
The absence of this header seems to confuse metamail. I simply see
text scrolling and nothing else happening if I run metamail on that
file from command line. Is this an emacs bug or is there something
that I am doing wrong?


Recent input:
<escape> x m e t a <backspace> <backspace> <backspace> 
<backspace> <help-echo> r e p o r t - e m a c s - b 
u g <return>

Recent messages:
(emacs)
Loading tool-bar...done
Loading image...done
Loading tooltip...done
For information about the GNU Project and its goals, type C-h C-p.
Loading emacsbug...done


_______________________________________________
Bug-gnu-emacs mailing list
Bug-gnu-emacs@gnu.org
http://mail.gnu.org/mailman/listinfo/bug-gnu-emacs

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Bug in metamail
  2002-10-10  8:43 Bug in metamail Richard Stallman
@ 2002-10-10 15:01 ` Masanobu UMEDA
  2002-10-11 23:46   ` Richard Stallman
  0 siblings, 1 reply; 4+ messages in thread
From: Masanobu UMEDA @ 2002-10-10 15:01 UTC (permalink / raw)
  Cc: akopps, emacs-devel

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=ISO-2022-JP-2, Size: 1108 bytes --]

   From: Richard Stallman <rms@gnu.org>
   Reply-To: rms@gnu.org
   Date: Thu, 10 Oct 2002 04:43:06 -0400

   Would you please fix this bug in metamail.el in the latest Emacs?
   (Are you still maintaining it?)

  >> I looked at that file and I noticed
  >> that the header "Content-Type: MULTIPART/MIXED;" is missing in it. For
  >> some reason emacs removes it before running metamail. 

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.

;; Leave MIME related headers.
(let ((headers '("\\|^mime-version:"
		 "\\|^content-transfer-encoding:"
		 "\\|^content-type:"))
      (case-fold-search t))
  (while headers
    (if (string-match (regexp-quote (car headers)) rmail-ignored-headers)
	(setq rmail-ignored-headers
	      (concat (substring rmail-ignored-headers 0 (match-beginning 0))
		      (substring rmail-ignored-headers (match-end 0)))))
    (setq headers (cdr headers))))

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Bug in metamail
  2002-10-10 15:01 ` Masanobu UMEDA
@ 2002-10-11 23:46   ` Richard Stallman
  2002-12-09 11:54     ` Masanobu UMEDA
  0 siblings, 1 reply; 4+ messages in thread
From: Richard Stallman @ 2002-10-11 23:46 UTC (permalink / raw)
  Cc: akopps, emacs-devel

    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:

      (let ((pruned (rmail-msg-is-pruned)))
	(unwind-protect
	    (let ((msgbeg (rmail-msgbeg rmail-current-message))
		  (msgend (rmail-msgend rmail-current-message)))
	      ;; Un-prune the message if it is pruned.
	      (if pruned
		  (rmail-toggle-header 1))
	      (narrow-to-region msgbeg msgend)
	      (goto-char (point-min))
	      (when (search-forward "\n*** EOOH ***\n" (point-max) t)
		(narrow-to-region msgbeg (point)))
	      (goto-char (point-min))
	      ... your code here ...
	      )
	  (if pruned
	      (rmail-toggle-header 0))))

Could you try using this approach?

Another approach is to search both the pruned and original
headers.  That would not require changing the buffer,
not even temporarily, so it would be advantageous.
It should not be terribly heard, even.
But you'd have to write that code.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Bug in metamail
  2002-10-11 23:46   ` Richard Stallman
@ 2002-12-09 11:54     ` Masanobu UMEDA
  0 siblings, 0 replies; 4+ messages in thread
From: Masanobu UMEDA @ 2002-12-09 11:54 UTC (permalink / raw)
  Cc: akopps

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=ISO-2022-JP-2, Size: 5112 bytes --]

   From: Richard Stallman <rms@gnu.org>
   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 <umerin@mse.kyutech.ac.jp>
;; 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2002-12-09 11:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-10  8:43 Bug in metamail Richard Stallman
2002-10-10 15:01 ` Masanobu UMEDA
2002-10-11 23:46   ` Richard Stallman
2002-12-09 11:54     ` Masanobu UMEDA

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).