From 8ba80979f85c3824977002f81b3370b5b755a655 Mon Sep 17 00:00:00 2001 From: Ava Hahn Date: Thu, 4 May 2023 00:25:42 -0700 Subject: [PATCH] update genbinding doc Signed-off-by: Ava Hahn --- snippets/genbind.rls | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/snippets/genbind.rls b/snippets/genbind.rls index f7cf74a..6ce504a 100644 --- a/snippets/genbind.rls +++ b/snippets/genbind.rls @@ -27,8 +27,23 @@ The point is to be able to autogenerate bindings for shell commands. Example: (eval ((gen-binding (q ls) '-l') ('-a'))) - Or: (def gcommit 'shortcut for git commit -s -m - (lambda (arg) (eval ((gen-binding (q git) 'commit') ('-s' '-m' arg)))))" + Or: (def gcommit 'use: (gcommit my-message)' + (lambda (arg) (eval ((gen-binding 'git' 'commit') ('-s' '-m' arg))))) + + +Or, a more advanced use: + (def -git-opts 'all subcommands for guix' + ('add' 'push' 'stash')) + + ;; define global functions for each subcommand + (let ((gx-iter (pop -git-opts))) + (while (gt? (len gx-iter) 1) + (let ((subc (car gx-iter)) + (rest (cdr gx-iter))) + (def (concat 'g-' subc) + 'subcommand binding for git. takes a list of args' + (lambda (args) (eval ((gen-binding 'git' subc) args)))) + (set (q gx-iter) (pop rest)))))" (sym subcommand) (let ((lam ((q lambda) (cons (q args))