Function: metamail-region
metamail-region is an interactive and byte-compiled function defined
in metamail.el.gz.
Signature
(metamail-region BEG END &optional VIEWMODE BUFFER NODISPLAY)
Documentation
Process current region through metamail.
Optional argument VIEWMODE specifies the value of the EMACS_VIEW_MODE environment variable (defaulted to 1). Optional argument BUFFER specifies a buffer to be filled (nil means current). Optional argument NODISPLAY non-nil means buffer is not redisplayed as output is inserted.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/obsolete/metamail.el.gz
;;;###autoload
(defun metamail-region (beg end &optional viewmode buffer nodisplay)
"Process current region through `metamail'.
Optional argument VIEWMODE specifies the value of the
EMACS_VIEW_MODE environment variable (defaulted to 1).
Optional argument BUFFER specifies a buffer to be filled (nil
means current).
Optional argument NODISPLAY non-nil means buffer is not
redisplayed as output is inserted."
(interactive "r\np")
(let ((curbuf (current-buffer))
(buffer-read-only nil)
(metafile (make-temp-file "metamail"))
(option-environment
(list (format "EMACS_VIEW_MODE=%d"
(if (numberp viewmode) viewmode 1)))))
(save-excursion
;; Gee! Metamail does not output to stdout if input comes from
;; stdin.
(let ((selective-display nil)) ;Disable ^M to nl translation.
(write-region beg end metafile nil 'nomessage))
(if buffer
(set-buffer buffer))
(setq buffer-read-only nil)
;; Clear destination buffer.
(if (eq curbuf (current-buffer))
(delete-region beg end)
(delete-region (point-min) (point-max)))
;; We have to pass the environment variable KEYHEADS to display
;; all header fields. Metamail should have an optional argument
;; to pass such information directly.
(let ((process-environment
(append process-environment
metamail-environment option-environment))
(coding-system-for-read 'undecided))
(apply (function call-process)
metamail-program-name
nil
t ;Output to current buffer
(not nodisplay) ;Force redisplay
(append metamail-switches
(list "-m" (or metamail-mailer-name "emacs"))
(list metafile))))
;; `metamail' may not delete the temporary file!
(condition-case nil
(delete-file metafile)
(error nil))
)))