home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 2: Applications / Linux Cubed Series 2 - Applications.iso / editors / emacs / xemacs / xemacs-1.004 / xemacs-1 / xemacs-19.13 / lisp / packages / metamail.el < prev    next >
Encoding:
Text File  |  1995-03-25  |  4.2 KB  |  122 lines

  1. ;;; metamail.el --- Metamail interface for GNU Emacs
  2. ;; Keywords: mail, news, mime, multimedia
  3.  
  4. ;; Copyright (C) 1993 Masanobu UMEDA
  5.  
  6. ;; Author: Masanobu UMEDA <umerin@mse.kyutech.ac.jp>
  7. ;; Version: Header: /cadillac-inferno-5/cvs-master/lemacs/lisp/packages/metamail.el,v 1.1 1993/12/01 08:54:51 jwz Exp 
  8. ;; Keywords: mail, news, mime, multimedia
  9.  
  10. ;; This file is part of XEmacs.
  11.  
  12. ;; XEmacs is free software; you can redistribute it and/or modify it
  13. ;; under the terms of the GNU General Public License as published by
  14. ;; the Free Software Foundation; either version 2, or (at your option)
  15. ;; any later version.
  16.  
  17. ;; XEmacs is distributed in the hope that it will be useful, but
  18. ;; WITHOUT ANY WARRANTY; without even the implied warranty of
  19. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  20. ;; General Public License for more details.
  21.  
  22. ;; You should have received a copy of the GNU General Public License
  23. ;; along with XEmacs; see the file COPYING.  If not, write to the Free
  24. ;; Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  25.  
  26. ;;; Commentary:
  27.  
  28. ;; LCD Archive Entry:
  29. ;; metamail|Masanobu UMEDA|umerin@mse.kyutech.ac.jp|
  30. ;; Metamail interface for GNU Emacs|
  31. ;; !Date: 1993/12/01 08:54:51 !|!Revision: 1.1 !|~/misc/metamail.el.Z|
  32.  
  33. ;; Note: Metamail does not have all options which is compatible with
  34. ;; the environment variables.  For that reason, matamail.el have to
  35. ;; hack the environment variables.  In addition, there is no way to
  36. ;; display all header fields without extra informative body messages
  37. ;; which is suppressed by "-q" option.
  38.  
  39. ;; The idea of using metamail to process MIME messages is from
  40. ;; gnus-mime.el by Spike <Spike@world.std.com>.
  41.  
  42. ;;; Code:
  43.  
  44. (defvar metamail-program-name "metamail"
  45.   "*Metamail program name.")
  46.  
  47. (defvar metamail-environment "KEYHEADS='*';export KEYHEADS;"
  48.   "*Environment variables for Metamail.
  49. It must be an emtpy string or a string terminated with ';'.")
  50.  
  51. (defvar metamail-switches '("-m" "emacs" "-x" "-d" "-z")
  52.   "*Switches for Metamail program.
  53. -z is required to remove zap file.")
  54.  
  55. (defun metamail-buffer (&optional buffer)
  56.   "Process current buffer through 'metamail'.
  57. Optional argument BUFFER specifies a buffer to be filled (nil means current)."
  58.   (interactive)
  59.   (metamail-region (point-min) (point-max) buffer))
  60.  
  61. (defun metamail-region (beg end &optional buffer)
  62.   "Process current region through 'metamail'.
  63. Optional argument BUFFER specifies a buffer to be filled (nil means current)."
  64.   (interactive "r")
  65.   (let ((curbuf (current-buffer))
  66.     (buffer-read-only nil)
  67.     (metafile (make-temp-name "/tmp/metamail")))
  68.     (save-excursion
  69.       ;; Gee!  Metamail does not ouput to stdout if input comes from
  70.       ;; stdin.
  71.       (write-region beg end metafile nil 'nomessage)
  72.       (if buffer
  73.       (set-buffer buffer))
  74.       (setq buffer-read-only nil)
  75.       ;; Clear destination buffer.
  76.       (if (eq curbuf (current-buffer))
  77.       (delete-region beg end)
  78.     (delete-region (point-min) (point-max)))
  79.       ;; We have to pass the environment variable KEYHEADS to /bin/sh
  80.       ;; to display all header fields.  Metamail should have an
  81.       ;; optional argument to pass such information directly.
  82.       (apply (function call-process)
  83.          "/bin/sh"
  84.          nil
  85.          t                ;Output to current buffer
  86.          t                ;Force redisplay
  87.          (list "-c"
  88.            ;; Construct environment and the command.
  89.            (concat
  90.             metamail-environment
  91.             metamail-program-name
  92.             " "
  93.             (mapconcat (function identity) metamail-switches " ")
  94.             " "
  95.             metafile
  96.             )))
  97.       )))
  98.  
  99. ;(defun metamail-region (beg end &optional buffer)
  100. ;  "Process current region through 'metamail'.
  101. ;Optional argument BUFFER specifies a buffer to be filled (nil means current)."
  102. ;  (interactive "r")
  103. ;  (let ((curbuf (current-buffer))
  104. ;    (buffer-read-only nil)
  105. ;    (metafile (make-temp-name "/tmp/metamail")))
  106. ;    (save-excursion
  107. ;      (write-region (point-min) (point-max) metafile nil 'nomessage)
  108. ;      (if (eq curbuf
  109. ;          (if buffer (get-buffer buffer) (current-buffer)))
  110. ;      (delete-region (point-min) (point-max)))
  111. ;      (apply (function call-process)
  112. ;         metamail-program-name
  113. ;         nil
  114. ;         (or buffer t)        ;BUFFER or current buffer
  115. ;         nil            ;don't redisplay
  116. ;         (append metamail-switches (list metafile)))
  117. ;      )))
  118.  
  119. (provide 'metamail)
  120.  
  121. ;;; metamail.el ends here
  122.