resetting xemacs' idea of home directory

Glynn Clements glynn at gclements.plus.com
Sat Apr 26 21:34:52 EDT 2008


Tim Connors wrote:

> I want to reset a running xemacs' idea of where my $HOME directory is (I 
> want to temporarily work in a different filesystem with my main xemacs 
> process) so that when I open a file in ~/thesis/..., it goes to 
> <directory>/thesis/....
> 
> (setenv "HOME" ...) didn't do what I was hoping it would do (obviously it 
> would for subshells).  Is there a way?

Not easily. XEmacs caches the result of getenv("HOME"), and there
isn't any way to un-cache it from lisp. Also, the variable which
stores the home directory isn't a lisp variable, so you can't just set
or bind it.

You could modify e.g. find-file-noselect (e.g. with defadvice) to
detect a filename beginning with "~/" and substitute your alternate
home directory.

You could even intercept expand-file-name if you want the change to
affect everything. However, that will get a bit messy, as
expand-file-name is a built-in function, so you can't use defadvice,
and if you want to override the definition, you'll need to store
(symbol-function 'expand-file-name) somewhere so that you can call it
from your wrapper.

-- 
Glynn Clements <glynn at gclements.plus.com>



More information about the XEmacs-Beta mailing list