🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.emacs.sources
Article #354

Improved Emacs MIME tools: rmailmime.el

#354
From: Masanobu UMEDA
Date: Sat, 21 Aug 1993 12:12
116 lines
4815 bytes
;;; rmailmime.el --- Rmail: MIME message reading.

;; Copyright (C) 1993 Masanobu UMEDA

;; Author: Masanobu UMEDA <umerin@mse.kyutech.ac.jp>
;; Version: $Header: rmailmime.el,v 1.9 93/08/21 19:41:40 umerin Locked $
;; 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:

;; LCD Archive Entry:
;; rmailmime|Masanobu UMEDA|umerin@mse.kyutech.ac.jp|
;; Rmail: MIME message support.|
;; $Date: 93/08/21 19:41:40 $|$Revision: 1.9 $|~/misc/rmailmime.el.Z|

;; 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)
;;
;; The function rmail-convert-mime-header works in VM, too.
;;
;; 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)
;;           ))))
;;
;; In VM, the following definitions may be requried:
;; 
;; (setq vm-preview-lines nil)
;; (setq vm-invisible-header-regexp nil)
;; (setq vm-visible-headers
;;       (append vm-visible-headers
;;               '("Mime-Version:"
;;                 "Content-Type:"
;;                 "Content-Transfer-Encoding:")))

;;; Code:

(require 'metamail)

;;;###autoload
(defun rmail-show-mime (&optional do-header)
  "Show a MIME message in current buffer using a View mode.
If an optional argument DO-HEADER is non-nil, interpret a header part,
too.  Otherwise, a body part is only interpreted.
The contents of current buffer are not changed at all."
  (interactive "P")
  (let ((curbuf (current-buffer)))
    (set-buffer (get-buffer-create "*metamail*"))
    (setq buffer-read-only nil)
    (erase-buffer)
    (insert-buffer curbuf)
    (view-buffer (current-buffer))
    (if do-header
	(metamail-interpret-header))
    (let ((metamail-switches		;Suppress header fields in a body.
	   (append metamail-switches '("-q"))))
      (metamail-interpret-body))
    ;;(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.  Original
header is preserved in Rmail."
  (interactive)
  (save-excursion
    ;; Convert only when it has a 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
--
Masanobu UMEDA
umerin@mse.kyutech.ac.jp
Faculty of Computer Science and System Engineering
Kyushu Institute of Technology
Technical Details
Message-ID: <UMERIN.93Aug21211205@orchid.mse.kyutech.ac.jp>
Path: arc1-ca.pugleaf.net!gmd.de!Germany.EU.net!mcsun!uunet!ccut!news.u-tokyo.ac.jp!wnoc-tyo-news!sh.wide!wnoc-kyo!kyu-cs!wnoc-fukuoka-news!shiwasu!shiwasu!umerin
References: <UMERIN.93Aug21210519@orchid.mse.kyutech.ac.jp>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 107729,de723f7325371838
X-Google-Attributes: gid107729,public
X-Google-Thread: 10160c,df93f28e9dfaa4a5,start
X-Google-Attributes: gid10160c,public
X-Google-ArrivalTime: 1993-08-21 05:52:37 PST
Newsgroups: gnu.emacs.sources,fj.sources
Path: arc1-ca.pugleaf.net!gmd.de!Germany.EU.net!mcsun!uunet!ccut!news.u-tokyo.ac.jp!wnoc-tyo-news!sh.wide!wnoc-kyo!kyu-cs!wnoc-fukuoka-news!shiwasu!shiwasu!umerin
From: umerin@mse.kyutech.ac.jp (Masanobu UMEDA)
Subject: Improved Emacs MIME tools: rmailmime.el
References: <UMERIN.93Aug21210519@orchid.mse.kyutech.ac.jp>
Sender: news@shiwasu.isci.kyutech.ac.jp
Organization: Department of Mechanical System Engineering, Kyutech, Japan
Date: Sat, 21 Aug 1993 12:12:05 GMT
Message-ID: <UMERIN.93Aug21211205@orchid.mse.kyutech.ac.jp>
Reply-To: umerin@mse.kyutech.ac.jp
Lines: 116