emacs-devel
[Top][All Lists]
Advanced

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

Re: A unified project root interface


From: Sudish Joseph
Subject: Re: A unified project root interface
Date: Tue, 12 Mar 2013 11:34:05 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2.93 (darwin)

Using .dir-locals as the definition of a project is eminently
reasonable, but it'd be good if projects and their roots could also be
computed dynamically or definitely implicitly from the context of an
action.

Computable roots:

- VC root directories define the most natural project roots in many
  cases.  This is by far the common case for me: look for the .git/
  directory.
- File and directory existence checks.  Rails projects contain these
  directories at their root: app, config, db.  Perl used to contain t
  and lib, though it's been a while.

It'd be good if Emacs didn't require or even write any context of its
own into these directories like most IDEs do - there's no reason to.

Implicit roots:

- Emacsclient should generate an implicit project root if given a
  directory as an argument.
- Drag and drop a directory into Emacs. This used to be one of
  Textmate's killer features - easy project creation.

Emacs doesn't need to define all this, just provide standard hooks to
let the user or external packages define this.  What would be great
would be if the grep interfaces and such could look for and use project
roots if one is found.

Here's the definition of projects I'm using right now:

(setq project-roots
      `(("Rails Project"
         :root-contains-files ("app" "config" "db" "lib" "script" "test")
         :on-hit (lambda (p) (message (car p))))
        ("Emacs config"
         :path-matches ,(format "\\(%s\\)" sj/emacs-base-dir)
         :on-hit (lambda (p) (message (car p))))
        ("Perl Project"
         :root-contains-files ("t" "lib")
         :on-hit (lambda (p) (message (car p))))
        ("Git Project"
         :root-contains-files (".git")
         :on-hit (lambda (p) (message (car p))))))

That's for project-root.el - selected because it was the only one I
found at the time.

The default .git rule turns out to be the most useful and catches most
projects.

Here's an example of a package that groups buffers by vc root that could
do an even better job with a standardized project interface in Emacs
itself: https://github.com/purcell/ibuffer-vc

Cheers,
-Sudish



reply via email to

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