Separate packages for config and command evaluation

Evaluate config options
This commit is contained in:
mainzelm 2006-04-06 13:25:03 +00:00
parent c82a228790
commit c0fbaf7d07
6 changed files with 37 additions and 17 deletions

View File

@ -30,7 +30,7 @@
(symbol? (cdar option.value)) (symbol? (cdar option.value))
(assoc (car option.value) *configuration*)) (assoc (car option.value) *configuration*))
=> (lambda (p) => (lambda (p)
(set-cdr! p (cdr option.value)))) (set-cdr! p (eval-s-expr (cdr option.value) 'commander-s-config-eval))))
(else (else
(error "Unknown option value or ill-formed option" (error "Unknown option value or ill-formed option"
option.value conf-file)))) option.value conf-file))))

View File

@ -29,10 +29,17 @@
(let ((string-port (open-input-string string))) (let ((string-port (open-input-string string)))
(read string-port))) (read string-port)))
(define (eval-string str) (define (eval-string str . maybe-package-name)
(eval (read-sexp-from-string str) (apply eval-s-expr (read-sexp-from-string str) maybe-package-name))
(evaluation-environment)))
(define (eval-s-expr s-expr . maybe-package-name)
(let ((env (if (null? maybe-package-name)
(evaluation-environment)
(load-evaluation-environment (car maybe-package-name)))))
(eval s-expr env)))
(define (eval-s-expr/command s-expr)
(let ((command-env (load-evaluation-environment 'nuit-eval)))
(eval s-expr command-env)))
(define (eval-s-expr s-expr)
(eval s-expr (evaluation-environment)))

View File

@ -307,7 +307,7 @@
(fork-pty-session (fork-pty-session
(lambda () (lambda ()
(handle-signal-default signal/ttou) (handle-signal-default signal/ttou)
(eval-s-expr s-expr)))) (eval-s-expr/command s-expr))))
(lambda (proc pty-in pty-out tty-name) (lambda (proc pty-in pty-out tty-name)
(make-job-with-console (make-job-with-console
s-expr proc pty-in pty-out s-expr proc pty-in pty-out
@ -342,7 +342,7 @@
(set-process-group child-pid) (set-process-group child-pid)
(set-tty-process-group (current-output-port) child-pid) (set-tty-process-group (current-output-port) child-pid)
(handle-signal-default signal/ttou) (handle-signal-default signal/ttou)
(eval-s-expr s-expr)))))) (eval-s-expr/command s-expr))))))
(let* ((job (make-job-sans-console s-expr proc)) (let* ((job (make-job-sans-console s-expr proc))
(status (job-status job))) (status (job-status job)))
(set-tty-process-group (current-output-port) foreground-pgrp) (set-tty-process-group (current-output-port) foreground-pgrp)
@ -367,7 +367,7 @@
(lambda () (lambda ()
(set-process-group (pid) (pid)) (set-process-group (pid) (pid))
(handle-signal-default signal/ttou) (handle-signal-default signal/ttou)
(eval-s-expr s-expr))))) (eval-s-expr/command s-expr)))))
(let ((job (make-job-sans-console s-expr proc))) (let ((job (make-job-sans-console s-expr proc)))
(release-lock paint-lock) (release-lock paint-lock)
job))) job)))

View File

@ -19,6 +19,7 @@
(define-option 'main 'switch-command-buffer-mode-key key-f7) (define-option 'main 'switch-command-buffer-mode-key key-f7)
(define-option 'main 'help-key (char->ascii #\?)) (define-option 'main 'help-key (char->ascii #\?))
(define-option 'main 'quit-help-key (char->ascii #\q)) (define-option 'main 'quit-help-key (char->ascii #\q))
(define-option 'main 'show-shell-key key-end)
;; mode of the command buffer ;; mode of the command buffer
(define-option 'main 'initial-command-mode 'command) (define-option 'main 'initial-command-mode 'command)
@ -457,6 +458,10 @@
(define (process-group-leader?) (define (process-group-leader?)
(= (process-group) (pid))) (= (process-group) (pid)))
;; config needs this to be initialized
(init-evaluation-environment! 'nuit-eval)
;; there are top-level expressions accessing the configuration...
(read-config-file!) (read-config-file!)
;; handle input ;; handle input
@ -471,8 +476,6 @@
(set! *command-buffer-mode* (config 'main 'initial-command-mode)) (set! *command-buffer-mode* (config 'main 'initial-command-mode))
(init-evaluation-environment! 'nuit-eval)
(clear) (clear)
(if (not (process-group-leader?)) (if (not (process-group-leader?))
(become-session-leader)) (become-session-leader))
@ -560,7 +563,8 @@
(define (define-key! key handler) (define (define-key! key handler)
(vector-set! *key-map* key handler)) (vector-set! *key-map* key handler))
(define-key! key-end ;; TODO does not work?!?
(define-key! (config 'main 'show-shell-key)
(lambda (ch) (show-shell-screen) (paint))) (lambda (ch) (show-shell-screen) (paint)))
(define-key! key-f2 (lambda (ch) (paint))) (define-key! key-f2 (lambda (ch) (paint)))
@ -879,8 +883,8 @@
(define header-line "Select completion") (define header-line "Select completion")
(define header-length (string-length header-line)) (define header-length (string-length header-line))
(let* ((lines (min (- (LINES) 5) (let* ((lines (+ 2 (min (- (LINES) 5)
(length completions))) (length completions))))
(inner-width (inner-width
(min (apply max header-length (min (apply max header-length
(map string-length completions)) (map string-length completions))

View File

@ -545,6 +545,12 @@
pps) pps)
(files eval)) (files eval))
(define-structure commander-s-config-eval (compound-interface
(interface-of scheme-with-scsh)
ncurses-interface)
(open scheme-with-scsh
ncurses))
;;; evaluation of Scheme expressions ;;; evaluation of Scheme expressions
(define-interface eval-environment-interface (define-interface eval-environment-interface
@ -554,7 +560,8 @@
evaluation-environment evaluation-environment
evaluation-environment-name evaluation-environment-name
eval-string eval-string
eval-s-expr)) eval-s-expr
eval-s-expr/command))
(define-structure eval-environment eval-environment-interface (define-structure eval-environment eval-environment-interface
(open scheme (open scheme
@ -943,7 +950,9 @@
(define-structure configuration configuration-interface (define-structure configuration configuration-interface
(open scheme-with-scsh (open scheme-with-scsh
signals signals
handle-fatal-error) handle-fatal-error
eval-environment)
(files config)) (files config))
;;; modal window ;;; modal window

View File

@ -98,7 +98,7 @@
(expanded (expand-command-line parsed)) (expanded (expand-command-line parsed))
(s-expr (compile-command-line expanded))) (s-expr (compile-command-line expanded)))
(debug-message "Compiled command " s-expr) (debug-message "Compiled command " s-expr)
(eval-s-expr s-expr))) (eval-s-expr/command s-expr)))
(define standard-command-plugin (define standard-command-plugin
(make-command-plugin #f (make-command-plugin #f