diff options
| author | Akshay Nair <phenax5@gmail.com> | 2026-06-23 00:50:21 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2026-06-23 00:50:21 +0530 |
| commit | 7502d1e84ae9956356e1578f65d11a8326ce3ec0 (patch) | |
| tree | d5f9140d2e4ffcd57df971b2b27dc655b7a6294c /scripts/marks.fnl | |
| parent | e254ac67272707644be53aa1eb296917651a1771 (diff) | |
| download | kakoune-config-7502d1e84ae9956356e1578f65d11a8326ce3ec0.tar.gz kakoune-config-7502d1e84ae9956356e1578f65d11a8326ce3ec0.zip | |
Refactor fennel scripts to babashka clojure
Diffstat (limited to '')
| -rwxr-xr-x | scripts/marks.fnl | 73 |
1 files changed, 0 insertions, 73 deletions
diff --git a/scripts/marks.fnl b/scripts/marks.fnl deleted file mode 100755 index d0ad3db..0000000 --- a/scripts/marks.fnl +++ /dev/null @@ -1,73 +0,0 @@ -#!/usr/bin/env -S fennel --lua luajit - -(lambda fnl-require [path] - (local fnl (require :fennel)) - (local scriptpath (string.gsub (. arg 0) "[^/]*$" "")) - (fnl.dofile (.. scriptpath "/" path))) - -(local {: index-of : exec : read-lines : write-lines} - (fnl-require :fnl/lib.fnl)) - -(local xdg_data_home - (do - (local path (os.getenv :XDG_DATA_HOME)) - (or path (.. (os.getenv :HOME) :/.local/share)))) - -(local marks_path (.. xdg_data_home :/kak/marks)) - -(local command {}) -(local M {}) - -(lambda command.add [[new-mark ?posstr]] - (local pos (and ?posstr (tonumber ?posstr))) - (local markpaths (M.get-marks)) - (local existing-idx (index-of markpaths new-mark)) - (when (not= nil existing-idx) - (table.remove markpaths existing-idx)) - (if (or (= pos nil) (= pos 0)) - (table.insert markpaths new-mark) - (table.insert markpaths pos new-mark)) - (M.set-marks markpaths)) - -(lambda command.get [[posstr]] - (local pos (and posstr (tonumber posstr))) - (local markpaths (M.get-marks)) - (local existing-idx (. markpaths pos)) - (when (not= nil existing-idx) (print existing-idx))) - -(lambda command.delete [[mark]] - (local markpaths (M.get-marks)) - (local existing-idx (index-of markpaths mark)) - (when (not= nil existing-idx) - (table.remove markpaths existing-idx)) - (M.set-marks markpaths)) - -(fn command.clear [] (M.set-marks [])) - -(fn command.show [] - (print (table.concat (M.get-marks) "\n"))) - -(fn command.show-path [] - (print (.. marks_path "/" (M.path-key)))) - -;; ----- - -(fn M.path-key [] - (string.gsub (os.getenv :PWD) "[^A-Za-z0-9._-]" "-")) - -(fn M.get-marks [?key] - (local path (.. marks_path "/" (or ?key (M.path-key)))) - (read-lines path)) - -(lambda M.set-marks [marks ?key] - (exec :mkdir [:-p marks_path]) ; Create marks path dir if not exists - (local path (.. marks_path "/" (or ?key (M.path-key)))) - (write-lines path marks)) - -(fn M.main [] - (local [cmd & cmdargs] arg) - (if (and cmd (. command cmd)) - ((. command cmd) cmdargs) - (error (.. "invalid command: " (or cmd ""))))) - -(M.main) |
