Mime documentation

mime is a scripting tool for text processing, inspired by Emacs Keyboard Macros.

View on GitHub

Print function names

The below script reads a go source file and prints the names of the functions.

func-names.mime

var b = buffer("main.go");

while(b.find("func ") >= 0) {
    b.set_mark();
    b.find("(");
    b.backward();

    print(b.copy());
}

main.go

If there is a file “main.go” in the same directory with the below contents,

package main

import "fmt"

func main() {
	fmt.Print(hello(), world())
}

func world() string {
	return "world!"
}

func hello() string {
	return "Hello "
}

Then running the above mime script with:

mime func-names.mime

would print this output

main
world
hello