mime is a scripting tool for text processing, inspired by Emacs Keyboard Macros.
GPL-3.0 License
#+startup: indent
[[https://github.com/shsms/mime/actions][https://github.com/shsms/mime/workflows/build/badge.svg]] [[https://codecov.io/gh/shsms/mime][https://codecov.io/gh/shsms/mime/branch/main/graph/badge.svg?token=ASAIA6P309]]
Mime is a scripting tool for text processing, inspired by Emacs.
Mime provides an editor-like abstraction for manipulating text files, but in a scripting environment, without an editor. This enables very sophisticated transformations that are easy to do through tools like Emacs Keyboard Macros, but hard to do in code.
** Dependencies For providing its functionalities, Mime depends on these amazing libraries:
(You don't have to install them separately, they are added as submodules to this repository, so just following the build steps in the [[https://mime.dev/getting-started.html][Getting started]] page is enough.)
** An example mime script
#+begin_src js var b = buffer("main.go"); var doc_c = b.new_cursor(); var nav_c = b.new_cursor();
b.use_cursor(nav_c);
while(b.find("func ") >= 0) { b.set_mark(); b.find("("); b.backward();
var fname = b.copy();
b.use_cursor(doc_c);
b.paste("// FuncAlert: " + fname + "\n");
b.use_cursor(nav_c);
} b.use_cursor(doc_c); b.paste("\n");
b.save_as("mimeout.go"); #+end_src
If there is a file "main.go" in the same directory with the below contents,
#+begin_src go package main
import "fmt"
func main() { fmt.Print(hello(), world()) }
func world() string { return "world!" }
func hello() string { return "Hello " } #+end_src
Then running the above mime script with:
#+begin_src shell mime gofunc.mime #+end_src
would generate a new file "mimeout.go" with below contents:
#+begin_src go // FuncAlert: main // FuncAlert: world // FuncAlert: hello
package main
import "fmt"
func main() { fmt.Print(hello(), world()) }
func world() string { return "world!" }
func hello() string { return "Hello " } #+end_src
Here's what the script does:
** Projects using mime
** Contributing
If you'd like to contribute a feature or a bug fix, feel free to send a pull request!