Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to specify path to .emacs.d

77 views
Skip to first unread message

Barry OReilly

unread,
Oct 29, 2012, 4:37:51 PM10/29/12
to help-gnu-emacs
Hi,
I'd like to know how to specify at the command line which directory Emacs should use as the .emacs.d directory.  I see the --user flag, but it seems unnecessarily inflexible.

One use case I would like this for is so as I can run Emacs unintrusively on a colleague's computer.  --user flag doesn't serve the purpose for technical reasons and I currently symlink their ~/.emacs.d to my .emacs.d on a network share.  For my colleagues who also use Emacs, this creates an awkwardness whereby I backup their .emacs.d before creating my symlink, and then remember to restore it later when finished.

Another use case is that I'm getting my Emacs configuration to work on Windows, and I discovered that Windows shortcuts are apparently .lnk files and don't function like a symlink.  I'm unsure how to use a .emacs.d at an arbitrary location, and only know to copy it to home instead.  This is inconvenient because I want to use a .emacs.d straight out of a Mercurial repo located elsewhere.

Specifying a .emacs.d location as a command line flag would be a big help.

Peter Dyballa

unread,
Oct 29, 2012, 6:27:36 PM10/29/12
to Barry OReilly, help-gnu-emacs

Am 29.10.2012 um 21:37 schrieb Barry OReilly:

> Specifying a .emacs.d location as a command line flag would be a big help.

Do you need that path for GNU Emacs that it finds some Elisp files? The environment variable EMACSLOADPATH can point to additional directories. This variable matches the use of the GNU Emacs variable load-path. This one can be changed in some init file, for example when the user is someone particular…

--
Greetings

Pete

Think of XML as Lisp for COBOL programmers.
- Tony-A (some guy on /.)


Nicolas Richard

unread,
Oct 30, 2012, 5:46:43 AM10/30/12
to help-gn...@gnu.org
Barry OReilly <gunda...@gmail.com> writes:
> Specifying a .emacs.d location as a command line flag would be a big
> help.

You could use apropos-value to list all variables which refer to
.emacs.d and then modify those from command line using --eval (although
sometimes that directory is hardcoded, e.g. in startup.el as a fallback
value). In particular, user-emacs-directory is of interest, and I'd
trying changing it, then run apropos-value to see what remains.

--
Nico.


Peter Münster

unread,
Oct 30, 2012, 9:30:49 AM10/30/12
to help-gn...@gnu.org
On Tue, Oct 30 2012, Nicolas Richard wrote:

> modify those from command line using --eval

That's too late...

--
Peter


Jambunathan K

unread,
Oct 30, 2012, 10:44:48 AM10/30/12
to Nicolas Richard, help-gn...@gnu.org
`user-emacs-directory' is a defconst.
--

Evan Driscoll

unread,
Oct 30, 2012, 12:09:24 PM10/30/12
to Barry OReilly, help-gnu-emacs
On 10/29/2012 03:37 PM, Barry OReilly wrote:
> Another use case is that I'm getting my Emacs configuration to work on
> Windows, and I discovered that Windows shortcuts are apparently .lnk
> files and don't function like a symlink. I'm unsure how to use a
> .emacs.d at an arbitrary location, and only know to copy it to home
> instead. This is inconvenient because I want to use a .emacs.d straight
> out of a Mercurial repo located elsewhere.

I can't help with the Emacs part of your question, but Vista and higher
have true (though still a bit brain dead in some respects) symlinks.
Look at the 'mklink' command.

You'll need a privilege that isn't granted to users by default (silly
decision #1), and while you can change that, for a one-off thing it's
easier to just elevate yourself when opening the command prompt. Also
note that Windows symlinks are specific to either pointing to a file or
a directory, so you'll have to explicitly tell 'mklink' that you want a
directory symlink.


On XP and 2000 (and also Vista and higher) you also have both hard links
and something called "directory junctions" available. (Windows is
capable of creating hard links to directories. Presumably you have to be
careful not to shoot yourself in the foot by creating a cycle.) I think
'mklink' may create hard links too though I'm not sure; for directory
junctions, there are a couple third-party utilities, e.g. Mark
Russinovich's 'junction':
http://technet.microsoft.com/en-us/sysinternals/bb896768.aspx

Evan


signature.asc

Barry OReilly

unread,
Oct 30, 2012, 6:53:02 PM10/30/12
to help-gnu-emacs
>"Nicolas Richard" <address@hidden> writes:

>
>> Barry OReilly <address@hidden> writes:
>>> Specifying a .emacs.d location as a command line flag would be a big
>>> help.
>>
>> You could use apropos-value to list all variables which refer to
>> .emacs.d and then modify those from command line using --eval (although
>> sometimes that directory is hardcoded, e.g. in startup.el as a fallback
>> value). In particular, user-emacs-directory is of interest, and I'd
>> trying changing it, then run apropos-value to see what remains.
>
>`user-emacs-directory' is a defconst.

I removed ~/.emacs.d, verified no ~/.emacs, executed:
   emacs --eval '(setq user-emacs-directory "my/path/.emacs.d/")'

It did not work.  More precisely, Emacs did not load my/path/.emacs.d/init.el .  C-h v does show that user-emacs-directory has the /my/path/.emacs.d value, however.


Stefan Monnier

unread,
Oct 30, 2012, 8:51:53 PM10/30/12
to
> emacs --eval '(setq user-emacs-directory "my/path/.emacs.d/")'

The --eval argument is executed after reading your .emacs (or
.emacs.d/init.el) file, so clearly that won't work.

> C-h v does show that user-emacs-directory has the /my/path/.emacs.d
> value, however.

Yes, but only later when you do C-h v, not while trying to load the
.emacs file.


Stefan

Nicolas Richard

unread,
Oct 31, 2012, 6:26:00 AM10/31/12
to help-gn...@gnu.org

Barry OReilly <gunda...@gmail.com> writes:
> It did not work.  More precisely, Emacs did not load my/path/.emacs.d
> /init.el .  C-h v does show that user-emacs-directory has the /my/
> path/.emacs.d value, however.

Ok, I had not quite understood what you wanted to do. My suggestion
would then be to run emacs as:
emacs -q --eval '(setq user-emacs-directory "~/.my.other.emacs.d")' --eval '(load (concat user-emacs-directory "/init.el"))'

It is far from optimal but maybe it can work for you.

--
Nicolas.


0 new messages