Skip to content

Commit

Permalink
Go Guru support
Browse files Browse the repository at this point in the history
-added Go Guru (golang.org/x/tools/cmd/guru) support.
-removed subsequently useless/redundant features.
-removed support for languages other than Go.

To sum up, we now support 3 kinds of searches: global search (in all
locations, with find and grep), guru search, and local search (in a
specified location, with find and grep).
  • Loading branch information
mpl committed Oct 7, 2016
1 parent 45906f2 commit 3ed4533
Show file tree
Hide file tree
Showing 8 changed files with 328 additions and 572 deletions.
81 changes: 45 additions & 36 deletions README.txt
@@ -1,39 +1,48 @@
gofinder
========

The gofinder program is an acme user interface to look for include files, specific patterns, and regexps.

You need a json config file to define the projects where gofind will look; see projects-example.json for the expected fields.

The resulting acme ui will look like the following.

Search in:
-----------------------------------
proj1:
c++: staticMethod staticMember include all
/home/glenda/foo /home/glenda/bar
proj2:
fortran: module subroutine function all
go: package func all
/home/glenda/foobar /home/glenda/foobarbaz /home/glenda/go
camlistore:
go: package func type method all
/home/mpl/gocode/src/camlistore.org /home/mpl/go /home/mpl/gocode/src/github.com/mpl /home/mpl/gocode/src/bitbucket.org/mpl /home/mpl/git/go
.*zembed_.*
-----------------------------------

All searches are 2-1 chords: one first selects with button 1 the queried terms in the code, and one then presses and holds button 2 on one of the words of this ui and presses button 1 while still holding button 2.

For each project, each language and its possible search methods are displayed, as well as the possible locations.
For example, say the fortran module named "foo" is used and defined in proj2. Then selecting foo in the code and chording it 2-1 on the "module" word on the fortran line of proj2 will try and find the location of this module definition.

The "all" keyword/command will trigger a regexp search (only in the relevant files for the corresponding language - this is hardcoded) of whatever is chorded 2-1 to it.

Same behaviour for the locations, except the search will apply to all the relevant files of the project (defined by the "Exts" field) in the chorded location.

The "Excluded" field (regexp) obsiously indicates what should be excluded from the search.

Limitations:
-It does not do chained calls. But I found I don't really need it, at least with Go.

-The underlying searches rely on find and grep. They should be replaced with native go code.
The gofinder program is an acme user interface to search through Go projects.

It uses 2-1 chording (see https://swtch.com/plan9port/man/man1/acme.html).
It uses a JSON configuration file to define project(s) to search on; see
projects-example.json for a working configuration example.

It displays, in the following order: The name of the project, to perform a
global search. The Go Guru (golang.org/x/tools/cmd/guru) modes, to perform a
guru search. The project's locations, to perform a local search. For example,
with the provided projects-example.json, the UI will look like:

Search in:
-----------------------------------
camlistore:
callees callers callstack definition describe freevars implements peers pointsto referrers what whicherrs
/home/mpl/src/camlistore.org /home/mpl/src/camlistore.org/vendor /home/mpl/src/go4.org /home/mpl/src/github.com/mpl
-----------------------------------


The configuration file is mapped to a project type, which is defined as follows:

type Project struct {
// Name is the one word name describing the project, that will appear at
// the top of the UI. One word, because chording on the name starts a
// global search in the project. Global search means a find on all the
// files ending with the extensions defined in Exts, looking in the
// locations defined in Locations, excluding all the patterns defined in
// Excluded. The results are piped to a grep for the argument that is sent
// with the chord.
Name string
// Locations defines all the locations relevant to the project, and as
// such, they are displayed on the UI. A global search runs find through
// all of them. A chording on one of the locations will perform a local
// search, i.e. in the same way as a global search, except find will only
// run through that one location.
Locations []string
// Exts defines the file extension patterns (regexp), that find will
// take into account. It defaults to []string{"\.go"} otherwise.
Exts []string
// Excluded defines the patterns (regexp), that find will take into
// account to exclude from the search results.
Excluded []string
// GuruScope is the scope that guru will use for the modes that need one.
GuruScope []string
}
106 changes: 0 additions & 106 deletions c++.go

This file was deleted.

39 changes: 0 additions & 39 deletions fortran.go

This file was deleted.

39 changes: 0 additions & 39 deletions go.go

This file was deleted.

0 comments on commit 3ed4533

Please sign in to comment.