Function: gnus-article-part-wrapper
gnus-article-part-wrapper is a byte-compiled function defined in
gnus-art.el.gz.
Signature
(gnus-article-part-wrapper N FUNCTION &optional NO-HANDLE INTERACTIVE)
Documentation
Call FUNCTION on MIME part N.
Unless NO-HANDLE, call FUNCTION with N-th MIME handle as its only argument. If INTERACTIVE, call FUNCTION interactively.
Source Code
;; Defined in /usr/src/emacs/lisp/gnus/gnus-art.el.gz
(defun gnus-article-part-wrapper (n function &optional no-handle interactive)
"Call FUNCTION on MIME part N.
Unless NO-HANDLE, call FUNCTION with N-th MIME handle as its only argument.
If INTERACTIVE, call FUNCTION interactively."
(let (window frame)
;; Check whether the article is displayed.
(unless (and (gnus-buffer-live-p gnus-article-buffer)
(setq window (get-buffer-window gnus-article-buffer t))
(frame-visible-p (setq frame (window-frame window))))
(error "No article is displayed"))
(with-current-buffer gnus-article-buffer
;; Check whether the article displays the right contents.
(unless (with-current-buffer gnus-summary-buffer
(eq gnus-current-article (gnus-summary-article-number)))
(error "You should select the right article first"))
(if n
(setq n (prefix-numeric-value n))
(let ((pt (point)))
(setq n (or (get-text-property pt 'gnus-part)
(and (not (bobp))
(get-text-property (1- pt) 'gnus-part))
(get-text-property (prog2
(forward-line 1)
(point)
(goto-char pt))
'gnus-part)
(get-text-property
(or (and (setq pt (previous-single-property-change
pt 'gnus-part))
(1- pt))
(next-single-property-change (point) 'gnus-part)
(point))
'gnus-part)
1))))
;; Check whether the specified part exists.
(when (> n (length gnus-article-mime-handle-alist))
(error "No such part")))
(unless
(progn
;; To select the window is needed so that the cursor
;; might be visible on the MIME button.
(select-window (prog1
window
(setq window (selected-window))
;; Article may be displayed in the other frame.
(select-frame-set-input-focus
(prog1
frame
(setq frame (selected-frame))))))
(when (gnus-article-goto-part n)
;; We point the cursor and the arrow at the MIME button
;; when the `function' prompt the user for something.
(unless (and (pos-visible-in-window-p)
(> (count-lines (point) (window-end))
(/ (1- (window-height)) 3)))
(recenter (/ (1- (window-height)) 3)))
(let ((cursor-in-non-selected-windows t)
(overlay-arrow-string "=>")
(overlay-arrow-position (point-marker)))
(unwind-protect
(cond
((and no-handle interactive)
(call-interactively function))
(no-handle
(funcall function))
(interactive
(call-interactively
function (get-text-property (point) 'gnus-data)))
(t
(funcall function
(get-text-property (point) 'gnus-data))))
(set-marker overlay-arrow-position nil)
(unless gnus-auto-select-part
(select-frame-set-input-focus frame)
(select-window window))))
t))
(if gnus-inhibit-mime-unbuttonizing
;; This is the default though the program shouldn't reach here.
(error "No such part")
;; The part which doesn't have the MIME button is selected.
;; So, we display all the buttons and redo it.
(let ((gnus-inhibit-mime-unbuttonizing t))
(gnus-summary-show-article)
(gnus-article-part-wrapper n function no-handle))))))