Function: mh-insert-mime-button

mh-insert-mime-button is a byte-compiled function defined in mh-mime.el.gz.

Signature

(mh-insert-mime-button HANDLE INDEX DISPLAYED)

Documentation

Insert MIME button for HANDLE.

INDEX is the part number that will be DISPLAYED. It is also used by commands like "K v" which operate on individual MIME parts.

Source Code

;; Defined in /usr/src/emacs/lisp/mh-e/mh-mime.el.gz
(defun mh-insert-mime-button (handle index displayed)
  "Insert MIME button for HANDLE.
INDEX is the part number that will be DISPLAYED. It is also used
by commands like \"K v\" which operate on individual MIME parts."
  ;; The button could be displayed by a previous decode. In that case
  ;; undisplay it if we need a hidden button.
  (when (and (mm-handle-displayed-p handle) (not displayed))
    (mm-display-part handle))
  (let ((name (or (mail-content-type-get (mm-handle-type handle) 'name)
                  (mail-content-type-get (mm-handle-disposition handle)
                                         'filename)
                  (mail-content-type-get (mm-handle-type handle) 'url)
                  ""))
        (type (mm-handle-media-type handle))
        begin end)
    (if (string-match ".*/" name) (setq name (substring name (match-end 0))))
    ;; These vars are passed by dynamic-scoping to
    ;; mh-mime-button-line-format-alist via gnus-eval-format.
    (mh-dlet* ((index index)
               (description (mail-decode-encoded-word-string
                             (or (mm-handle-description handle) "")))
               (dots (if (or displayed (mm-handle-displayed-p handle))
                         "   " "..."))
               (long-type (concat type (and (not (equal name ""))
                                            (concat "; " name)))))
      (unless (equal description "")
        (setq long-type (concat " --- " long-type)))
      (unless (bolp) (insert "\n"))
      (setq begin (point))
      (gnus-eval-format
       mh-mime-button-line-format mh-mime-button-line-format-alist
       `(,@(mh-gnus-local-map-property mh-mime-button-map)
         mh-callback mh-mm-display-part
         mh-part ,index
         mh-data ,handle)))
    (setq end (point))
    (widget-convert-button
     'link begin end
     :mime-handle handle
     :action 'mh-widget-press-button
     :button-keymap mh-mime-button-map
     :help-echo
     "Mouse-2 click or press RET (in show buffer) to toggle display")
    (dolist (ov (mh-funcall-if-exists overlays-in begin end))
      (mh-funcall-if-exists overlay-put ov 'evaporate t))))