+\f
+
+;;; MH-Letter Commands
+
+;; MH-E commands are alphabetical; specific support routines follow command.
+
+;;;###mh-autoload
+(defun mh-compose-forward (&optional description folder range)
+ "Add tag to forward a message.
+
+You are prompted for a content DESCRIPTION, the name of the
+FOLDER in which the messages to forward are located, and a RANGE
+of messages, which defaults to the current message in that
+folder. Check the documentation of `mh-interactive-range' to see
+how RANGE is read in interactive use.
+
+The option `mh-compose-insertion' controls what type of tags are inserted."
+ (interactive
+ (let* ((description
+ (mml-minibuffer-read-description))
+ (folder
+ (mh-prompt-for-folder "Message from"
+ mh-sent-from-folder nil))
+ (default
+ (if (and (equal folder mh-sent-from-folder)
+ (numberp mh-sent-from-msg))
+ mh-sent-from-msg
+ (nth 0 (mh-translate-range folder "cur"))))
+ (range
+ (mh-read-range "Forward" folder
+ (or (and default
+ (number-to-string default))
+ t)
+ t t)))
+ (list description folder range)))
+ (let ((messages (mapconcat 'identity (mh-list-to-string range) " ")))
+ (dolist (message (mh-translate-range folder messages))
+ (if (equal mh-compose-insertion 'mml)
+ (mh-mml-forward-message description folder (format "%s" message))
+ (mh-mh-forward-message description folder (format "%s" message))))))
+
+;;;###mh-autoload
+(defun mh-mml-forward-message (description folder message)
+ "Forward a message as attachment.
+
+The function will prompt the user for a DESCRIPTION, a FOLDER and
+MESSAGE number."
+ (let ((msg (if (and (equal message "") (numberp mh-sent-from-msg))
+ mh-sent-from-msg
+ (string-to-number message))))
+ (cond ((integerp msg)
+ (if (string= "" description)
+ ;; Rationale: mml-attach-file constructs a malformed composition
+ ;; if the description string is empty. This fixes SF #625168.
+ (mml-attach-file (format "%s%s/%d"
+ mh-user-path (substring folder 1) msg)
+ "message/rfc822")
+ (mml-attach-file (format "%s%s/%d"
+ mh-user-path (substring folder 1) msg)
+ "message/rfc822"
+ description)))
+ (t (error "The message number, %s, is not a integer" msg)))))
+
+(defun mh-mh-forward-message (&optional description folder messages)
+ "Add tag to forward a message.
+You are prompted for a content DESCRIPTION, the name of the
+FOLDER in which the messages to forward are located, and the
+MESSAGES' numbers.
+
+See also \\[mh-mh-to-mime]."
+ (interactive (list
+ (mml-minibuffer-read-description)
+ (mh-prompt-for-folder "Message from" mh-sent-from-folder nil)
+ (read-string (concat "Messages"
+ (if (numberp mh-sent-from-msg)
+ (format " (default %d): "
+ mh-sent-from-msg)
+ ": ")))))
+ (beginning-of-line)
+ (insert "#forw [")
+ (and description
+ (not (string= description ""))
+ (insert description))
+ (insert "]")
+ (and folder
+ (not (string= folder ""))
+ (insert " " folder))
+ (if (and messages
+ (not (string= messages "")))
+ (let ((start (point)))
+ (insert " " messages)
+ (subst-char-in-region start (point) ?, ? ))
+ (if (numberp mh-sent-from-msg)
+ (insert " " (int-to-string mh-sent-from-msg))))
+ (insert "\n"))
+
+;;;###mh-autoload
+(defun mh-compose-insertion (&optional inline)
+ "Add tag to include a file such as an image or sound.
+
+You are prompted for the filename containing the object, the
+media type if it cannot be determined automatically, and a
+content description. If you're using MH-style directives, you
+will also be prompted for additional attributes.
+
+The option `mh-compose-insertion' controls what type of tags are
+inserted. Optional argument INLINE means make it an inline
+attachment."
+ (interactive "P")
+ (if (equal mh-compose-insertion 'mml)
+ (if inline
+ (mh-mml-attach-file "inline")
+ (mh-mml-attach-file))
+ (call-interactively 'mh-mh-attach-file)))
+
+(defun mh-mml-attach-file (&optional disposition)
+ "Add a tag to insert a MIME message part from a file.
+
+You are prompted for the filename containing the object, the
+media type if it cannot be determined automatically, a content
+description and the DISPOSITION of the attachment.
+
+This is basically `mml-attach-file' from Gnus, modified such that a prefix
+argument yields an \"inline\" disposition and Content-Type is determined
+automatically."
+ (let* ((file (mml-minibuffer-read-file "Attach file: "))
+ (type (mh-minibuffer-read-type file))
+ (description (mml-minibuffer-read-description))
+ (dispos (or disposition
+ (mh-mml-minibuffer-read-disposition type))))
+ (mml-insert-empty-tag 'part 'type type 'filename file
+ 'disposition dispos 'description description)))
+
+(defun mh-mh-attach-file (filename type description attributes)
+ "Add a tag to insert a MIME message part from a file.
+You are prompted for the FILENAME containing the object, the
+media TYPE if it cannot be determined automatically, and a
+content DESCRIPTION. In addition, you are also prompted for
+additional ATTRIBUTES.
+
+See also \\[mh-mh-to-mime]."
+ (interactive (let ((filename (mml-minibuffer-read-file "Attach file: ")))
+ (list
+ filename
+ (mh-minibuffer-read-type filename)
+ (mml-minibuffer-read-description)
+ (read-string "Attributes: "
+ (concat "name=\""
+ (file-name-nondirectory filename)
+ "\"")))))
+ (mh-mh-compose-type filename type description attributes))
+
+(defun mh-mh-compose-type (filename type
+ &optional description attributes comment)
+ "Insert an MH-style directive to insert a file.
+The file specified by FILENAME is encoded as TYPE. An optional
+DESCRIPTION is used as the Content-Description field, optional
+set of ATTRIBUTES and an optional COMMENT can also be included."
+ (beginning-of-line)
+ (insert "#" type)
+ (and attributes
+ (insert "; " attributes))
+ (and comment
+ (insert " (" comment ")"))
+ (insert " [")
+ (and description
+ (insert description))
+ (insert "] " (expand-file-name filename))
+ (insert "\n"))
+
+;;;###mh-autoload
+(defun mh-mh-compose-anon-ftp (host filename type description)
+ "Add tag to include anonymous ftp reference to a file.
+
+You can have your message initiate an \"ftp\" transfer when the
+recipient reads the message. You are prompted for the remote HOST
+and FILENAME, the media TYPE, and the content DESCRIPTION.
+
+See also \\[mh-mh-to-mime]."
+ (interactive (list
+ (read-string "Remote host: ")
+ (read-string "Remote filename: ")
+ (mh-minibuffer-read-type "DUMMY-FILENAME")
+ (mml-minibuffer-read-description)))
+ (mh-mh-compose-external-type "anon-ftp" host filename
+ type description))
+
+;;;###mh-autoload
+(defun mh-mh-compose-external-compressed-tar (host filename description)
+ "Add tag to include anonymous ftp reference to a compressed tar file.
+
+In addition to retrieving the file via anonymous \"ftp\" as per
+the command \\[mh-mh-compose-anon-ftp], the file will also be
+uncompressed and untarred. You are prompted for the remote HOST
+and FILENAME and the content DESCRIPTION.
+
+See also \\[mh-mh-to-mime]."
+ (interactive (list
+ (read-string "Remote host: ")
+ (read-string "Remote filename: ")
+ (mml-minibuffer-read-description)))
+ (mh-mh-compose-external-type "anon-ftp" host filename
+ "application/octet-stream"
+ description
+ "type=tar; conversions=x-compress"
+ "mode=image"))
+
+;; RFC 2045 - Multipurpose Internet Mail Extensions (MIME) Part One:
+;; Format of Internet Message Bodies.
+;; RFC 2046 - Multipurpose Internet Mail Extensions (MIME) Part Two:
+;; Media Types.
+;; RFC 2049 - Multipurpose Internet Mail Extensions (MIME) Part Five:
+;; Conformance Criteria and Examples.
+;; RFC 2017 - Definition of the URL MIME External-Body Access-Type
+;; RFC 1738 - Uniform Resource Locators (URL)
+(defvar mh-access-types
+ '(("anon-ftp") ; RFC2046 Anonymous File Transfer Protocol
+ ("file") ; RFC1738 Host-specific file names
+ ("ftp") ; RFC2046 File Transfer Protocol
+ ("gopher") ; RFC1738 The Gopher Protocol
+ ("http") ; RFC1738 Hypertext Transfer Protocol
+ ("local-file") ; RFC2046 Local file access
+ ("mail-server") ; RFC2046 mail-server Electronic mail address
+ ("mailto") ; RFC1738 Electronic mail address
+ ("news") ; RFC1738 Usenet news
+ ("nntp") ; RFC1738 Usenet news using NNTP access
+ ("propspero") ; RFC1738 Prospero Directory Service
+ ("telnet") ; RFC1738 Telnet
+ ("tftp") ; RFC2046 Trivial File Transfer Protocol
+ ("url") ; RFC2017 URL scheme MIME access-type Protocol
+ ("wais")) ; RFC1738 Wide Area Information Servers
+ "Valid MIME access-type values.")
+
+;;;###mh-autoload
+(defun mh-mh-compose-external-type (access-type host filename type
+ &optional description
+ attributes parameters
+ comment)
+ "Add tag to refer to a remote file.
+
+This command is a general utility for referencing external files.
+In fact, all of the other commands that insert directives to
+access external files call this command. You are prompted for the
+ACCESS-TYPE, remote HOST and FILENAME, and content TYPE. If you
+provide a prefix argument, you are also prompted for a content
+DESCRIPTION, ATTRIBUTES, PARAMETERS, and a COMMENT.
+
+See also \\[mh-mh-to-mime]."
+ (interactive (list
+ (completing-read "Access type: " mh-access-types)
+ (read-string "Remote host: ")
+ (read-string "Remote filename: ")
+ (mh-minibuffer-read-type "DUMMY-FILENAME")
+ (if current-prefix-arg (mml-minibuffer-read-description))
+ (if current-prefix-arg (read-string "Attributes: "))
+ (if current-prefix-arg (read-string "Parameters: "))
+ (if current-prefix-arg (read-string "Comment: "))))
+ (beginning-of-line)
+ (insert "#@" type)
+ (and attributes
+ (insert "; " attributes))
+ (and comment
+ (insert " (" comment ") "))
+ (insert " [")
+ (and description
+ (insert description))
+ (insert "] ")
+ (insert "access-type=" access-type "; ")
+ (insert "site=" host)
+ (insert "; name=" (file-name-nondirectory filename))
+ (let ((directory (file-name-directory filename)))
+ (and directory
+ (insert "; directory=\"" directory "\"")))
+ (and parameters
+ (insert "; " parameters))
+ (insert "\n"))
+
+(defvar mh-mh-to-mime-args nil
+ "Extra arguments for \\[mh-mh-to-mime] to pass to the \"mhbuild\" command.
+The arguments are passed to \"mhbuild\" if \\[mh-mh-to-mime] is
+given a prefix argument. Normally default arguments to
+\"mhbuild\" are specified in the MH profile.")
+
+;;;###mh-autoload
+(defun mh-mh-to-mime (&optional extra-args)
+ "Compose MIME message from MH-style directives.
+
+Typically, you send a message with attachments just like any other
+message. However, you may take a sneak preview of the MIME encoding if
+you wish by running this command.
+
+If you wish to pass additional arguments to \"mhbuild\" (\"mhn\")
+to affect how it builds your message, use the option
+`mh-mh-to-mime-args'. For example, you can build a consistency
+check into the message by setting `mh-mh-to-mime-args' to
+\"-check\". The recipient of your message can then run \"mhbuild
+-check\" on the message--\"mhbuild\" (\"mhn\") will complain if
+the message has been corrupted on the way. This command only
+consults this option when given a prefix argument EXTRA-ARGS.
+
+The hook `mh-mh-to-mime-hook' is called after the message has been
+formatted.
+
+The effects of this command can be undone by running
+\\[mh-mh-to-mime-undo]."
+ (interactive "*P")
+ (mh-mh-quote-unescaped-sharp)
+ (save-buffer)
+ (message "Running %s..." (if (mh-variant-p 'nmh) "mhbuild" "mhn"))
+ (cond
+ ((mh-variant-p 'nmh)
+ (mh-exec-cmd-error nil
+ "mhbuild"
+ (if extra-args mh-mh-to-mime-args)
+ buffer-file-name))
+ (t
+ (mh-exec-cmd-error (format "mhdraft=%s" buffer-file-name)
+ "mhn"
+ (if extra-args mh-mh-to-mime-args)
+ buffer-file-name)))
+ (revert-buffer t t)
+ (message "Running %s...done" (if (mh-variant-p 'nmh) "mhbuild" "mhn"))
+ (run-hooks 'mh-mh-to-mime-hook))
+
+(defun mh-mh-quote-unescaped-sharp ()
+ "Quote \"#\" characters that haven't been quoted for \"mhbuild\".
+If the \"#\" character is present in the first column, but it isn't
+part of a MH-style directive then \"mhbuild\" gives an error.
+This function will quote all such characters."
+ (save-excursion
+ (goto-char (point-min))
+ (while (re-search-forward "^#" nil t)
+ (beginning-of-line)
+ (unless (mh-mh-directive-present-p (point) (mh-line-end-position))
+ (insert "#"))
+ (goto-char (mh-line-end-position)))))
+
+;;;###mh-autoload
+(defun mh-mh-to-mime-undo (noconfirm)
+ "Undo effects of \\[mh-mh-to-mime].
+
+It does this by reverting to a backup file. You are prompted to
+confirm this action, but you can avoid the confirmation by adding
+a prefix argument NOCONFIRM."
+ (interactive "*P")
+ (if (null buffer-file-name)
+ (error "Buffer does not seem to be associated with any file"))
+ (let ((backup-strings '("," "#"))
+ backup-file)
+ (while (and backup-strings
+ (not (file-exists-p
+ (setq backup-file
+ (concat (file-name-directory buffer-file-name)
+ (car backup-strings)
+ (file-name-nondirectory buffer-file-name)
+ ".orig")))))
+ (setq backup-strings (cdr backup-strings)))
+ (or backup-strings
+ (error "Backup file for %s no longer exists" buffer-file-name))
+ (or noconfirm
+ (yes-or-no-p (format "Revert buffer from file %s? "
+ backup-file))
+ (error "Revert not confirmed"))
+ (let ((buffer-read-only nil))
+ (erase-buffer)
+ (insert-file-contents backup-file))
+ (after-find-file nil)))
+
+;; Shush compiler.
+(defvar mh-identity-pgg-default-user-id)
+
+;;;###mh-autoload
+(defun mh-mml-secure-message-encrypt (method)
+ "Add tag to encrypt the message.
+
+A proper multipart message is created for you when you send the
+message. Use the command \\[mh-mml-unsecure-message] to remove
+this tag. Use a prefix argument METHOD to be prompted for one of
+the possible security methods (see `mh-mml-method-default')."
+ (interactive (list (mh-mml-query-cryptographic-method)))
+ (mh-secure-message method "encrypt" mh-identity-pgg-default-user-id))
+
+;;;###mh-autoload
+(defun mh-mml-secure-message-sign (method)
+ "Add tag to sign the message.
+
+A proper multipart message is created for you when you send the
+message. Use the command \\[mh-mml-unsecure-message] to remove
+this tag. Use a prefix argument METHOD to be prompted for one of
+the possible security methods (see `mh-mml-method-default')."
+ (interactive (list (mh-mml-query-cryptographic-method)))
+ (mh-secure-message method "sign" mh-identity-pgg-default-user-id))
+
+;;;###mh-autoload
+(defun mh-mml-secure-message-signencrypt (method)
+ "Add tag to encrypt and sign the message.
+
+A proper multipart message is created for you when you send the
+message. Use the command \\[mh-mml-unsecure-message] to remove
+this tag. Use a prefix argument METHOD to be prompted for one of
+the possible security methods (see `mh-mml-method-default')."
+ (interactive (list (mh-mml-query-cryptographic-method)))
+ (mh-secure-message method "signencrypt" mh-identity-pgg-default-user-id))
+
+(defvar mh-mml-cryptographic-method-history ())
+
+(defun mh-mml-query-cryptographic-method ()
+ "Read the cryptographic method to use."
+ (if current-prefix-arg
+ (let ((def (or (car mh-mml-cryptographic-method-history)
+ mh-mml-method-default)))
+ (completing-read (format "Method (default %s): " def)
+ '(("pgp") ("pgpmime") ("smime"))
+ nil t nil 'mh-mml-cryptographic-method-history def))
+ mh-mml-method-default))
+
+(defun mh-secure-message (method mode &optional identity)
+ "Add tag to encrypt or sign message.
+
+METHOD should be one of: \"pgpmime\", \"pgp\", \"smime\".
+MODE should be one of: \"sign\", \"encrypt\", \"signencrypt\", \"none\".
+IDENTITY is optionally the default-user-id to use."
+ (if (not mh-pgp-support-flag)
+ (error "Your version of Gnus does not support PGP/GPG")
+ ;; Check the arguments
+ (let ((valid-methods (list "pgpmime" "pgp" "smime"))
+ (valid-modes (list "sign" "encrypt" "signencrypt" "none")))
+ (if (not (member method valid-methods))
+ (error "Method %s is invalid" method))
+ (if (not (member mode valid-modes))
+ (error "Mode %s is invalid" mode))
+ (mml-unsecure-message)
+ (if (not (string= mode "none"))
+ (save-excursion
+ (goto-char (point-min))
+ (mh-goto-header-end 1)
+ (if mh-identity-pgg-default-user-id
+ (mml-insert-tag 'secure 'method method 'mode mode
+ 'sender mh-identity-pgg-default-user-id)
+ (mml-insert-tag 'secure 'method method 'mode mode)))))))
+
+;;;###mh-autoload
+(defun mh-mml-to-mime ()
+ "Compose MIME message from MML tags.
+
+Typically, you send a message with attachments just like any
+other message. However, you may take a sneak preview of the MIME
+encoding if you wish by running this command.
+
+This action can be undone by running \\[undo]."
+ (interactive)
+ (require 'message)
+ (when mh-pgp-support-flag ;; This is only needed for PGP
+ (message-options-set-recipient))
+ (let ((saved-text (buffer-string))
+ (buffer (current-buffer))
+ (modified-flag (buffer-modified-p)))
+ (condition-case err (mml-to-mime)
+ (error
+ (with-current-buffer buffer
+ (delete-region (point-min) (point-max))
+ (insert saved-text)
+ (set-buffer-modified-p modified-flag))
+ (error (error-message-string err))))))
+
+;;;###mh-autoload
+(defun mh-mml-unsecure-message ()
+ "Remove any secure message tags."
+ (interactive)
+ (if (not mh-pgp-support-flag)
+ (error "Your version of Gnus does not support PGP/GPG")
+ (mml-unsecure-message)))
+
+\f
+
+;;; Support Routines for MH-Letter Commands
+
+;;;###mh-autoload
+(defun mh-mml-tag-present-p ()
+ "Check if the current buffer has text which may be a MML tag."
+ (save-excursion
+ (goto-char (point-min))
+ (re-search-forward
+ (concat
+ "\\(<#\\(mml\\|part\\)\\(.\\|\n\\)*>[ \n\t]*<#/\\(mml\\|part\\)>\\|"
+ "^<#secure.+>$\\)")
+ nil t)))
+
+(defvar mh-media-type-regexp
+ (concat (regexp-opt '("text" "image" "audio" "video" "application"
+ "multipart" "message") t)
+ "/[-.+a-zA-Z0-9]+")
+ "Regexp matching valid media types used in MIME attachment compositions.")
+
+;;;###mh-autoload
+(defun mh-mh-directive-present-p (&optional begin end)
+ "Check if the text between BEGIN and END might be a MH-style directive.
+The optional argument BEGIN defaults to the beginning of the
+buffer, while END defaults to the the end of the buffer."
+ (unless begin (setq begin (point-min)))
+ (unless end (setq end (point-max)))
+ (save-excursion
+ (block 'search-for-mh-directive
+ (goto-char begin)
+ (while (re-search-forward "^#" end t)
+ (let ((s (buffer-substring-no-properties
+ (point) (mh-line-end-position))))
+ (cond ((equal s ""))
+ ((string-match "^forw[ \t\n]+" s)
+ (return-from 'search-for-mh-directive t))
+ (t (let ((first-token (car (split-string s "[ \t;@]"))))
+ (when (and first-token
+ (string-match mh-media-type-regexp
+ first-token))
+ (return-from 'search-for-mh-directive t)))))))
+ nil)))
+
+(defun mh-minibuffer-read-type (filename &optional default)
+ "Return the content type associated with the given FILENAME.
+If the \"file\" command exists and recognizes the given file,
+then its value is returned\; otherwise, the user is prompted for
+a type (see `mailcap-mime-types').
+Optional argument DEFAULT is returned if a type isn't entered."
+ (mailcap-parse-mimetypes)
+ (let* ((default (or default
+ (mm-default-file-encoding filename)
+ "application/octet-stream"))
+ (probed-type (mh-file-mime-type filename))
+ (type (or (and (not (equal probed-type "application/octet-stream"))
+ probed-type)
+ (completing-read
+ (format "Content type (default %s): " default)
+ (mapcar 'list (mailcap-mime-types))))))
+ (if (not (equal type ""))
+ type
+ default)))
+
+;;;###mh-autoload
+(defun mh-file-mime-type (filename)
+ "Return MIME type of FILENAME from file command.
+Returns nil if file command not on system."
+ (cond
+ ((not (mh-have-file-command))
+ nil) ;no file command, exit now
+ ((not (and (file-exists-p filename)
+ (file-readable-p filename)))
+ nil) ;no file or not readable, ditto
+ (t
+ (save-excursion
+ (let ((tmp-buffer (get-buffer-create mh-temp-buffer)))
+ (set-buffer tmp-buffer)
+ (unwind-protect
+ (progn
+ (call-process "file" nil '(t nil) nil "-b" "-i"
+ (expand-file-name filename))
+ (goto-char (point-min))
+ (if (not (re-search-forward mh-media-type-regexp nil t))
+ nil
+ (mh-file-mime-type-substitute (match-string 0) filename)))
+ (kill-buffer tmp-buffer)))))))
+
+(defvar mh-file-mime-type-substitutions
+ '(("application/msword" "\.xls" "application/ms-excel")
+ ("application/msword" "\.ppt" "application/ms-powerpoint")
+ ("text/plain" "\.vcf" "text/x-vcard")
+ ("text/rtf" "\.rtf" "application/rtf")
+ ("application/x-zip" "\.sxc" "application/vnd.sun.xml.calc")
+ ("application/x-zip" "\.sxd" "application/vnd.sun.xml.draw")
+ ("application/x-zip" "\.sxi" "application/vnd.sun.xml.impress")
+ ("application/x-zip" "\.sxw" "application/vnd.sun.xml.writer")
+ ("application/x-zip" "\.odg" "application/vnd.oasis.opendocument.graphics")
+ ("application/x-zip" "\.odi" "application/vnd.oasis.opendocument.image")
+ ("application/x-zip" "\.odp"
+ "application/vnd.oasis.opendocument.presentation")
+ ("application/x-zip" "\.ods"
+ "application/vnd.oasis.opendocument.spreadsheet")
+ ("application/x-zip" "\.odt" "application/vnd.oasis.opendocument.text"))
+ "Substitutions to make for Content-Type returned from file command.
+The first element is the Content-Type returned by the file command.
+The second element is a regexp matching the file name, usually the
+extension.
+The third element is the Content-Type to replace with.")
+
+(defun mh-file-mime-type-substitute (content-type filename)
+ "Return possibly changed CONTENT-TYPE on the FILENAME.
+Substitutions are made from the `mh-file-mime-type-substitutions'
+variable."
+ (let ((subst mh-file-mime-type-substitutions)
+ (type) (match) (answer content-type)
+ (case-fold-search t))
+ (while subst
+ (setq type (car (car subst))
+ match (elt (car subst) 1))
+ (if (and (string-equal content-type type)
+ (string-match match filename))
+ (setq answer (elt (car subst) 2)
+ subst nil)
+ (setq subst (cdr subst))))
+ answer))
+
+(defvar mh-have-file-command 'undefined
+ "Cached value of function `mh-have-file-command'.
+Do not reference this variable directly as it might not have been
+initialized. Always use the command `mh-have-file-command'.")
+
+;;;###mh-autoload
+(defun mh-have-file-command ()
+ "Return t if 'file' command is on the system.
+'file -i' is used to get MIME type of composition insertion."
+ (when (eq mh-have-file-command 'undefined)
+ (setq mh-have-file-command
+ (and (fboundp 'executable-find)
+ (executable-find "file") ; file command exists
+ ; and accepts -i and -b args.
+ (zerop (call-process "file" nil nil nil "-i" "-b"
+ (expand-file-name "inc" mh-progs))))))
+ mh-have-file-command)
+
+\f
+
+;;; MIME Cleanup
+
+;;;###mh-autoload
+(defun mh-mime-cleanup ()
+ "Free the decoded MIME parts."
+ (let ((mime-data (gethash (current-buffer) mh-globals-hash)))
+ ;; This is for Emacs, what about XEmacs?
+ (mh-funcall-if-exists remove-images (point-min) (point-max))
+ (when mime-data
+ (mh-mm-destroy-parts (mh-mime-handles mime-data))
+ (remhash (current-buffer) mh-globals-hash))))
+
+;;;###mh-autoload
+(defun mh-destroy-postponed-handles ()
+ "Free MIME data for externally displayed MIME parts."
+ (let ((mime-data (mh-buffer-data)))
+ (when mime-data
+ (mh-mm-destroy-parts (mh-mime-handles mime-data)))
+ (remhash (current-buffer) mh-globals-hash)))