all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Dmitry Gutov <dgutov@yandex.ru>
To: Stephen Leake <stephen_leake@stephe-leake.org>, emacs-devel@gnu.org
Subject: Re: Unified project interface
Date: Wed, 10 Jun 2015 01:31:59 +0300	[thread overview]
Message-ID: <5577695F.70800@yandex.ru> (raw)
In-Reply-To: <85zj4barkf.fsf@stephe-leake.org>

On 06/08/2015 04:59 AM, Stephen Leake wrote:

> The user; they are the only ones that know what "the project" is.

Let's cut out the user out of the discussion and just say that the 
project system knows stuff. Because it can know everything we want to 
ask the user; we just need to figure out the right set of questions.

>> Will a project-backend "source directories" implementation
>> always cl-call-next-method?
>
> I don't understand this.

If project-source-directories is a generic method, maybe we can say that 
its implementation should almost always (unless it really knows what 
it's doing) call the next applicable implementation.

That implementation could be set up to dispatch based on the value of 
major-mode.

>> Will the default impl simply return the value of some variable,
>> assigned by a major mode?
>
> default implementation of what function?

project-source-directories.

>> "sources" already has a common meaning,
>
> What is that? I take it to mean "any human-readable file". Which thus
> includes README, Makefile, .git/config, etc.

Maybe there's value in allowing this semantic split to (sometimes?) go 
along different lines, but the two main directions I want to see 
commands work are these:

- Search all files that belong to any of the projects we're currently 
interested in.

- Search only some of those files; ones that are likely programmatically 
(semantically?) related to the one we're editing right now.

The latter could have a decent-enough implementation using Grep, but it 
would be better if we could only search directories that are related.

Maybe it's indeed an excessive requirement, though. After all, backends 
can provide their own implementations of "find references" already.

>> and at least in one proprietary editor it's just one a subset of all
>> project files (see the nomenclature here:
>> https://www.jetbrains.com/idea/help/content-root.html).
>
> That gives me 404

That link still works for me. Maybe your email client mangles it somehow?

> We need it to search what the user wants to search; the user needs to be
> able to specify that clearly and easily.

I intend to allow the user to specify the exact directory for 
xref-find-regexp to search, when called with a prefix. However, allowing 
to input an arbitrary set of directories is obviously non-trivial (if we 
want to have an interface that's not annoying).

> If the user specifies compilation-search-path (directly or indirectly),
> and the user wants to be able to search README, then the user must
> include the directory containing README in compilation-search-path.
>
> Is that a problem?

I mentioned compilation-search-path only as an example, though I didn't 
expect that you might suggest putting the project root into 
compilation-search-path.

Anyway, emacs-lisp-mode doesn't set compilation-search-path. And 
hopefully you're not suggesting to put project roots into load-path, 
just to be able to search READMEs.

>> So it would make sense to have a different name (and a different
>> function/slot/etc) for directories that might be reached that way.
>
> I don't follow; can you give more details, and a clear example?

If my java project is in ~/vc/fooberz, then project-directories would be 
'("~/vc/fooberz"), and project-source-directories would be 
'("~/vc/fooberz/src"). That seems obvious enough, so maybe I don't 
understand the question.

> Ah. Now you are talking about one file that mixes source in two
> languages. Yes, that is a problem. There have been discussions here of
> multi-mode files.

It's targentially related, but the difficulties in displaying and 
editing multi-mode files are entirely different from the subject of this 
discussion.

> I have projects that mix Ada and C++; the project level cross reference
> facility handles both, using the current xref API. That works because
> gcc generates the same cross reference info for those two langauages; I
> doubt there is something similar for Ruby and html.

Maybe, or maybe not; but that's not very relevant. If the tool *can* be 
written, the API is manageable. In the meantime, we can use Grep.

>> That's probably not necessary: after all, only the default
>> xref-find-references implementation will use
>> project-source-directories in a naive way. A smarter xref backend
>> should determine itself which directories to search.
>
> I don't see how that is at all possible, especially in the face of
> hierarchical projects.

I suppose all parts of the "hierarchical project" will employ the same 
project definition logic, possibly enabled by the same minor mode. And 
that minor mode might as well implement the specialized xref backend 
that will know where to search.

> Only the user knows what a "project" is; they write the hierachical
> project files that tell the system what the project structure is.

See the beginning of this email.

> You seem to be missing my point; I see no need for project-root, outside
> of configuration management. So I don't see why xref should care about
> "root" at all.

Or you're missing mine.

The distinction I'm (or was) suggesting is not between the root and 
everything else, but between "source directories" and "other directories 
the user might want to search in", and we'll often want to see the 
project's root directory inside the latter list (when not in both).

>>>> On the other hand, after the project root is determined, it might want
>>>> to add some new element(s) to the source directories list.
>>>
>>> "it" is what here ? Can you give an example?
>>
>> Some package that defines that root-finding logic. Not every major
>> mode knows where the relevant source directories are, or it might not
>> know some of them.
>
> As I've said, none of the languages I deal with care about a "root"
> directory. Only git, mtn, cvs care.

Allow me to repeat: "it" is the package that defines the root-finding 
logic. Defines the logic that determines the bounds of the current (and 
possibly linked) project(s).

The act of find the project root directory may sometimes be skipped in 
some odd cases, but otherwise, it'll usually be the first step to 
determining the current project.

> Hmm. Java imposes something like a root by forcing the directory
> structure to match the hiearchical package naming. But referencing other
> package hierarchies complicates that, just as in Ada and C++.

So there'll be several roots. Or project-directories. No big deal.

>> If we've opened one of the files in a third-party Elisp project that
>> hasn't been loaded yet (so not in load-path), a project implementation
>> can still add an element or several to project-source-directories, so
>> that xref-find-references returns somewhat useful results anyway.
>
> What does that have to do with "root"?

The root directory usually, a) contains data about the project 
structure, b) includes files we want to search.

> The third-party elisp file will presumably have some paths in "(require
> ...)" forms that will define a set of directories to be added to
> project-source-directories.

First of all, those forms specify path relative to *any* load-path 
element. We can't add every permutation. Second, I was describing the 
case where the requires load-path element weren't even set yet.

Third, either way it won't include the files that depend on the current 
one. Those are important, too.

>> Or, say, for Ruby: while the major mode might conceivably be taught
>> about paths where to find system-wide libraries, the locations of
>> source files in a given project depend on the project's type, and that
>> must be something a project implementation knows better. Even if it'll
>> simply add the root to project-source-directories.
>
> What "root"? Is that the directory containing the Ruby file that we
> opened?

It's some parent directory of the currently opened file. Probably not 
the direct parent. It's important because it contains files related to 
the current one.

 > Why is that a "root" as opposed to just some source directory?

That's a weird question. It's a root of the project. It *is* also one of 
the source directories, in this example.



  reply	other threads:[~2015-06-09 22:31 UTC|newest]

Thread overview: 87+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-04 11:43 Unified project interface Dmitry Gutov
2015-06-04 14:40 ` Stephen Leake
2015-06-05  0:08   ` Dmitry Gutov
2015-06-05 10:08     ` Stephen Leake
2015-06-05 13:03       ` Stephen Leake
2015-06-05 13:14         ` Dmitry Gutov
2015-06-08  1:24           ` Stephen Leake
2015-06-09 18:16             ` Dmitry Gutov
2015-06-09 18:21               ` Eli Zaretskii
2015-06-09 18:49                 ` Dmitry Gutov
2015-06-09 19:03                   ` Eli Zaretskii
2015-06-07 23:22         ` Dmitry Gutov
2015-06-08  1:35           ` [SPAM UNSURE] " Stephen Leake
2015-06-09 19:04             ` Dmitry Gutov
2015-06-07 23:15       ` Dmitry Gutov
2015-06-08  1:59         ` Stephen Leake
2015-06-09 22:31           ` Dmitry Gutov [this message]
2015-06-10  7:13             ` Steinar Bang
2015-07-08  0:25             ` Dmitry Gutov
2015-07-11 13:43               ` Bozhidar Batsov
2015-07-11 14:17                 ` Dmitry Gutov
2015-07-12 14:42                   ` Dmitry Gutov
2015-07-13  8:49                   ` Bozhidar Batsov
2015-07-13 10:23                     ` Dmitry Gutov
2015-07-24 23:43       ` Dmitry Gutov
2015-07-25  0:55         ` Stephen Leake
2015-07-25  7:29           ` Eli Zaretskii
2015-07-26  2:12             ` Dmitry Gutov
2015-07-26  2:45               ` Eli Zaretskii
2015-07-26 11:25               ` Stephen Leake
2015-07-26  2:11           ` Dmitry Gutov
2015-07-26 11:22             ` Stephen Leake
2015-07-26 17:23               ` Dmitry Gutov
2015-07-26 18:57                 ` Stephen Leake
2015-07-26 23:56                   ` John Yates
2015-07-27  1:49                     ` Dmitry Gutov
2015-07-27 11:12                     ` Stephen Leake
2015-07-27 11:27                       ` Dmitry Gutov
2015-07-27 13:00                   ` Dmitry Gutov
2015-07-27 13:02                     ` Dmitry Gutov
2015-07-28  1:21                     ` Stephen Leake
2015-07-28 11:05                       ` Stephen Leake
2015-07-28 14:33                         ` Dmitry Gutov
2015-07-28 15:45                           ` Stephen Leake
2015-07-28 16:25                             ` Dmitry Gutov
2015-07-29  1:36                               ` Stephen Leake
2015-07-29  2:10                                 ` Dmitry Gutov
2015-07-28 14:18                       ` Dmitry Gutov
2015-07-28 16:15                         ` Stephen Leake
2015-07-28 18:44                           ` Dmitry Gutov
2015-07-29  2:27                             ` Stephen Leake
2015-07-29 22:51                               ` Dmitry Gutov
2015-07-30  8:17                                 ` Stephen Leake
2015-07-31  0:15                                   ` Dmitry Gutov
2015-07-31 16:13                                     ` Stephen Leake
2015-08-01  0:57                                       ` Dmitry Gutov
2015-08-01  9:50                                         ` Stephen Leake
2015-08-01 10:51                                           ` Stephen Leake
2015-08-01 12:42                                             ` Dmitry Gutov
2015-08-01 12:40                                           ` Dmitry Gutov
2015-08-01 14:15                                             ` Stephen Leake
2015-08-01 15:09                                               ` Dmitry Gutov
2015-08-01 19:04                                                 ` Stephen Leake
2015-08-01 22:33                                                   ` Dmitry Gutov
2015-08-01  1:14                                       ` Per-language project-search-path, was: " Dmitry Gutov
2015-08-01 10:43                                         ` Stephen Leake
2015-08-01 14:12                                           ` Dmitry Gutov
2015-08-01 18:57                                             ` Stephen Leake
2015-08-02  0:25                                               ` Dmitry Gutov
2015-08-02  2:29                                             ` Eric Ludlam
2015-08-02  8:57                                               ` Nix
2015-08-02 17:14                                                 ` Michael Heerdegen
2015-08-02 23:09                                                   ` Eric Ludlam
2015-08-02 23:39                                                     ` Michael Heerdegen
2015-08-03 11:33                                                       ` Eric Ludlam
2015-08-02 23:07                                                 ` Dmitry Gutov
2015-08-03 10:24                                                   ` Nix
2015-08-03 10:35                                                     ` Dmitry Gutov
2015-08-07 15:25                                                       ` Nix
2015-08-03  1:21                                               ` Dmitry Gutov
2015-07-29 23:11                               ` xref display and multiple locations, " Dmitry Gutov
2015-06-06 10:20 ` Bozhidar Batsov
2015-06-06 10:29   ` Dmitry Gutov
2015-06-06 12:32 ` Eric Ludlam
2015-06-06 18:44   ` Dmitry Gutov
2015-06-06 19:28     ` Eli Zaretskii
2015-06-07 22:29       ` Dmitry Gutov

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=5577695F.70800@yandex.ru \
    --to=dgutov@yandex.ru \
    --cc=emacs-devel@gnu.org \
    --cc=stephen_leake@stephe-leake.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.