Add for-loop semantics
* geesh/shell.scm (sh:for): New public function. * .dir-locals.el: Indent it nicely.
This commit is contained in:
parent
46ae7129d5
commit
db56b1cc0a
|
@ -9,6 +9,7 @@
|
||||||
(eval . (put '<sh-with-redirects> 'scheme-indent-function 1))
|
(eval . (put '<sh-with-redirects> 'scheme-indent-function 1))
|
||||||
(eval . (put 'call-with-backquoted-input-port 'scheme-indent-function 1))
|
(eval . (put 'call-with-backquoted-input-port 'scheme-indent-function 1))
|
||||||
(eval . (put 'make-script 'scheme-indent-function 1))
|
(eval . (put 'make-script 'scheme-indent-function 1))
|
||||||
|
(eval . (put 'sh:for 'scheme-indent-function 2))
|
||||||
(eval . (put 'sh:subshell 'scheme-indent-function 1))
|
(eval . (put 'sh:subshell 'scheme-indent-function 1))
|
||||||
(eval . (put 'sh:substitute-command 'scheme-indent-function 1))
|
(eval . (put 'sh:substitute-command 'scheme-indent-function 1))
|
||||||
(eval . (put 'sh:with-redirects 'scheme-indent-function 2)))))
|
(eval . (put 'sh:with-redirects 'scheme-indent-function 2)))))
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#:export (sh:and
|
#:export (sh:and
|
||||||
sh:exec-let
|
sh:exec-let
|
||||||
sh:exec
|
sh:exec
|
||||||
|
sh:for
|
||||||
sh:not
|
sh:not
|
||||||
sh:or
|
sh:or
|
||||||
sh:pipeline
|
sh:pipeline
|
||||||
|
@ -294,3 +295,16 @@ run @var{thunk2}."
|
||||||
(if (string=? (var-ref* env "?") "0")
|
(if (string=? (var-ref* env "?") "0")
|
||||||
(set-var! env "?" "1")
|
(set-var! env "?" "1")
|
||||||
(set-var! env "?" "0")))
|
(set-var! env "?" "0")))
|
||||||
|
|
||||||
|
|
||||||
|
;;; Loops.
|
||||||
|
|
||||||
|
(define (sh:for env bindings thunk)
|
||||||
|
"Run @var{thunk} for each binding in @var{bindings}. The value of
|
||||||
|
@var{bindings} have the form @code{(@var{name} (@var{value} ...))}."
|
||||||
|
(set-var! env "?" "0")
|
||||||
|
(match-let (((name (values ...)) bindings))
|
||||||
|
(for-each (lambda (value)
|
||||||
|
(set-var! env name value)
|
||||||
|
(thunk))
|
||||||
|
values)))
|
||||||
|
|
Loading…
Reference in New Issue