diff --git a/mu4e/mu4e-message.el b/mu4e/mu4e-message.el index b8d01db6..2acc0533 100644 --- a/mu4e/mu4e-message.el +++ b/mu4e/mu4e-message.el @@ -137,7 +137,6 @@ This is equivalent to: "" ;; not implemented for Gnus mode. ) - (defun mu4e-message-contact-field-matches (msg cfield rx) "Does MSG's contact-field CFIELD match rx? Check if any of the of the CFIELD in MSG matches RX. I.e. @@ -211,6 +210,15 @@ symbol, see `mu4e-header-info'." ;;; Html2Text (make-obsolete 'mu4e-shr2text "No longer in use" "1.7.0") +(defun mu4e-message-readable-path (&optional msg) + "Get a readable path to MSG or raise an error. +If MSG is nil, use mu4e-message-at-point. +" + (let ((path (plist-get (or msg (mu4e-message-at-point)) :path))) + (unless (file-readable-p path) + (mu4e-error "No readable message at %s; database outdated?" path)) + path)) + (defun mu4e-copy-message-path () "Copy the message-path of message at point to the kill ring." (interactive) diff --git a/mu4e/mu4e-view.el b/mu4e/mu4e-view.el index 02ee6e7a..b97c7d94 100644 --- a/mu4e/mu4e-view.el +++ b/mu4e/mu4e-view.el @@ -196,10 +196,8 @@ other windows." (defun mu4e-view-raw-message () "Display the raw contents of message at point in a new buffer." (interactive) - (let ((path (mu4e-message-field-at-point :path)) + (let ((path (mu4e-message-readable-path)) (buf (get-buffer-create mu4e~view-raw-buffer-name))) - (unless (and path (file-readable-p path)) - (mu4e-error "Not a readable file: %S" path)) (with-current-buffer buf (let ((inhibit-read-only t)) (erase-buffer) @@ -212,7 +210,7 @@ other windows." "Pipe the message at point through shell command CMD. Then, display the results." (interactive "sShell command: ") - (let ((path (mu4e-message-field (mu4e-message-at-point) :path))) + (let ((path (mu4e-message-readable-path))) (mu4e-process-file-through-pipe path cmd))) (defmacro mu4e~view-in-headers-context (&rest body) @@ -642,7 +640,7 @@ marking if it still had that." (remove-overlays (point-min)(point-max) 'mu4e-overlay t) (erase-buffer) (insert-file-contents-literally - (mu4e-message-field msg :path) nil nil nil t))) + (mu4e-message-readable-path msg) nil nil nil t))) (switch-to-buffer gnus-article-buffer) (setq mu4e~view-message msg) (mu4e~view-render-buffer msg)) @@ -651,9 +649,10 @@ marking if it still had that." "Return the pristine MSG as a string." ;; we need this for replying/forwarding, since the mu4e-compose ;; wants it that way. + (with-temp-buffer (insert-file-contents-literally - (mu4e-message-field msg :path) nil nil nil t) + (mu4e-message-readable-path msg) nil nil nil t) (mu4e~view-render-buffer msg) (buffer-substring-no-properties (point-min) (point-max)))) @@ -665,7 +664,7 @@ The variables `browse-url-browser-function', determine which browser function to use." (with-temp-buffer (insert-file-contents-literally - (mu4e-message-field msg :path) nil nil nil t) + (mu4e-message-readable-path msg) nil nil nil t) (run-hooks 'gnus-article-decode-hook) (let ((header (unless skip-headers (cl-loop for field in '("from" "to" "cc" "date" "subject")