From: "Drew Adams" <drew.adams@oracle.com>
To: "'Brett Hoerner'" <bretthoerner@gmail.com>, <help-gnu-emacs@gnu.org>
Subject: RE: Convenient way to set "root of my project"?
Date: Thu, 29 Jan 2009 09:00:37 -0800 [thread overview]
Message-ID: <011701c98233$1c3024f0$c2b22382@us.oracle.com> (raw)
In-Reply-To: <3e60bfb0-80b8-44df-a95d-1ad8b2271722@p36g2000prp.googlegroups.com>
> > 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.
prev parent reply other threads:[~2009-01-29 17:00 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-01-27 22:13 Convenient way to set "root of my project"? Brett Hoerner
2009-01-28 7:11 ` Drew Adams
2009-01-28 7:49 ` Thierry Volpiatto
2009-01-28 7:57 ` Kevin Rodgers
2009-01-28 9:03 ` Andreas Politz
2009-01-28 10:57 ` Peter Dyballa
[not found] ` <mailman.6052.1233129460.26697.help-gnu-emacs@gnu.org>
2009-01-28 15:22 ` Brett Hoerner
[not found] ` <mailman.6072.1233140265.26697.help-gnu-emacs@gnu.org>
2009-01-28 15:24 ` Brett Hoerner
[not found] ` <mailman.6047.1233126709.26697.help-gnu-emacs@gnu.org>
2009-01-28 15:25 ` Brett Hoerner
2009-01-28 21:24 ` Scott Frazer
2009-01-29 17:00 ` Drew Adams [this message]
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='011701c98233$1c3024f0$c2b22382@us.oracle.com' \
--to=drew.adams@oracle.com \
--cc=bretthoerner@gmail.com \
--cc=help-gnu-emacs@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.