emacs: Track full message and part descriptor in w3m CID store

This will simplify later changes.
This commit is contained in:
Austin Clements 2015-01-24 16:16:56 -05:00 committed by David Bremner
parent 4d5477a3d5
commit c67a04de60

View file

@ -562,35 +562,26 @@ message at DEPTH in the current thread."
(defvar notmuch-show-w3m-cid-store nil) (defvar notmuch-show-w3m-cid-store nil)
(make-variable-buffer-local 'notmuch-show-w3m-cid-store) (make-variable-buffer-local 'notmuch-show-w3m-cid-store)
(defun notmuch-show-w3m-cid-store-internal (content-id (defun notmuch-show-w3m-cid-store-internal (content-id msg part content)
message-id (push (list content-id msg part content)
part-number
content-type
content)
(push (list content-id
message-id
part-number
content-type
content)
notmuch-show-w3m-cid-store)) notmuch-show-w3m-cid-store))
(defun notmuch-show-w3m-cid-store (msg part) (defun notmuch-show-w3m-cid-store (msg part)
(let ((content-id (plist-get part :content-id))) (let ((content-id (plist-get part :content-id)))
(when content-id (when content-id
(notmuch-show-w3m-cid-store-internal (concat "cid:" content-id) (notmuch-show-w3m-cid-store-internal (concat "cid:" content-id)
(plist-get msg :id) msg part nil))))
(plist-get part :id)
(plist-get part :content-type)
nil))))
(defun notmuch-show-w3m-cid-retrieve (url &rest args) (defun notmuch-show-w3m-cid-retrieve (url &rest args)
(let ((matching-part (with-current-buffer w3m-current-buffer (let ((matching-part (with-current-buffer w3m-current-buffer
(assoc url notmuch-show-w3m-cid-store)))) (assoc url notmuch-show-w3m-cid-store))))
(if matching-part (if matching-part
(let ((message-id (nth 1 matching-part)) (let* ((msg (nth 1 matching-part))
(part-number (nth 2 matching-part)) (part (nth 2 matching-part))
(content-type (nth 3 matching-part)) (content (nth 3 matching-part))
(content (nth 4 matching-part))) (message-id (plist-get msg :id))
(part-number (plist-get part :id))
(content-type (plist-get part :content-type)))
;; If we don't already have the content, get it and cache ;; If we don't already have the content, get it and cache
;; it, as some messages reference the same cid: part many ;; it, as some messages reference the same cid: part many
;; times (hundreds!), which results in many calls to ;; times (hundreds!), which results in many calls to
@ -599,11 +590,7 @@ message at DEPTH in the current thread."
(setq content (notmuch-get-bodypart-internal (notmuch-id-to-query message-id) (setq content (notmuch-get-bodypart-internal (notmuch-id-to-query message-id)
part-number notmuch-show-process-crypto)) part-number notmuch-show-process-crypto))
(with-current-buffer w3m-current-buffer (with-current-buffer w3m-current-buffer
(notmuch-show-w3m-cid-store-internal url (notmuch-show-w3m-cid-store-internal url msg part content)))
message-id
part-number
content-type
content)))
(insert content) (insert content)
content-type) content-type)
nil))) nil)))