summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJose Antonio Ortega Ruiz <jao@gnu.org>2010-06-08 02:11:55 +0200
committerJose Antonio Ortega Ruiz <jao@gnu.org>2010-06-08 02:11:55 +0200
commite9b0f1aaa810c15dbdffc4147f2956851c4f1782 (patch)
tree17878b6fce5aa24a7415b8a9e41d6c59e86437ed
parentd402ed3f41790abb9861af9dbe47166295cd66b1 (diff)
downloadgeiser-chez-e9b0f1aaa810c15dbdffc4147f2956851c4f1782.tar.gz
geiser-chez-e9b0f1aaa810c15dbdffc4147f2956851c4f1782.tar.bz2
Racket: square cosmetics.
-rw-r--r--scheme/racket/geiser/autodoc.rkt154
-rw-r--r--scheme/racket/geiser/enter.rkt4
-rw-r--r--scheme/racket/geiser/eval.rkt16
-rw-r--r--scheme/racket/geiser/locations.rkt10
-rw-r--r--scheme/racket/geiser/modules.rkt68
-rw-r--r--scheme/racket/geiser/utils.rkt8
6 files changed, 130 insertions, 130 deletions
diff --git a/scheme/racket/geiser/autodoc.rkt b/scheme/racket/geiser/autodoc.rkt
index e54a242..5b85e96 100644
--- a/scheme/racket/geiser/autodoc.rkt
+++ b/scheme/racket/geiser/autodoc.rkt
@@ -16,8 +16,8 @@
(require geiser/utils geiser/modules geiser/locations scheme/help)
(define (get-help symbol mod)
- (with-handlers ((exn? (lambda (_)
- (eval `(help ,symbol)))))
+ (with-handlers ([exn? (lambda (_)
+ (eval `(help ,symbol)))])
(eval `(help ,symbol #:from ,(ensure-module-spec mod)))))
(define (autodoc ids)
@@ -28,11 +28,11 @@
(define (autodoc* id)
(and
(symbol? id)
- (let* ((loc (symbol-location* id))
- (name (car loc))
- (path (cdr loc))
- (sgns (and path (find-signatures path name id)))
- (sgns (and sgns (if (list? sgns) sgns '()))))
+ (let* ([loc (symbol-location* id)]
+ [name (car loc)]
+ [path (cdr loc)]
+ [sgns (and path (find-signatures path name id))]
+ [sgns (and sgns (if (list? sgns) sgns '()))])
(and sgns
`(,id
(name . ,name)
@@ -53,7 +53,7 @@
(struct signature (required optional keys rest))
(define (find-signatures path name local-name)
- (let ((path (if (path? path) (path->string path) path)))
+ (let ([path (if (path? path) (path->string path) path)])
(hash-ref! (hash-ref! signatures
path
(lambda () (parse-signatures path)))
@@ -61,54 +61,54 @@
(lambda () (infer-signatures local-name)))))
(define (parse-signatures path)
- (let ((result (make-hasheq)))
- (with-handlers ((exn? (lambda (e) result)))
+ (let ([result (make-hasheq)])
+ (with-handlers ([exn? (lambda (e) result)])
(with-input-from-file path
(lambda ()
- (parameterize ((read-accept-reader #t))
- (let loop ((stx (read-syntax path)))
- (cond ((eof-object? stx) void)
- ((syntax->datum stx) =>
+ (parameterize ([read-accept-reader #t])
+ (let loop ([stx (read-syntax path)])
+ (cond [(eof-object? stx) void]
+ [(syntax->datum stx) =>
(lambda (datum)
(parse-datum! datum result)
- (loop (read-syntax path))))
- (else void)))))))
+ (loop (read-syntax path)))]
+ [else void]))))))
result))
(define (parse-datum! datum store)
- (with-handlers ((exn? (lambda (_) void)))
+ (with-handlers ([exn? (lambda (_) void)])
(match datum
- (`(module ,name ,lang (#%module-begin . ,forms))
- (for-each (lambda (f) (parse-datum! f store)) forms))
- (`(module ,name ,lang . ,forms)
- (for-each (lambda (f) (parse-datum! f store)) forms))
- (`(define ((,name . ,formals) . ,_) . ,_)
- (add-signature! name formals store))
- (`(define (,name . ,formals) . ,_)
- (add-signature! name formals store))
- (`(define ,name (lambda ,formals . ,_))
- (add-signature! name formals store))
- (`(define ,name (case-lambda ,clauses ...))
+ [`(module ,name ,lang (#%module-begin . ,forms))
+ (for-each (lambda (f) (parse-datum! f store)) forms)]
+ [`(module ,name ,lang . ,forms)
+ (for-each (lambda (f) (parse-datum! f store)) forms)]
+ [`(define ((,name . ,formals) . ,_) . ,_)
+ (add-signature! name formals store)]
+ [`(define (,name . ,formals) . ,_)
+ (add-signature! name formals store)]
+ [`(define ,name (lambda ,formals . ,_))
+ (add-signature! name formals store)]
+ [`(define ,name (case-lambda ,clauses ...))
(for-each (lambda (c) (add-signature! name (car c) store))
- (reverse clauses)))
- (`(,(or 'struct 'define-struct) ,name ,(? symbol? _)
+ (reverse clauses))]
+ [`(,(or 'struct 'define-struct) ,name ,(? symbol? _)
,(list formals ...) . ,_)
- (add-signature! name formals store))
- (`(,(or 'struct 'define-struct) ,name ,(list formals ...) . ,_)
- (add-signature! name formals store))
- (`(define-for-syntax (,name . ,formals) . ,_)
- (add-signature! name formals store))
- (`(define-for-syntax ,name (lambda ,formals . ,_))
- (add-signature! name formals store))
- (`(define-syntax-rule (,name . ,formals) . ,_)
- (add-signature! name formals store))
- (`(define-syntax ,name (syntax-rules ,specials . ,clauses))
+ (add-signature! name formals store)]
+ [`(,(or 'struct 'define-struct) ,name ,(list formals ...) . ,_)
+ (add-signature! name formals store)]
+ [`(define-for-syntax (,name . ,formals) . ,_)
+ (add-signature! name formals store)]
+ [`(define-for-syntax ,name (lambda ,formals . ,_))
+ (add-signature! name formals store)]
+ [`(define-syntax-rule (,name . ,formals) . ,_)
+ (add-signature! name formals store)]
+ [`(define-syntax ,name (syntax-rules ,specials . ,clauses))
(for-each (lambda (c) (add-syntax-signature! name (cdar c) store))
- (reverse clauses)))
- (`(define-syntax ,name (lambda ,_ (syntax-case ,_ . ,clauses)))
+ (reverse clauses))]
+ [`(define-syntax ,name (lambda ,_ (syntax-case ,_ . ,clauses)))
(for-each (lambda (c) (add-syntax-signature! name (cdar c) store))
- (reverse clauses)))
- (_ void))))
+ (reverse clauses))]
+ [_ void])))
(define (add-signature! name formals store)
(when (symbol? name)
@@ -125,16 +125,16 @@
(hash-ref store name '())))))
(define (parse-formals formals)
- (let loop ((formals formals) (req '()) (opt '()) (keys '()))
- (cond ((null? formals)
- (signature (reverse req) (reverse opt) (reverse keys) #f))
- ((symbol? formals)
- (signature (reverse req) (reverse opt) (reverse keys) formals))
- ((pair? (car formals)) (loop (cdr formals)
+ (let loop ([formals formals] [req '()] [opt '()] [keys '()])
+ (cond [(null? formals)
+ (signature (reverse req) (reverse opt) (reverse keys) #f)]
+ [(symbol? formals)
+ (signature (reverse req) (reverse opt) (reverse keys) formals)]
+ [(pair? (car formals)) (loop (cdr formals)
req
(cons (car formals) opt)
- keys))
- ((keyword? (car formals)) (let* ((kname (car formals))
+ keys)]
+ [(keyword? (car formals)) (let* ((kname (car formals))
(arg-id (cadr formals))
(name (if (pair? arg-id)
(list kname
@@ -143,47 +143,47 @@
(loop (cddr formals)
req
opt
- (cons name keys))))
- (else (loop (cdr formals) (cons (car formals) req) opt keys)))))
+ (cons name keys)))]
+ [else (loop (cdr formals) (cons (car formals) req) opt keys)])))
(define (infer-signatures name)
(define syntax-tag (cons 1 0))
(define error-tag (cons 1 1))
(define generic-signature (signature '(...) '() '() #f))
- (let ((value (with-handlers ((exn:fail:syntax? (lambda (_) syntax-tag))
- (exn:fail:contract:variable? (lambda (_)
- error-tag)))
- (namespace-variable-value name))))
- (cond ((procedure? value) (arity->signatures (procedure-arity value)))
- ((eq? value syntax-tag) (list generic-signature))
- ((eq? value error-tag) #f)
- (else 'variable))))
+ (let ([value (with-handlers ([exn:fail:syntax? (lambda (_) syntax-tag)]
+ [exn:fail:contract:variable? (lambda (_)
+ error-tag)])
+ (namespace-variable-value name))])
+ (cond [(procedure? value) (arity->signatures (procedure-arity value))]
+ [(eq? value syntax-tag) (list generic-signature)]
+ [(eq? value error-tag) #f]
+ [else 'variable])))
(define (arity->signatures arity)
(define (args fst count)
- (let* ((letts (list->vector '(#\x #\y #\z #\u #\v #\w #\r #\s)))
- (len (vector-length letts))
- (lett (lambda (n) (vector-ref letts (modulo n len)))))
+ (let* ([letts (list->vector '(#\x #\y #\z #\u #\v #\w #\r #\s))]
+ [len (vector-length letts)]
+ [lett (lambda (n) (vector-ref letts (modulo n len)))])
(map (lambda (n) (string->symbol (format "~a" (lett n))))
(build-list count (lambda (n) (+ n fst))))))
(define (arity->signature arity)
- (cond ((number? arity)
- (signature (args 0 arity) '() '() #f))
- ((arity-at-least? arity)
- (signature (args 0 (arity-at-least-value arity)) '() '() 'rest))))
+ (cond [(number? arity)
+ (signature (args 0 arity) '() '() #f)]
+ [(arity-at-least? arity)
+ (signature (args 0 (arity-at-least-value arity)) '() '() 'rest)]))
(define (conseq? lst)
- (cond ((< (length lst) 2) (number? (car lst)))
- ((and (number? (car lst))
+ (cond [(< (length lst) 2) (number? (car lst))]
+ [(and (number? (car lst))
(number? (cadr lst))
(eqv? (+ 1 (car lst)) (cadr lst)))
- (conseq? (cdr lst)))
- (else #f)))
- (cond ((and (list? arity) (conseq? arity))
+ (conseq? (cdr lst))]
+ [else #f]))
+ (cond [(and (list? arity) (conseq? arity))
(let ((mi (apply min arity))
(ma (apply max arity)))
- (list (signature (args 0 mi) (args mi (- ma mi)) '() #f))))
- ((list? arity) (map arity->signature arity))
- (else (list (arity->signature arity)))))
+ (list (signature (args 0 mi) (args mi (- ma mi)) '() #f)))]
+ [(list? arity) (map arity->signature arity)]
+ [else (list (arity->signature arity))]))
(define (update-signature-cache path . form)
(when (and (string? path)
diff --git a/scheme/racket/geiser/enter.rkt b/scheme/racket/geiser/enter.rkt
index 181c06a..9705ec3 100644
--- a/scheme/racket/geiser/enter.rkt
+++ b/scheme/racket/geiser/enter.rkt
@@ -21,8 +21,8 @@
(define loaded (make-hash))
(define (module-loaded? path)
- (with-handlers ((exn? (lambda (_) #f)))
- (let ((rp (module-path-index-resolve (module-path-index-join path #f))))
+ (with-handlers ([exn? (lambda (_) #f)])
+ (let ([rp (module-path-index-resolve (module-path-index-join path #f))])
(hash-has-key? loaded (resolved-module-path-name rp)))))
(define (enter-module mod)
diff --git a/scheme/racket/geiser/eval.rkt b/scheme/racket/geiser/eval.rkt
index db50ded..1210d22 100644
--- a/scheme/racket/geiser/eval.rkt
+++ b/scheme/racket/geiser/eval.rkt
@@ -33,14 +33,14 @@
(define current-marks (make-parameter (current-continuation-marks)))
(define (get-real-context e)
- (let ((ec (continuation-mark-set->context (exn-continuation-marks e)))
- (cc (continuation-mark-set->context (current-marks))))
+ (let ([ec (continuation-mark-set->context (exn-continuation-marks e))]
+ [cc (continuation-mark-set->context (current-marks))])
(filter-not (lambda (c) (member c cc)) ec)))
(define (display-exn-context c)
(define (maybe-display p x) (when x (display p) (display x)) x)
(when (and (pair? c) (cdr c))
- (let ((sloc (cdr c)))
+ (let ([sloc (cdr c)])
(and (maybe-display "" (srcloc-source sloc))
(maybe-display ":" (srcloc-line sloc))
(maybe-display ":" (srcloc-column sloc)))
@@ -62,12 +62,12 @@
(define (call-with-result thunk)
(set-last-result (void))
- (let ((output
+ (let ([output
(with-output-to-string
(lambda ()
- (parameterize ((current-marks (current-continuation-marks)))
- (with-handlers ((exn? set-last-error))
- (call-with-values thunk set-last-result)))))))
+ (parameterize ([current-marks (current-continuation-marks)])
+ (with-handlers ([exn? set-last-error])
+ (call-with-values thunk set-last-result)))))])
(append last-result `((output . ,output)))))
(define (eval-in form spec lang)
@@ -87,7 +87,7 @@
(define compile-file load-file)
(define (macroexpand form . all)
- (let ((all (and (not (null? all)) (car all))))
+ (let ([all (and (not (null? all)) (car all))])
(with-output-to-string
(lambda ()
(pretty-print (syntax->datum ((if all expand expand-once) form)))))))
diff --git a/scheme/racket/geiser/locations.rkt b/scheme/racket/geiser/locations.rkt
index b4c0f37..7f69d3a 100644
--- a/scheme/racket/geiser/locations.rkt
+++ b/scheme/racket/geiser/locations.rkt
@@ -20,8 +20,8 @@
(require geiser/utils geiser/modules)
(define (symbol-location* sym)
- (let* ((id (namespace-symbol->identifier sym))
- (binding (and id (identifier-binding id))))
+ (let* ([id (namespace-symbol->identifier sym)]
+ [binding (and id (identifier-binding id))])
(if (list? binding)
(cons
(cadr binding)
@@ -35,9 +35,9 @@
(cons 'line (or line '()))))
(define (symbol-location sym)
- (let* ((loc (symbol-location* sym))
- (name (car loc))
- (path (cdr loc)))
+ (let* ([loc (symbol-location* sym)]
+ [name (car loc)]
+ [path (cdr loc)])
(if path
(make-location name path #f)
(module-location sym))))
diff --git a/scheme/racket/geiser/modules.rkt b/scheme/racket/geiser/modules.rkt
index 95219ed..299baee 100644
--- a/scheme/racket/geiser/modules.rkt
+++ b/scheme/racket/geiser/modules.rkt
@@ -23,43 +23,43 @@
(require srfi/13 syntax/modresolve syntax/modcode geiser/enter)
(define (ensure-module-spec spec)
- (cond ((symbol? spec) spec)
- ((not (string? spec)) #f)
- (else `(file ,spec))))
+ (cond [(symbol? spec) spec]
+ [(not (string? spec)) #f]
+ [else `(file ,spec)]))
(define (module-spec->namespace spec (lang #f))
- (let ((spec (ensure-module-spec spec))
- (try-lang (lambda (_)
- (with-handlers ((exn? (const (current-namespace))))
+ (let ([spec (ensure-module-spec spec)]
+ [try-lang (lambda (_)
+ (with-handlers ([exn? (const (current-namespace))])
(and lang
(begin
(load-module lang #f (current-namespace))
- (module->namespace lang)))))))
+ (module->namespace lang)))))])
(or (and spec
- (with-handlers ((exn? try-lang)) (get-namespace spec)))
+ (with-handlers ([exn? try-lang]) (get-namespace spec)))
(current-namespace))))
(define nowhere (open-output-nowhere))
(define (load-module spec (port #f) (ns #f))
- (parameterize ((current-error-port (or port nowhere)))
+ (parameterize ([current-error-port (or port nowhere)])
(enter-module (ensure-module-spec spec))
(when (namespace? ns)
(current-namespace ns))))
(define (namespace->module-path-name ns)
- (let ((rmp (variable-reference->resolved-module-path
- (eval '(#%variable-reference) ns))))
+ (let ([rmp (variable-reference->resolved-module-path
+ (eval '(#%variable-reference) ns))])
(and (resolved-module-path? rmp)
(resolved-module-path-name rmp))))
(define (module-spec->path-name spec)
- (with-handlers ((exn? (lambda (_) #f)))
- (let ((ns (module-spec->namespace (ensure-module-spec spec))))
+ (with-handlers ([exn? (lambda (_) #f)])
+ (let ([ns (module-spec->namespace (ensure-module-spec spec))])
(namespace->module-path-name ns))))
(define (module-path-name->name path)
- (cond ((path? path)
+ (cond [(path? path)
(let* ((path (path->string path))
(cpaths (map (compose path->string path->directory-path)
(current-library-collection-paths)))
@@ -73,11 +73,11 @@
(if (absolute-path? real-path)
(call-with-values (lambda () (split-path path))
(lambda (_ basename __) (path->string basename)))
- (regexp-replace "\\.[^./]*$" real-path ""))))
- ((eq? path '#%kernel) "(kernel)")
- ((string? path) path)
- ((symbol? path) (symbol->string path))
- (else "")))
+ (regexp-replace "\\.[^./]*$" real-path "")))]
+ [(eq? path '#%kernel) "(kernel)"]
+ [(string? path) path]
+ [(symbol? path) (symbol->string path)]
+ [else ""]))
(define (skippable-dir? path)
(call-with-values (lambda () (split-path path))
@@ -87,27 +87,27 @@
(define path->symbol (compose string->symbol path->string))
(define (path->entry path)
- (let ((ext (filename-extension path)))
+ (let ([ext (filename-extension path)])
(and ext
(or (bytes=? ext #"rkt") (bytes=? ext #"ss"))
- (let* ((path (path->string path))
- (len (- (string-length path) (bytes-length ext) 1)))
+ (let* ([path (path->string path)]
+ [len (- (string-length path) (bytes-length ext) 1)])
(substring path 0 len)))))
(define (visit-module-path path kind acc)
(case kind
- ((file) (let ((entry (path->entry path)))
- (if entry (cons entry acc) acc)))
- ((dir) (cond ((skippable-dir? path) (values acc #f))
+ [(file) (let ((entry (path->entry path)))
+ (if entry (cons entry acc) acc))]
+ [(dir) (cond ((skippable-dir? path) (values acc #f))
((or (file-exists? (build-path path "main.rkt"))
(file-exists? (build-path path "main.ss")))
(cons (path->string path) acc))
- (else acc)))
- (else acc)))
+ (else acc))]
+ [else acc]))
(define (find-modules path acc)
(if (directory-exists? path)
- (parameterize ((current-directory path))
+ (parameterize ([current-directory path])
(fold-files visit-module-path acc))
acc))
@@ -128,13 +128,13 @@
(map car (cdr idls)))
ls))
(define (classify-ids ids ns)
- (let loop ((ids ids) (procs '()) (vars '()))
- (cond ((null? ids)
- `((procs ,@(reverse procs)) (vars ,@(reverse vars))))
- ((procedure?
+ (let loop ([ids ids] [procs '()] [vars '()])
+ (cond [(null? ids)
+ `((procs ,@(reverse procs)) (vars ,@(reverse vars)))]
+ [(procedure?
(namespace-variable-value (car ids) #t (const #f) ns))
- (loop (cdr ids) (cons (car ids) procs) vars))
- (else (loop (cdr ids) procs (cons (car ids) vars))))))
+ (loop (cdr ids) (cons (car ids) procs) vars)]
+ [else (loop (cdr ids) procs (cons (car ids) vars))])))
(let-values (((reg syn)
(module-compiled-exports
(get-module-code (resolve-module-path mod #f)))))
diff --git a/scheme/racket/geiser/utils.rkt b/scheme/racket/geiser/utils.rkt
index 730a396..4bf9494 100644
--- a/scheme/racket/geiser/utils.rkt
+++ b/scheme/racket/geiser/utils.rkt
@@ -16,10 +16,10 @@
symbol->keyword)
(define (pair->list pair)
- (let loop ((d pair) (s '()))
- (cond ((null? d) (reverse s))
- ((symbol? d) (reverse (cons d s)))
- (else (loop (cdr d) (cons (car d) s))))))
+ (let loop ([d pair] [s '()])
+ (cond [(null? d) (reverse s)]
+ [(symbol? d) (reverse (cons d s))]
+ [else (loop (cdr d) (cons (car d) s))])))
(define keyword->symbol (compose string->symbol keyword->string))
(define (symbol->keyword sym) (string->keyword (format "~a" sym)))