Subject: MH-E: want all folder buffers to use $HOME as default-directory
From: Stephen Gildea <[email-masked]>
To: [email-masked]
Date: Tue, 25 Mar 2025 14:07:33 -0700
List-Id: <debbugs-submit.debbugs.gnu.org>

Version: 30.1
Severity: wishlist
Tags: patch

An MH-E folder buffer inherits the default-directory of the
buffer you happened to be in when you gave the command 'mh-rmail'.

This seems arbitrary in general, and inconvenient when the
current directory happens to be remote.  With a remote
directory, Emacs tries to do remote things in the background,
and all I'm trying to do is read my (local) email.

The following patch would fix the problem.  It introduces a new
variable 'mh-default-directory', which defaults to $HOME.

diff --git a/lisp/mh-e/mh-e.el b/lisp/mh-e/mh-e.el
index e507996c581..ca829c6cf3c 100644
--- a/lisp/mh-e/mh-e.el
+++ b/lisp/mh-e/mh-e.el
@@ -144,6 +144,9 @@ mh-lib-progs
 ;;;###autoload
 (put 'mh-lib-progs 'risky-local-variable t)
 
+(defvar mh-default-directory "~/"
+  "Default directory for MH-E folder buffers.")
+
 ;; Profile Components
 
 (defvar mh-draft-folder nil
diff --git a/lisp/mh-e/mh-folder.el b/lisp/mh-e/mh-folder.el
index 5009c2c4f98..43b4c98ef01 100644
--- a/lisp/mh-e/mh-folder.el
+++ b/lisp/mh-e/mh-folder.el
@@ -51,9 +51,12 @@ mh-rmail
   (interactive "P")
   (mh-find-path)
   (if arg
-      (call-interactively 'mh-visit-folder)
+      (progn
+        (call-interactively 'mh-visit-folder)
+        (cd-absolute mh-default-directory))
     (unless (get-buffer mh-inbox)
-      (mh-visit-folder mh-inbox (symbol-name mh-unseen-seq)))
+      (mh-visit-folder mh-inbox (symbol-name mh-unseen-seq))
+      (cd-absolute mh-default-directory))
     (mh-inc-folder)))
 
 ;;;###autoload
@@ -67,6 +70,7 @@ mh-nmail
   (mh-find-path)                        ; init mh-inbox
   (if arg
       (call-interactively 'mh-visit-folder)
-    (mh-visit-folder mh-inbox)))
+    (mh-visit-folder mh-inbox))
+  (cd-absolute mh-default-directory))