Function: preview-format-mml

preview-format-mml is a byte-compiled function defined in preview.el.

Signature

(preview-format-mml OV &optional DONT-ASK)

Documentation

Return an MML representation of OV as string.

This can be used to send inline images in mail and news when using MML mode. If there is nothing current available, nil is returned. If the image has a colored border and the user wants it removed when asked (unless DONT-ASK is set), badcolor is thrown a t. The MML is returned in the car of the result, DONT-ASK in the cdr.

Source Code

;; Defined in ~/.emacs.d/elpa/auctex-14.1.2/preview.el
(defun preview-format-mml (ov &optional dont-ask)
  "Return an MML representation of OV as string.
This can be used to send inline images in mail and news when
using MML mode.  If there is nothing current available,
nil is returned.  If the image has a colored border and the
user wants it removed when asked (unless DONT-ASK is set),
`badcolor' is thrown a t.  The MML is returned in the car of the
result, DONT-ASK in the cdr."
  (and (memq (overlay-get ov 'preview-state) '(active inactive))
       (not (overlay-get ov 'queued))
       (let* ((text (with-current-buffer (overlay-buffer ov)
                     (buffer-substring (overlay-start ov)
                                       (overlay-end ov))))
              (image (cdr (overlay-get ov 'preview-image)))
              file type)
         (cond ((consp image)
                (and (not dont-ask)
                     (nth 3 image)
                     (if (y-or-n-p "Replace colored borders? ")
                         (throw 'badcolor t)
                       (setq dont-ask t)))
                (setq file (car (car (last (overlay-get ov 'filenames))))
                      type (mailcap-extension-to-mime
                            (file-name-extension file)))
                (cons
                 (format "<#part %s
description=\"%s\"
filename=%s>
<#/part>"
                         (if type
                             (format "type=\"%s\" disposition=inline" type)
                           "disposition=attachment")
                         (if (string-match "[\n\"]" text)
                             "preview-latex image"
                           text)
                         (if (string-match "[ \n<>]" file)
                             (concat "\"" file "\"")
                           file))
                 dont-ask))
               ((stringp image)
                (cons image dont-ask))))))