{"id":15011015,"url":"https://github.com/shsms/mime","last_synced_at":"2025-06-21T17:33:10.487Z","repository":{"id":54398971,"uuid":"306716933","full_name":"shsms/mime","owner":"shsms","description":"mime is a scripting tool for text processing, inspired by Emacs Keyboard Macros.","archived":false,"fork":false,"pushed_at":"2023-05-27T11:37:21.000Z","size":1613,"stargazers_count":7,"open_issues_count":11,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-11T15:16:46.035Z","etag":null,"topics":["cpp","emacs","scripting","text-processing"],"latest_commit_sha":null,"homepage":"https://shsms.github.io/mime","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shsms.png","metadata":{"files":{"readme":"README.org","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-10-23T18:29:27.000Z","updated_at":"2023-02-19T21:16:23.000Z","dependencies_parsed_at":"2024-06-21T15:37:54.770Z","dependency_job_id":"428e53aa-681d-43bd-9bc9-466b9903473a","html_url":"https://github.com/shsms/mime","commit_stats":{"total_commits":76,"total_committers":3,"mean_commits":"25.333333333333332","dds":0.2894736842105263,"last_synced_commit":"7736ad92b77be8b754444b4a42063565281ef62a"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"purl":"pkg:github/shsms/mime","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shsms%2Fmime","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shsms%2Fmime/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shsms%2Fmime/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shsms%2Fmime/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shsms","download_url":"https://codeload.github.com/shsms/mime/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shsms%2Fmime/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261165664,"owners_count":23118874,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cpp","emacs","scripting","text-processing"],"created_at":"2024-09-24T19:38:26.650Z","updated_at":"2025-06-21T17:33:05.473Z","avatar_url":"https://github.com/shsms.png","language":"C++","readme":"#+startup: indent\n* mime\n\n[[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]]\n\nMime is a scripting tool for text processing, inspired by Emacs.\n\nMime provides an editor-like abstraction for manipulating text files,\nbut in a scripting environment,  without an editor.  This enables very\nsophisticated transformations that are easy to do through tools\nlike Emacs Keyboard Macros,  but hard to do in code.\n\n- *Documentation*: https://shsms.github.io/mime\n\n** Dependencies\nFor providing its functionalities, Mime depends on these amazing\n libraries:\n\n- [[https://github.com/ChaiScript/ChaiScript][ChaiScript]] for the scripting language.\n- [[https://github.com/arximboldi/immer][Immer]] for data representation.\n- [[https://github.com/jarro2783/cxxopts][cxxopts]] for parsing of cli arguments.\n- [[https://github.com/google/googletest][googletest]] for unit tests.\n\n(You don't have to install them separately, they are added as\nsubmodules to this repository, so just following the build steps in\nthe [[https://mime.dev/getting-started.html][Getting started]] page is enough.)\n\n** An example mime script\n\n#+begin_src js\nvar b = buffer(\"main.go\");\nvar doc_c = b.new_cursor();\nvar nav_c = b.new_cursor();\n\nb.use_cursor(nav_c);\n\nwhile(b.find(\"func \") \u003e= 0) {\n    b.set_mark();\n    b.find(\"(\");\n    b.backward();\n\n    var fname = b.copy();\n\n    b.use_cursor(doc_c);\n    b.paste(\"// FuncAlert: \" + fname + \"\\n\");\n\n    b.use_cursor(nav_c);\n}\nb.use_cursor(doc_c);\nb.paste(\"\\n\");\n\nb.save_as(\"mimeout.go\");\n#+end_src\n\nIf there is a file \"main.go\" in the same directory with the below\ncontents,\n\n#+begin_src go\npackage main\n\nimport \"fmt\"\n\nfunc main() {\n\tfmt.Print(hello(), world())\n}\n\nfunc world() string {\n\treturn \"world!\"\n}\n\nfunc hello() string {\n\treturn \"Hello \"\n}\n#+end_src\n\nThen running the above mime script with:\n\n#+begin_src shell\nmime gofunc.mime\n#+end_src\n\nwould generate a new file \"mimeout.go\" with below contents:\n\n#+begin_src go\n// FuncAlert: main\n// FuncAlert: world\n// FuncAlert: hello\n\npackage main\n\nimport \"fmt\"\n\nfunc main() {\n        fmt.Print(hello(), world())\n}\n\nfunc world() string {\n        return \"world!\"\n}\n\nfunc hello() string {\n        return \"Hello \"\n}\n#+end_src\n\nHere's what the script does:\n\n   1. open file \"main.go\"\n   2. create two cursors - one for adding documentation at the top,\n      and one for navigating the file.\n   3. switch to the navigation cursor.\n   4. find and goto next occurence of the string \"func \".  If found:\n      1. set mark (emacs parlance for \"start selecting\")\n      2. find next occurence of \"(\" (assuming we are operating on a\n         valid go program,  we don't check if \"(\" was found, we assume\n         it is there.)\n      3. go back one character,  we don't want to copy the \"(\"\n      4. copy the text between mark (where we started selecting in\n         4.1), and (current cursor) point, and store in a var called\n         \"fname\".\n      5. switch to the documentation cursor, which is still at the top\n      6. paste the function name in \"fname\" with a comment prefix and\n         a newline at the end.\n      7. switch to navigation cursor\n      8. goto step 4.\n   5. switch to doc cursor to insert a final newline to introduce a\n      gap between inserted text and original program.\n   6. save file under a new name.\n\n** Projects using mime\n\n- *ulysses-annotated*: a project to automatically generate an annotated ebook version of [[https://en.wikipedia.org/wiki/Ulysses_(novel)][Ulysses]]. Read more in its [[https://github.com/shsms/ulysses-annotated][github page]] or on [[http://www.joyceproject.com/pages/ebook.htm][joyceproject.com]]\n\n** Contributing\n\nIf you'd like to contribute a feature or a bug fix,  feel free to send a pull request!\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshsms%2Fmime","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshsms%2Fmime","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshsms%2Fmime/lists"}