GNU bug report logs - #77263
MH-E: want all folder buffers to use $HOME as default-directory

Previous Next

Package: emacs;

Reported by: Stephen Gildea <stepheng+emacs <at> gildea.com>

Date: Tue, 25 Mar 2025 21:08:02 UTC

Severity: wishlist

Tags: patch

Found in version 30.1

Done: Stephen Gildea <stepheng+emacs <at> gildea.com>

Bug is archived. No further changes may be made.

Full log


Message #14 received at 77263 <at> debbugs.gnu.org (full text, mbox):

From: Stephen Gildea <stepheng+emacs <at> gildea.com>
To: 77263 <at> debbugs.gnu.org
Cc: Bill Wohler <wohler <at> newt.com>
Subject: Re: bug#77263: MH-E: want all folder buffers to use $HOME as
 default-directory
Date: Wed, 26 Mar 2025 09:22:29 -0700
Eli Zaretskii <eliz <at> gnu.org> wrote:

>   I wonder if calling cd-absolute here is really a good idea.  That
>   function could signal an error, and it insists on the directory being
>   an existing accessible directory.  Is it a good idea to potentially
>   screw up starting MH-E if the directory happens to be problematic?
>   Why not simply set the default-directory of the buffer instead?

I had not realized that 'cd-absolute' had issues when called
from Lisp.  Here is a revised version of my patch:


diff --git a/lisp/mh-e/mh-e.el b/lisp/mh-e/mh-e.el
index e507996c581..f64b02c7bca 100644
--- a/lisp/mh-e/mh-e.el
+++ b/lisp/mh-e/mh-e.el
@@ -144,6 +144,10 @@ mh-lib-progs
 ;;;###autoload
 (put 'mh-lib-progs 'risky-local-variable t)
 
+(defvar mh-default-directory "~/"
+  "Default directory for MH-E folder buffers.
+Set to nil to have MH-E buffers inherit default-directory.")
+
 ;; Profile Components
 
 (defvar mh-draft-folder nil
@@ -438,6 +442,12 @@ mh-list-to-string-1
              (error "Bad element: %s" element))))
     new-list))
 
+(defun mh-set-default-directory ()
+  "Set `default-directory' to `mh-default-directory' unless it is nil."
+  (when (stringp mh-default-directory)
+    (setq default-directory (file-name-as-directory
+                             (expand-file-name mh-default-directory)))))
+
 
 
 ;;; MH-E Process Support
diff --git a/lisp/mh-e/mh-folder.el b/lisp/mh-e/mh-folder.el
index 5009c2c4f98..e0c53724f9c 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)
+        (mh-set-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))
+      (mh-set-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))
+  (mh-set-default-directory))
 
 




This bug report was last modified 80 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.