[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Convenient way to set "root of my project"?

From: Drew Adams
Subject: RE: Convenient way to set "root of my project"?
Date: Thu, 29 Jan 2009 09:00:37 -0800

> > Sounds similar to the recent thread "build a macro that 
> > opens a directory and prompts for file name" - see that
> > for suggestions. In particular, see Emacs
> > command `cd' and variable `default-directory'.
> Thanks!
> I had used 'cd' by hand in the past, but 'default-directory' looks
> like what I want.

`cd' just sets the value of `default-directory'.

But from your other mail, it sounds like you want to set `default-directory'
_automatically_ to some "project" directory, whenever you visit a file that is
under that directory.

> I just need to find a way now to hook the opening of a file, detect
> if it matches a path like '/a/NAME/src/.*' and set the default
> directory of that buffer to '/a/NAME/src/'

Perhaps take a look at `find-file-hooks'. You could add a function there that
checks the current `default-directory' value (for the visited file), and, if it
is underneath your "project" directory, then set `default-directory' to the
"project" directory instead. Not sure if the timing of running the hook will be
right - you'll have to check.

But watch out. If you do that, then the directory associated with that file
buffer will be the project directory, not the file's own directory (underneath
the proj dir). I don't think that's what you want - it will affect saving the
buffer etc.

It's not clear to me exactly what you want/need. My guess is that it would be
better to just have a Dired buffer open for your project directory. Perhaps
someone else has a better understanding of what you want, and can help.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]