Subject: bug#37456: 27.0.50; can't load .emacs file

From: Paul Eggert <[email-masked]>
Date: Thu, 19 Sep 2019 01:04:20 -0700

Thanks for the bug report. I installed the attached; please give it a try.
>From 6cc1d4bdf70d58e64f95daf1a871212aefa0e47e Mon Sep 17 00:00:00 2001
From: Paul Eggert <[email-masked]>
Date: Thu, 19 Sep 2019 00:59:59 -0700
Subject: [PATCH] Also prefer .emacs.d if .emacs exists

Problem reported by Katsumi Yamaoka (Bug#37456).
* lisp/startup.el (startup--xdg-or-homedot): Also
prefer .emacs.d if a traditional .emacs file exists.
---
 doc/lispref/os.texi | 3 ++-
 lisp/startup.el     | 9 ++++++++-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/doc/lispref/os.texi b/doc/lispref/os.texi
index c94e96bde8..ddbc8a8294 100644
--- a/doc/lispref/os.texi
+++ b/doc/lispref/os.texi
@@ -475,7 +475,8 @@ Init File
 @defvar user-emacs-directory
 This variable holds the name of the Emacs default directory.
 It defaults to @file{$@{XDG_CONFIG_HOME-'~/.config'@}/emacs/}
-if that directory exists and @file{~/.emacs.d/} does not exist,
+if that directory exists and @file{~/.emacs.d/} and @file{~/.emacs} do
+not exist,
 otherwise to @file{~/.emacs.d/} on all platforms but MS-DOS@.
 Here, @file{$@{XDG_CONFIG_HOME-'~/.config'@}}
 stands for the value of the environment variable @env{XDG_CONFIG_HOME}
diff --git a/lisp/startup.el b/lisp/startup.el
index ef6234128a..4078f23f3a 100644
--- a/lisp/startup.el
+++ b/lisp/startup.el
@@ -508,7 +508,14 @@ startup--xdg-or-homedot
 			       (if (eq system-type 'ms-dos)
 				   "/_emacs.d/"
 				 "/.emacs.d/"))))
-      (if (file-exists-p emacs-d-dir)
+      (if (or (file-exists-p emacs-d-dir)
+	      (if (eq system-type 'windows-nt)
+		  (directory-files (concat "~" user-name) nil
+				   "\\`[._]emacs\\(\\.elc?\\)?\\'")
+		(file-exists-p (concat "~" init-file-user
+				       (if (eq system-type 'ms-dos)
+					   "/_emacs"
+					 "/.emacs")))))
 	  emacs-d-dir
 	xdg-dir))))
 
-- 
2.17.1