From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Scott Frazer Newsgroups: gmane.emacs.help Subject: Re: Convenient way to set "root of my project"? Date: Wed, 28 Jan 2009 16:24:36 -0500 Organization: Ye 'Ol Disorganized NNTPCache groupie Message-ID: <1233177877.97608@sj-nntpcache-3.cisco.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=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1233178933 12132 80.91.229.12 (28 Jan 2009 21:42:13 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 28 Jan 2009 21:42:13 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Jan 28 22:43:26 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 1LSIBw-0007VN-8w for geh-help-gnu-emacs@m.gmane.org; Wed, 28 Jan 2009 22:43:24 +0100 Original-Received: from localhost ([127.0.0.1]:42886 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LSIAe-0006gl-4d for geh-help-gnu-emacs@m.gmane.org; Wed, 28 Jan 2009 16:42:04 -0500 Original-Path: news.stanford.edu!newsfeed.stanford.edu!postnews.google.com!news1.google.com!npeer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post02.iad.highwinds-media.com!newsfe25.iad.POSTED!7564ea0f!not-for-mail User-Agent: Thunderbird 2.0.0.19 (Windows/20081209) Original-Newsgroups: gnu.emacs.help In-Reply-To: <3e60bfb0-80b8-44df-a95d-1ad8b2271722@p36g2000prp.googlegroups.com> Cache-Post-Path: sj-nntpcache-3.cisco.com!unknown@scfrazer-wxp.cisco.com X-Cache: nntpcache 3.0.2 (see http://www.nntpcache.com/) Original-Lines: 27 Original-X-Complaints-To: newsadmin@cisco.com Original-NNTP-Posting-Date: Wed, 28 Jan 2009 21:24:37 UTC Original-Xref: news.stanford.edu gnu.emacs.help:166423 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:61739 Archived-At: Brett Hoerner wrote: > On Jan 28, 1:11 am, "Drew Adams" wrote: >> 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. I'm very new to all of this, 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/' This might be close: (defvar my-default-directory-roots (list "/foo/bar" "/baz/quux") "Default directory roots") (defun my-set-default-directory-hook () (mapc (lambda (root) (when (string-match (concat "^" root) (buffer-file-name)) (setq default-directory root))) my-default-directory-roots)) (add-hook 'find-file-hook 'my-set-default-directory-hook)