[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: |
Wed, 13 Mar 2013 15:11:37 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3 (darwin) |
David Engster <address@hidden> writes:
> You can create a project like this with ede-generic, but then you have
> to write a little defclass inheriting from ede-generic, call
> ede-generic-new-autoloader, and to actually *do* something when the
> project is loaded you have to define methods like
> `ede-generic-setup-configuration'. This is just too much boilerplate for
> such a simple thing like the above. Also, even most Emacs developers are
> not familiar with the CLOS-like syntax that's needed to define those
> things.
>
> There's no doubt that EDE can do all what's needed, but is has to be
> wrapped in something that's easier to use, at least for simple stuff
> like what project-roots.el does.
The simplest - and for me, only - use is to ask a buffer which project
it belongs to, if any. Everything else in my usage can be derived from
that. This is how vc works, too, I think, and ibuffer-vc can aggregate
buffers by vc-roots handily.
Buffers and buffer-locals provide a simple and emacsy form of extensible
object and attributes, so if there's more data associated with a project
it'd be nice to expose them as such as opposed or in addition to having
a dedicated project api. This fits with .dir-locals as well.
Most project convenience functions I need turn out to be general
directory and file functions. For e.g., "all files in current project"
could be as simple as
(all-files-in project-root)
where the former is generic functionality and the latter is a buffer
local.
-Sudish
PS: Some more examples of how I find having a simple buffer-local
project-root handy - I use these every day:
;; project-details is a buffer-local of
;; (matching-rule-name . project-root-dir)
(defun sj/project-root-dir ()
(when (project-root-fetch)
(cdr project-details)))
;; this auto-restricts recursive ack searches to current project, where
;; project is defined dynamically - vc roots, etc.
(setq ack-mode-root-directory-function 'sj/project-root-dir)
;; A couple of anything.el sources that automatically use the current
;; buffer's project root
;; Files from current project root, if any
(defconst sj/anything-source-project-root-files
'((name . "Project Files")
(init . (lambda ()
(setq anything-project-root project-details)))
(candidates . (lambda ()
(project-root-file-find-process anything-pattern)))
(candidate-transformer . sj/anything-file-candidate-filter)
(requires-pattern . 2)
(volatile)
(type . file)))
;; A source that's aware of the MVC structure of a Rails project.
(defconst sj/anything-rails-files
'((name . "Rails")
(init . (lambda ()
(setq anything-project-root project-details)))
(candidates . (lambda ()
(when (equal "Rails Project" (car anything-project-root))
(rails-list-project-files (cdr anything-project-root)))))
(type . file)))
- A unified project root interface, Jorgen Schaefer, 2013/03/09
- Re: A unified project root interface, Fabian Ezequiel Gallina, 2013/03/09
- Re: A unified project root interface, Stefan Monnier, 2013/03/10
- Re: A unified project root interface, Jorgen Schaefer, 2013/03/10
- Re: A unified project root interface, LluĂs, 2013/03/11
- Re: A unified project root interface, David Engster, 2013/03/13
- Re: A unified project root interface,
Sudish Joseph <=
- Re: A unified project root interface, Eric M. Ludlam, 2013/03/15
- Re: A unified project root interface, David Engster, 2013/03/16
- Re: A unified project root interface, Jorgen Schaefer, 2013/03/16
- Re: A unified project root interface, David Engster, 2013/03/16
- Re: A unified project root interface, Jorgen Schaefer, 2013/03/16
- Re: A unified project root interface, David Engster, 2013/03/17
- Re: A unified project root interface, Jorgen Schaefer, 2013/03/17
- Re: A unified project root interface, David Engster, 2013/03/18
- Re: A unified project root interface, John Yates, 2013/03/18
- Re: A unified project root interface, David Engster, 2013/03/19