From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Sudish Joseph Newsgroups: gmane.emacs.devel Subject: Re: A unified project root interface Date: Wed, 13 Mar 2013 15:11:37 -0400 Message-ID: References: <20130309174419.6e1cadb4@forcix.kollektiv-hamburg.de> <87hakh2299.fsf@fimbulvetr.bsc.es> <513FBA1C.5040100@siege-engine.com> <87vc8vyy66.fsf@engster.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1363201917 25923 80.91.229.3 (13 Mar 2013 19:11:57 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 13 Mar 2013 19:11:57 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Mar 13 20:12:18 2013 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UFr61-0002tE-OY for ged-emacs-devel@m.gmane.org; Wed, 13 Mar 2013 20:12:17 +0100 Original-Received: from localhost ([::1]:60815 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UFr5f-0002Pp-2J for ged-emacs-devel@m.gmane.org; Wed, 13 Mar 2013 15:11:55 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:53026) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UFr5Z-0002P0-FQ for emacs-devel@gnu.org; Wed, 13 Mar 2013 15:11:52 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UFr5R-00035m-P8 for emacs-devel@gnu.org; Wed, 13 Mar 2013 15:11:49 -0400 Original-Received: from mail-yh0-x231.google.com ([2607:f8b0:4002:c01::231]:52582) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UFr5R-00035X-LZ for emacs-devel@gnu.org; Wed, 13 Mar 2013 15:11:41 -0400 Original-Received: by mail-yh0-f49.google.com with SMTP id m1so239675yhg.36 for ; Wed, 13 Mar 2013 12:11:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; bh=qaQ3JNsSWu8arW/8f2ZSVAeQNbHQeMt/i6olUbU0sM4=; b=ntOlOhZRVxaqWAuPk4/xFQ1ZtfyDew/bfnNq/6sE0opD+DRf24o7vLjEDq0evXcwtN 3Q3Qfbew3/kqbRxABeea7ORXulUpZ/ujG2fjOHJ+cOvUjNrD0orNl8vlrGSMzvelW2zm 9mc33ZDVWhwMBMNR6uIsCx3Zyi5AMbNTeiOLEZiwDkgzyOnF55lj9oLDLeU7usliG5gi LL9YJ88VtXmIENKZY4Qn9LVGuZZZR5LIZGaWKE/IjC3o5sdE65aog+hUuB41qIP3XZWx KIybgjmlWhgw/lGU5fH4IFKDFi3chDAFltEcuBKPU2lTUV+R1SfpfBNzJwA6ue5cG2+q H0hQ== X-Received: by 10.236.125.77 with SMTP id y53mr17071356yhh.14.1363201901008; Wed, 13 Mar 2013 12:11:41 -0700 (PDT) Original-Received: from barca (c-71-56-113-161.hsd1.ga.comcast.net. [71.56.113.161]) by mx.google.com with ESMTPS id u41sm37086738yhb.20.2013.03.13.12.11.38 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 13 Mar 2013 12:11:39 -0700 (PDT) In-Reply-To: <87vc8vyy66.fsf@engster.org> (David Engster's message of "Wed, 13 Mar 2013 19:03:45 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (darwin) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:4002:c01::231 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:157822 Archived-At: David Engster 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)))