MCPcopy Index your code
hub / github.com/as/edit

github.com/as/edit @v0.6.14

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.6.14 ↗ · + Follow
141 symbols 477 edges 11 files 19 documented · 13%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

edit

Edit is an implementation of the Acme/Sam command language

usage

ed, _ := text.Open(text.NewBuffer())
ed.Insert([]byte("Removing vowels isnt the best way to name things"), 0)

cmd, _ := edit.Compile(",x,[aeiou],d")
cmd.Run(ed)

fmt.Printf("%s\n", ed.Bytes())
// Rmvng vwls snt th bst wy t nm thngs

example

See example/example.go

reference

Rob Pike pioneered structural regular expressions in the 1980s. The original implementations can be found in his Sam and Acme text editors.

http://doc.cat-v.org/bell_labs/structural_regexps/

http://doc.cat-v.org/bell_labs/sam_lang_tutorial/

Go Report Card

appendix

This implementation now runs 10-1000 times faster

Benchmark before coalescing (2017.09.17)

goos: windows
goarch: amd64
BenchmarkChange128KBto64KB-4                       1    3531749200 ns/op
BenchmarkChange128KBto128KB-4                      1    3784740700 ns/op
BenchmarkChange128KBto128KBNest4x2x1-4             1    3642752800 ns/op
BenchmarkChange128KBto128KBx16x4x1-4               1    3589181900 ns/op

After coalescing (current)

goos: windows
goarch: amd64
pkg: github.com/as/edit
BenchmarkChange128KBto64KB-4                           2         530753100 ns/op
BenchmarkChange128KBto128KB-4                        200           6529711 ns/op
BenchmarkChange128KBto128KBNest4x2x1-4               200           6450888 ns/op
BenchmarkChange128KBto128KBx16x4x1-4                 200           6333687 ns/op
BenchmarkDelete128KB-4                            200000             11720 ns/op
BenchmarkDelete128KBx64-4                             20          93447760 ns/op
BenchmarkDelete128KBx8-4                              20          68008640 ns/op
BenchmarkDelete128KBx1-4                               5         263001000 ns/op
BenchmarkDelete256KBx1-4                               2         519648200 ns/op
BenchmarkDelete512KBx1-4                               1        1032597800 ns/op

Extension points exported contracts — how you extend this code

Address (Interface)
Address implements Set on the Editor. Possibly selecting some range of text (a dot). [5 implementers]
addr.go
Sender (Interface)
(no doc)
parse.go
Editor (Interface)
(no doc)
addr.go

Core symbols most depended-on inside this repo

Dot
called by 27
addr.go
Insert
called by 26
addr.go
Select
called by 26
addr.go
emit
called by 23
lex.go
Bytes
called by 21
addr.go
accept
called by 21
lex.go
Delete
called by 17
addr.go
parseArg
called by 16
parse.go

Shape

Method 65
Function 45
Struct 24
Interface 3
TypeAlias 3
FuncType 1

Languages

Go100%

Modules by API surface

lex.go30 symbols
addr.go27 symbols
parse.go24 symbols
compile.go17 symbols
cmd.go17 symbols
bench_test.go10 symbols
example/example.go7 symbols
rec.go5 symbols
edit_test.go4 symbols

For agents

$ claude mcp add edit \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact