From 7d03d5f32ae86ced52fbe1a5aa154d696a29708b Mon Sep 17 00:00:00 2001
From: Daniel Colascione <dancol@dancol.org>
Date: Sat, 22 Feb 2025 14:54:24 -0500
Subject: [PATCH] Call file-readable-p only on non-remote files

Calling file-readable-p before reading a message file is fine
when the file is local, but when it's a remote file, doing so incurs
an extra network round trip.  It's not really necessary to do so
either: if the file is missing, we'll fail in the insert-file-contents
below anyway, so we're missing out only on a nicer warning message.
---
 mu4e/mu4e-headers.el | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/mu4e/mu4e-headers.el b/mu4e/mu4e-headers.el
index c214ce894..92b6dda3b 100644
--- a/mu4e/mu4e-headers.el
+++ b/mu4e/mu4e-headers.el
@@ -1432,7 +1432,8 @@ If SUBTHREAD is non-nil, only apply to subthread."
     (mu4e-error "Must be in mu4e-headers-mode (%S)" major-mode))
   (let* ((msg (mu4e-message-at-point))
          (path (mu4e-message-field msg :path))
-         (_exists (or (file-readable-p  path)
+         (_exists (or (file-remote-p path)
+                      (file-readable-p path)
                       (mu4e-warn "No message at %s" path)))
          (docid (or (mu4e-message-field msg :docid)
                     (mu4e-warn "No message at point")))