From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Drew Adams" Newsgroups: gmane.emacs.help Subject: RE: Convenient way to set "root of my project"? Date: Thu, 29 Jan 2009 09:00:37 -0800 Message-ID: <011701c98233$1c3024f0$c2b22382@us.oracle.com> References: <43f72653-1412-4402-8074-ef5302ab07a0@35g2000pry.googlegroups.com> <3e60bfb0-80b8-44df-a95d-1ad8b2271722@p36g2000prp.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1233248816 22435 80.91.229.12 (29 Jan 2009 17:06:56 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 29 Jan 2009 17:06:56 +0000 (UTC) To: "'Brett Hoerner'" , Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Jan 29 18:08:10 2009 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1LSaMv-0006vp-Cl for geh-help-gnu-emacs@m.gmane.org; Thu, 29 Jan 2009 18:07:57 +0100 Original-Received: from localhost ([127.0.0.1]:52138 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LSaLc-0003LU-Rb for geh-help-gnu-emacs@m.gmane.org; Thu, 29 Jan 2009 12:06:37 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LSaFx-0007gX-3C for help-gnu-emacs@gnu.org; Thu, 29 Jan 2009 12:00:45 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LSaFu-0007fz-QY for help-gnu-emacs@gnu.org; Thu, 29 Jan 2009 12:00:44 -0500 Original-Received: from [199.232.76.173] (port=59260 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LSaFu-0007fq-Ak for help-gnu-emacs@gnu.org; Thu, 29 Jan 2009 12:00:42 -0500 Original-Received: from rcsinet12.oracle.com ([148.87.113.124]:34319 helo=rgminet12.oracle.com) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LSaFt-0005Wl-PW for help-gnu-emacs@gnu.org; Thu, 29 Jan 2009 12:00:41 -0500 Original-Received: from rgminet15.oracle.com (rcsinet15.oracle.com [148.87.113.117]) by rgminet12.oracle.com (Switch-3.3.1/Switch-3.3.1) with ESMTP id n0TH0D1Y022400 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 29 Jan 2009 17:00:14 GMT Original-Received: from acsmt707.oracle.com (acsmt707.oracle.com [141.146.40.85]) by rgminet15.oracle.com (Switch-3.3.1/Switch-3.3.1) with ESMTP id n0TH0ZIX015533; Thu, 29 Jan 2009 17:00:36 GMT Original-Received: from dradamslap1 (/130.35.178.194) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 29 Jan 2009 17:00:34 +0000 X-Mailer: Microsoft Office Outlook 11 In-Reply-To: <3e60bfb0-80b8-44df-a95d-1ad8b2271722@p36g2000prp.googlegroups.com> Thread-Index: AcmB18DWOMGDdO5zTOWuBeVfEnzenAAWYJuA X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3350 X-Source-IP: acsmt707.oracle.com [141.146.40.85] X-Auth-Type: Internal IP X-CT-RefId: str=0001.0A09020B.4981E0B4.01AD:SCFSTAT928724,ss=1,fgs=0 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 1) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:61760 Archived-At: > > 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.