X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=emacs%2Fnotmuch-lib.el;h=d4b668496e51cb48355473c6427facc6170d0cee;hp=fd25f7c9e6279b528c81b1908948ff7554a12015;hb=021906d6ec60360b5587ae08657fd6caa9a71b17;hpb=c67a04de60d4f2f9060e41204f2fd50f1edc6a5c diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el index fd25f7c9..d4b66849 100644 --- a/emacs/notmuch-lib.el +++ b/emacs/notmuch-lib.el @@ -529,25 +529,25 @@ the given type." (lambda (part) (notmuch-match-content-type (plist-get part :content-type) type)) parts)) -;; Helper for parts which are generally not included in the default -;; SEXP output. -(defun notmuch-get-bodypart-internal (query part-number process-crypto) - (let ((args '("show" "--format=raw")) - (part-arg (format "--part=%s" part-number))) - (setq args (append args (list part-arg))) - (if process-crypto - (setq args (append args '("--decrypt")))) - (setq args (append args (list query))) +(defun notmuch-get-bodypart-binary (msg part process-crypto) + "Return the unprocessed content of PART in MSG. + +This returns the \"raw\" content of the given part after content +transfer decoding, but with no further processing (see the +discussion of --format=raw in man notmuch-show). In particular, +this does no charset conversion." + (let ((args `("show" "--format=raw" + ,(format "--part=%d" (plist-get part :id)) + ,@(when process-crypto '("--decrypt")) + ,(notmuch-id-to-query (plist-get msg :id))))) (with-temp-buffer (let ((coding-system-for-read 'no-conversion)) - (progn - (apply 'call-process (append (list notmuch-command nil (list t nil) nil) args)) - (buffer-string)))))) + (apply #'call-process notmuch-command nil '(t nil) nil args) + (buffer-string))))) (defun notmuch-get-bodypart-content (msg part process-crypto) (or (plist-get part :content) - (notmuch-get-bodypart-internal (notmuch-id-to-query (plist-get msg :id)) - (plist-get part :id) process-crypto))) + (notmuch-get-bodypart-binary msg part process-crypto))) ;; Workaround: The call to `mm-display-part' below triggers a bug in ;; Emacs 24 if it attempts to use the shr renderer to display an HTML