From 502e861af75e32152346f17f034c92a0550ccea3 Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Sat, 25 Jun 2022 17:28:12 +0200 Subject: [PATCH] Don't create HOME if it doesn't exist * lisp/files.el (locate-user-emacs-file): Don't create HOME if it doesn't exist (bug#47298). This returns us to Emacs 26.3 behaviour here. --- lisp/files.el | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/lisp/files.el b/lisp/files.el index a804f0088ee..cc38f4e921f 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -1115,10 +1115,17 @@ directory if it does not exist." (if (file-directory-p user-emacs-directory) (or (file-accessible-directory-p user-emacs-directory) (setq errtype "access")) - (with-file-modes ?\700 - (condition-case nil - (make-directory user-emacs-directory t) - (error (setq errtype "create"))))) + ;; We don't want to create HOME if it doesn't exist. + (if (and (not (file-exists-p "~")) + (string-prefix-p + (expand-file-name "~") + (expand-file-name user-emacs-directory))) + (setq errtype "create") + ;; Create `user-emacs-directory'. + (with-file-modes ?\700 + (condition-case nil + (make-directory user-emacs-directory t) + (error (setq errtype "create")))))) (when (and errtype user-emacs-directory-warning (not (get 'user-emacs-directory-warning 'this-session))) -- 2.39.5