all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Pete Williamson <petewil@google.com>
To: emacs-devel@gnu.org
Subject: [PATCH] for review - Allow expansion of "~" (as opposed to "~user")
Date: Fri, 27 Feb 2015 16:06:02 -0800	[thread overview]
Message-ID: <CAHsSLHA8R80TC1DUjETkaG=9OcOvCfV95T0aixsRu7k+Ep4TJg@mail.gmail.com> (raw)


[-- 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


             reply	other threads:[~2015-02-28  0:06 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-28  0:06 Pete Williamson [this message]
2015-02-28  8:08 ` [PATCH] for review - Allow expansion of "~" (as opposed to "~user") 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAHsSLHA8R80TC1DUjETkaG=9OcOvCfV95T0aixsRu7k+Ep4TJg@mail.gmail.com' \
    --to=petewil@google.com \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.