views:

1163

answers:

3

I have seen a few suggestions on making emacs portable (on Windows). I have this in my site-start.el:

(defvar program-dir (substring data-directory 0 -4))

(setq inhibit-startup-message t)
(setenv "HOME" program-dir)

I changed the HOME variable so that not only my .emacs init files (and other init files) are read, but everything generated by emacs will stay in the program directory, not needing me to specify the path for everything one by one.

Well this works well but the emacs server is not working; I get error message "no connection could be made because target machine actively refused it." If I don't change my HOME var then emacs server works. Is there way to fix this?

+5  A: 

Quoth the Emacs manual:

When you start the Emacs server (by calling server-start), Emacs creates a file with information about TCP connection to the server: the host where Emacs is running, the port where it is listening, and an authentication string. emacsclient uses this information if it needs to connect to the server via TCP. By default, the file goes in the ~/.emacs.d/server/ directory. You can specify the file name to use with the `-f file' or `--server-file=file' options, or by setting EMACS_SERVER_FILE environment variable to the file name.

In other words: wherever you're calling emacsclient from, you'll have to tell it to use the file in ${program-dir}/.emacs.d/server/, either with -f or setting the EMACS_SERVER_FILE environment variable. (In the environment in which you're starting emacsclient, not within Emacs.)
[You could also tell Emacsclient to look in the right place with -s for "socket", but that doesn't work on Windows. And on Unixes (at least on Mac OS X with Aquamacs) the socket would be somewhere like /tmp/emacs501/server (501 is my UID).]

[Oh, BTW, take a look at this question: How can I have a portable Emacs? Maybe something will help you, or maybe you have something to add to it :-)]

ShreevatsaR
+1  A: 

Wow that works! Can't believe that I haven't try that before! (btw I did see the other question but that does not solve my problem and I don't have much to add ;) )

EDIT: Just saw the edit above ;) I actually started emacsclientw (did not try on the console version though) with -f "server-file-path", AND it works!

polyglot
A: 

There is an initial packaging of a Portable Apps version of emacs 23.2 here. Initial test works here.

ScoBe