X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=emacs%2Fnotmuch-show.el;h=2896aae855ca78e076d2a4b098ddd108078c4203;hb=HEAD;hp=e5de97790e4da9fe7cc4d55d15a170b9261fdf5f;hpb=eb7d096edce8443f3db49376ee485cf357523d3b;p=obsolete%2Fnotmuch-old diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index e5de9779..2896aae8 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -41,6 +41,9 @@ (declare-function notmuch-search-next-thread "notmuch" nil) (declare-function notmuch-search-previous-thread "notmuch" nil) (declare-function notmuch-search-show-thread "notmuch" nil) +(declare-function notmuch-foreach-mime-part "notmuch" (function mm-handle)) +(declare-function notmuch-count-attachments "notmuch" (mm-handle)) +(declare-function notmuch-save-attachments "notmuch" (mm-handle &optional queryp)) (defcustom notmuch-message-headers '("Subject" "To" "Cc" "Date") "Headers that should be shown in a message, in this order. @@ -237,42 +240,6 @@ For example, if you wanted to remove an \"unread\" tag and add a ))) (mm-display-parts (mm-dissect-buffer))))) -(defun notmuch-foreach-mime-part (function mm-handle) - (cond ((stringp (car mm-handle)) - (dolist (part (cdr mm-handle)) - (notmuch-foreach-mime-part function part))) - ((bufferp (car mm-handle)) - (funcall function mm-handle)) - (t (dolist (part mm-handle) - (notmuch-foreach-mime-part function part))))) - -(defun notmuch-count-attachments (mm-handle) - (let ((count 0)) - (notmuch-foreach-mime-part - (lambda (p) - (let ((disposition (mm-handle-disposition p))) - (and (listp disposition) - (or (equal (car disposition) "attachment") - (and (equal (car disposition) "inline") - (assq 'filename disposition))) - (incf count)))) - mm-handle) - count)) - -(defun notmuch-save-attachments (mm-handle &optional queryp) - (notmuch-foreach-mime-part - (lambda (p) - (let ((disposition (mm-handle-disposition p))) - (and (listp disposition) - (or (equal (car disposition) "attachment") - (and (equal (car disposition) "inline") - (assq 'filename disposition))) - (or (not queryp) - (y-or-n-p - (concat "Save '" (cdr (assq 'filename disposition)) "' "))) - (mm-save-part p)))) - mm-handle)) - (defun notmuch-show-save-attachments () "Save all attachments from the current message." (interactive) @@ -892,6 +859,9 @@ If HIDE is non-nil then initially hide this part." (notmuch-show-insert-part-header nth mime-type content-type (plist-get part :filename)))) (content-beg (point))) + ;; Store the computed mime-type for later use (e.g. by attachment handlers). + (plist-put part :computed-type mime-type) + (if (not hide) (notmuch-show-insert-bodypart-internal msg part mime-type nth depth button) (button-put button :notmuch-lazy-part @@ -2042,7 +2012,7 @@ the user (see `notmuch-show-stash-mlarchive-link-alist')." (with-current-buffer buf (setq notmuch-show-process-crypto process-crypto) ;; Always acquires the part via `notmuch part', even if it is - ;; available in the JSON output. + ;; available in the SEXP output. (insert (notmuch-get-bodypart-internal message-id nth notmuch-show-process-crypto))) buf)) @@ -2055,10 +2025,10 @@ caller is responsible for killing this buffer as appropriate." (message-id (notmuch-show-get-message-id)) (nth (plist-get part :id)) (buf (notmuch-show-generate-part-buffer message-id nth)) - (content-type (plist-get part :content-type)) + (computed-type (plist-get part :computed-type)) (filename (plist-get part :filename)) (disposition (if filename `(attachment (filename . ,filename))))) - (mm-make-handle buf (list content-type) nil nil disposition))) + (mm-make-handle buf (list computed-type) nil nil disposition))) (defun notmuch-show-apply-to-current-part-handle (fn) "Apply FN to an mm-handle for the part containing point.