From: Sudish Joseph <sudish@gmail.com>
To: emacs-devel@gnu.org
Subject: Re: A unified project root interface
Date: Wed, 13 Mar 2013 15:11:37 -0400 [thread overview]
Message-ID: <m1ip4vglna.fsf@gmail.com> (raw)
In-Reply-To: <87vc8vyy66.fsf@engster.org> (David Engster's message of "Wed, 13 Mar 2013 19:03:45 +0100")
David Engster <deng@randomsample.de> 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)))
next prev parent reply other threads:[~2013-03-13 19:11 UTC|newest]
Thread overview: 62+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-09 16:44 A unified project root interface Jorgen Schaefer
2013-03-09 17:12 ` Fabian Ezequiel Gallina
2013-03-10 5:38 ` Stefan Monnier
2013-03-10 10:06 ` Jorgen Schaefer
2013-03-11 18:57 ` Lluís
2013-03-12 23:28 ` Eric M. Ludlam
2013-03-12 23:42 ` Jorgen Schaefer
2013-03-13 2:02 ` Eric M. Ludlam
2013-03-13 18:03 ` David Engster
2013-03-13 19:11 ` Sudish Joseph [this message]
2013-03-16 0:47 ` Eric M. Ludlam
2013-03-16 14:18 ` David Engster
2013-03-16 15:02 ` Jorgen Schaefer
2013-03-16 22:27 ` Phil Hagelberg
2013-03-16 22:59 ` David Engster
2013-03-16 23:16 ` Jorgen Schaefer
2013-03-17 17:40 ` David Engster
2013-03-17 18:18 ` Jorgen Schaefer
2013-03-18 22:50 ` David Engster
2013-03-19 1:57 ` John Yates
2013-03-19 7:18 ` David Engster
2013-03-19 12:23 ` Eric M. Ludlam
2013-03-19 13:06 ` Stefan Monnier
2013-03-19 19:09 ` David Engster
2013-03-20 3:21 ` Stefan Monnier
2013-03-20 4:48 ` Leo Liu
2013-03-20 7:04 ` joakim
2013-03-20 7:05 ` David Engster
2013-03-20 7:13 ` David Engster
2013-03-20 12:57 ` Stefan Monnier
2013-03-20 16:14 ` Davis Herring
2013-03-20 17:41 ` Stefan Monnier
2013-03-20 17:48 ` Stefan Monnier
2013-03-20 18:20 ` Bruce Korb
2013-03-20 22:14 ` Stefan Monnier
2013-03-20 16:34 ` David Engster
2013-03-20 17:47 ` Stefan Monnier
2013-03-21 0:55 ` Eric M. Ludlam
2013-03-21 3:27 ` Stefan Monnier
2013-03-21 4:07 ` Eric M. Ludlam
2013-03-21 14:33 ` Stefan Monnier
2013-03-22 2:12 ` Eric M. Ludlam
2013-03-23 11:04 ` EIEIO split (was: A unified project root interface) David Engster
2013-03-21 16:32 ` A unified project root interface David Engster
2013-03-22 0:47 ` Eric M. Ludlam
2013-03-22 20:30 ` David Engster
2013-03-23 17:10 ` Eric M. Ludlam
2013-03-23 17:26 ` Jorgen Schaefer
2013-03-23 18:02 ` Dmitry Gutov
2013-03-23 20:51 ` Pascal J. Bourguignon
2013-03-24 4:25 ` Dmitry Gutov
2013-03-24 10:13 ` Jorgen Schaefer
2013-04-06 13:25 ` Jorgen Schaefer
2013-04-06 17:13 ` Eric M. Ludlam
2013-04-08 19:03 ` David Engster
2013-12-31 20:12 ` Daniel Colascione
2013-03-20 17:49 ` Jorgen Schaefer
2013-03-19 7:33 ` Jorgen Schaefer
2013-03-17 8:08 ` joakim
2013-03-12 15:34 ` Sudish Joseph
2013-03-12 16:51 ` Dmitry Gutov
2013-03-12 18:23 ` Ted Zlatanov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m1ip4vglna.fsf@gmail.com \
--to=sudish@gmail.com \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.