[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: Scott Frazer
Subject: Re: Convenient way to set "root of my project"?
Date: Wed, 28 Jan 2009 16:24:36 -0500
User-agent: Thunderbird (Windows/20081209)

Brett Hoerner wrote:
On Jan 28, 1:11 am, "Drew Adams" <address@hidden> 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'.


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

This might be close:

(defvar my-default-directory-roots (list "/foo/bar"
  "Default directory roots")

(defun my-set-default-directory-hook ()
  (mapc (lambda (root)
          (when (string-match (concat "^" root) (buffer-file-name))
            (setq default-directory root)))

(add-hook 'find-file-hook 'my-set-default-directory-hook)

reply via email to

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