diff options
| author | Akshay Nair <phenax5@gmail.com> | 2025-10-26 01:12:36 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2025-10-26 01:12:36 +0530 |
| commit | a699f41c228b573ff980927d6807ea2b538c0be0 (patch) | |
| tree | 9690227ac84f8b54b52ab28750b497ba219aa133 /scripts/fnl | |
| parent | 5d823bbd19dc8589cfacdbe51ee5260042dacab2 (diff) | |
| download | kakoune-config-a699f41c228b573ff980927d6807ea2b538c0be0.tar.gz kakoune-config-a699f41c228b573ff980927d6807ea2b538c0be0.zip | |
Move marks into fnl script
Diffstat (limited to 'scripts/fnl')
| -rw-r--r-- | scripts/fnl/lib.fnl | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/scripts/fnl/lib.fnl b/scripts/fnl/lib.fnl new file mode 100644 index 0000000..100b447 --- /dev/null +++ b/scripts/fnl/lib.fnl @@ -0,0 +1,32 @@ +(local M {}) + +(lambda M.contains? [tbl elem] + (not= nil (table.index-of tbl elem))) + +(lambda M.index-of [tbl elem] + (each [idx value (pairs tbl)] + (when (= value elem) (lua "return idx"))) + nil) + +(lambda M.exec [cmd args] + (var argstr "") + (each [_ arg (ipairs args)] + (set argstr (.. argstr " \"" (string.gsub arg "\"" "\\\"") "\""))) + (local code (os.execute (.. cmd argstr)))) + +(lambda M.read-lines [filepath] + (local file (io.open filepath :r)) + (if file + (do + (local lines []) + (each [line (file:lines)] (table.insert lines line)) + (file:close) + lines) + [])) + +(lambda M.write-lines [filepath lines] + (local file (io.open filepath :w)) + (file:write (table.concat lines "\n")) + (file:close)) + +M |
