unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH] for review - Allow expansion of "~" (as opposed to "~user")
@ 2015-02-28  0:06 Pete Williamson
  2015-02-28  8:08 ` Eli Zaretskii
  0 siblings, 1 reply; 15+ messages in thread
From: Pete Williamson @ 2015-02-28  0:06 UTC (permalink / raw)
  To: emacs-devel


[-- Attachment #1.1: Type: text/plain, Size: 978 bytes --]

I'm porting Emacs to run on NaCl (Chrome Native Client) and the Chromebook.
 (You can see slides about this in the FOSDEM 2015 archives).

The NaCl platform does not support expanding the "~user" syntax for
filenames (where user is the name of the logged in user), but it does
support expanding "~" in filenames when looking for the init.el file.

I've made a patch to startup.el to check in "~" for .emacs.d/init.el if it
is not found in "~user".  Is taking this patch a good idea?  I'm not sure
how much emacs should adapt to the platform, and how much should be done in
a private patch that does not affect other platforms, and I would be
grateful for any guidance.

Currently for the NaCl port, we have a patch in naclports which does OS
specific fixes, and I can leave this patch in naclports if that is thought
by others to be a better place, or I would be happy to contribute it back
to Gnu if it is seen as generally useful.

All comments on the patch welcome.

Thanks!

[-- Attachment #1.2: Type: text/html, Size: 1175 bytes --]

[-- Attachment #2: 0001-Allow-expansion-of-bare-tilde-when-looking-for-.emac.patch --]
[-- Type: text/x-patch, Size: 2297 bytes --]

From 05f9b47226f2653c88818d22f9ec81c59ad53c55 Mon Sep 17 00:00:00 2001
From: Pete Williamson <petewil@chromium.org>
Date: Fri, 27 Feb 2015 15:47:34 -0800
Subject: [PATCH] Allow expansion of bare tilde when looking for .emacs file

On some systems, the shortcut "~user" is not expanded properly, but "~" is.
So, I added code in startup.el to check first for ~user/.emacs.d/init.el,
and if that is not found, to then try ~/.emacs.d/init.el.
---
 ChangeLog       |  6 ++++++
 lisp/startup.el | 16 ++++++++++++----
 2 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 0bfdfbb..243dd4b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2015-02-27 Pete Williamson <petewil@chromium.org>
+
+	To find the .emacs file, check both ~user/.emacs.d and ~/.emacs.d
+	* lisp/startup.el: If The system does not support expanding ~user,
+	try expanding ~ when looking for the .emacs.d/init.el file.
+
 2015-02-27  Paul Eggert  <eggert@cs.ucla.edu>
 
 	Don't require GNU putenv
diff --git a/lisp/startup.el b/lisp/startup.el
index 999e53e..c0d6059 100644
--- a/lisp/startup.el
+++ b/lisp/startup.el
@@ -1105,14 +1105,22 @@ please check its value")
 		      (load user-init-file-1 t t)
 
 		      (when (eq user-init-file t)
-			;; If we did not find ~/.emacs, try
-			;; ~/.emacs.d/init.el.
+			;; If we did not find ~<user>/.emacs or ~/.emacs, try
+			;; ~<user>/.emacs.d/init.el or ~/.emacs.d/init.el
 			(let ((otherfile
 			       (expand-file-name
 				"init"
 				(file-name-as-directory
-				 (concat "~" init-file-user "/.emacs.d")))))
-			  (load otherfile t t)
+				 (concat "~" init-file-user "/.emacs.d"))))
+                              ;; Generate a filename for ~/.emacs.d/init.el.
+                              (otherfile-tilde-only
+                               (expand-file-name
+                                "init"
+                                (file-name-as-directory "~/.emacs.d"))))
+			  (when (nilp (load otherfile t t))
+                            ;; If ~<user>/.emacs.d/init.el was not found, try
+                            ;; ~/.emacs.d/init.el
+                            (load otherfile-tilde-only t t))
 
 			  ;; If we did not find the user's init file,
 			  ;; set user-init-file conclusively.
-- 
2.2.0.rc0.207.ga3a616c


^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2015-03-04 18:06 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-28  0:06 [PATCH] for review - Allow expansion of "~" (as opposed to "~user") Pete Williamson
2015-02-28  8:08 ` Eli Zaretskii
2015-03-02  9:44   ` Michal Nazarewicz
2015-03-02 13:50     ` Eli Zaretskii
2015-03-02 20:37       ` Michal Nazarewicz
2015-03-03 15:37         ` Eli Zaretskii
2015-03-03 17:48           ` Michal Nazarewicz
2015-03-03 18:09             ` Eli Zaretskii
2015-03-03 18:20               ` Eli Zaretskii
2015-03-03 18:22                 ` Pete Williamson
2015-03-03 18:36                   ` Eli Zaretskii
2015-03-03 18:38                     ` Pete Williamson
2015-03-03 21:01                       ` Michal Nazarewicz
2015-03-03 21:03               ` Michal Nazarewicz
2015-03-04 18:06                 ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).