Add 'arguments' field to environment
* geesh/environment.scm (<environment>): Add an 'arguments' field. (make-environment): Add an optional 'arguments' parameter. (with-environment-arguments): New public function. .dir-locals.el: Indent it nicely.
This commit is contained in:
parent
f03b438009
commit
58f5644d2a
|
@ -12,4 +12,5 @@
|
||||||
(eval . (put 'sh:for 'scheme-indent-function 2))
|
(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))
|
||||||
|
(eval . (put 'with-environment-arguments 'scheme-indent-function 2)))))
|
||||||
|
|
|
@ -32,7 +32,9 @@
|
||||||
environment-status
|
environment-status
|
||||||
set-environment-status!
|
set-environment-status!
|
||||||
environment-function-ref
|
environment-function-ref
|
||||||
define-environment-function!))
|
define-environment-function!
|
||||||
|
environment-arguments
|
||||||
|
with-environment-arguments))
|
||||||
|
|
||||||
;;; Commentary:
|
;;; Commentary:
|
||||||
;;;
|
;;;
|
||||||
|
@ -42,19 +44,21 @@
|
||||||
;;; Code:
|
;;; Code:
|
||||||
|
|
||||||
(define-record-type <environment>
|
(define-record-type <environment>
|
||||||
(%make-environment vars functions status)
|
(%make-environment vars functions arguments status)
|
||||||
environment?
|
environment?
|
||||||
(vars environment-vars set-environment-vars!)
|
(vars environment-vars set-environment-vars!)
|
||||||
(functions environment-functions set-environment-functions!)
|
(functions environment-functions set-environment-functions!)
|
||||||
|
(arguments environment-arguments set-environment-arguments!)
|
||||||
(status environment-status set-environment-status!))
|
(status environment-status set-environment-status!))
|
||||||
|
|
||||||
(define (make-environment vars)
|
(define* (make-environment vars #:optional (arguments '()))
|
||||||
;; In order to insure that each pair in the 'vars' alist is mutable,
|
;; In order to insure that each pair in the 'vars' alist is mutable,
|
||||||
;; we copy each one into a new list.
|
;; we copy each one into a new list.
|
||||||
(%make-environment (map (match-lambda
|
(%make-environment (map (match-lambda
|
||||||
((key . val) (cons key val)))
|
((key . val) (cons key val)))
|
||||||
vars)
|
vars)
|
||||||
'()
|
'()
|
||||||
|
arguments
|
||||||
0))
|
0))
|
||||||
|
|
||||||
(define (var-ref env name)
|
(define (var-ref env name)
|
||||||
|
@ -105,3 +109,17 @@ such function, return @code{#f}."
|
||||||
"Make @var{name} refer to @var{proc} in @var{env}."
|
"Make @var{name} refer to @var{proc} in @var{env}."
|
||||||
(set-environment-functions! env (acons name proc
|
(set-environment-functions! env (acons name proc
|
||||||
(environment-functions env))))
|
(environment-functions env))))
|
||||||
|
|
||||||
|
(define (with-environment-arguments env arguments thunk)
|
||||||
|
"Call @var{thunk} with the arguments in @var{env} set to
|
||||||
|
@var{arguments}."
|
||||||
|
(let ((saved-arguments #f))
|
||||||
|
(dynamic-wind
|
||||||
|
(lambda ()
|
||||||
|
(set! saved-arguments (environment-arguments env))
|
||||||
|
(set-environment-arguments! env arguments))
|
||||||
|
thunk
|
||||||
|
(lambda ()
|
||||||
|
(let ((tmp saved-arguments))
|
||||||
|
(set! saved-arguments (environment-arguments env))
|
||||||
|
(set-environment-arguments! env tmp))))))
|
||||||
|
|
Loading…
Reference in New Issue