[Top][All Lists]

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

Re: A unified project root interface

From: Jorgen Schaefer
Subject: Re: A unified project root interface
Date: Sun, 10 Mar 2013 11:06:42 +0100

On Sun, 10 Mar 2013 00:38:12 -0500
Stefan Monnier <address@hidden> wrote:

> > So this is my somewhat verbose request to say "yes, let's do this"
> > and pick a library to provide the functionality.
> Agreed.
> [...]
> If the only need is to figure out the "root directory of the project",

That is I think the minimum requirement, yes.

> then maybe a simple solution is:
>    (defvar project-root-predicate
>        (lambda () (file-exists-p ".dir-locals.el")))
>    (defun project-root ()
>      (locate-dominating-file default-directory
> project-root-predicate))
> where packages can (add-function :until-before (default-value
> project-root-predicate) <mypredicate>) to recognize other "tell tale
> sign" of a project root (e.g. a Tupfile).

This would indeed be the minimal set to help with the problem. I think
it's a bit *too* minimal, because it fails for most common cases, i.e.
those where the project root is not defined yet. Every package trying
to use it will need to extend it with some way to define or set the
project root before this code can be used at all. The project.el files I
linked to (and most projects) by default look for VCS markers to find
the project root if nothing else is specified. This might be trivial
enough to add by default, too.

The only added functionality of the project.el files I linked to is
that they allow the user to override the project root (using M-x
project-set-root), which in turn makes it worthwhile to have the
project root as a buffer-local variable.

        -- Jorgen

reply via email to

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