From 5fb83906097b444cb967485f76d616aba98f2fc4 Mon Sep 17 00:00:00 2001 From: Eli Barzilay Date: Mon, 18 Jul 2011 13:44:01 -0400 Subject: [PATCH] Hook XREPL into a few places where `readline' and `enter!' are mentioned. --- collects/scribblings/guide/running.scrbl | 5 +- collects/scribblings/guide/welcome.scrbl | 4 + collects/scribblings/more/more.scrbl | 96 ++++++++++++++++-------- 3 files changed, 72 insertions(+), 33 deletions(-) diff --git a/collects/scribblings/guide/running.scrbl b/collects/scribblings/guide/running.scrbl index 081e8b446a..fa1622313e 100644 --- a/collects/scribblings/guide/running.scrbl +++ b/collects/scribblings/guide/running.scrbl @@ -38,8 +38,9 @@ with a @litchar{> } prompt: > } -@margin-note{For information on GNU Readline support, see -@racketmodname[readline].} +@margin-note{For enhancing your @tech{REPL} experience, see + @racketmodname[xrepl]; for information on GNU Readline support, see + @racketmodname[readline].} To initialize the @tech{REPL}'s environment, @exec{racket} first requires the @racketmodname[racket/init] module, which provides all of diff --git a/collects/scribblings/guide/welcome.scrbl b/collects/scribblings/guide/welcome.scrbl index f56f8ff12f..badb0548f6 100644 --- a/collects/scribblings/guide/welcome.scrbl +++ b/collects/scribblings/guide/welcome.scrbl @@ -1,5 +1,6 @@ #lang scribble/doc @(require scribble/manual scribble/eval scribble/bnf "guide-utils.rkt" + (only-in scribble/core link-element) (for-label racket/enter)) @(define piece-eval (make-base-eval)) @@ -134,6 +135,9 @@ the above text in a file using your favorite editor. If you save it as @filepath{extract.rkt}, then after starting @exec{racket} in the same directory, you'd evaluate the following sequence: +@margin-note{If you use @racketmodname[xrepl], you can use + @(link-element "plainlink" (litchar ",enter extract.rkt") `(xrepl "enter")).} + @interaction[ #:eval piece-eval (eval:alts (enter! "extract.rkt") (void)) diff --git a/collects/scribblings/more/more.scrbl b/collects/scribblings/more/more.scrbl index ce9df39e19..5b198a456e 100644 --- a/collects/scribblings/more/more.scrbl +++ b/collects/scribblings/more/more.scrbl @@ -2,43 +2,58 @@ @(require scribble/manual scribble/urls scribble/eval + (only-in scribble/core link-element) "../quick/keep.rkt" (for-label scheme racket/enter + xrepl readline net/url xml racket/control)) -@(define quick @other-manual['(lib "quick.scrbl" "scribblings/quick")]) -@(define guide @other-manual['(lib "guide.scrbl" "scribblings/guide")]) +@(begin -@(define more-eval (make-base-eval)) -@(interaction-eval #:eval more-eval - (define (show-load re?) - (fprintf (current-error-port) " [~aloading serve.rkt]\n" (if re? "re-" "")))) -@(interaction-eval #:eval more-eval - (define (serve n) void)) -@(interaction-eval #:eval more-eval - (define (show-break) - (fprintf (current-error-port) "^Cuser break"))) -@(interaction-eval #:eval more-eval - (define (show-fail n) - (error 'tcp-listen - "listen on ~a failed (address already in use)" - n))) -@(interaction-eval #:eval more-eval (require xml net/url)) +(define quick @other-manual['(lib "quick.scrbl" "scribblings/quick")]) +(define guide @other-manual['(lib "guide.scrbl" "scribblings/guide")]) -@(define (whole-prog which [last? #f]) +(define more-eval (make-base-eval)) +(interaction-eval #:eval more-eval + (define (show-load re?) + (fprintf (current-error-port) + " [~aloading serve.rkt]\n" (if re? "re-" "")))) +(interaction-eval #:eval more-eval + (define (serve n) void)) +(interaction-eval #:eval more-eval + (define (show-break) + (fprintf (current-error-port) "^Cuser break"))) +(interaction-eval #:eval more-eval + (define (show-fail n) + (error 'tcp-listen + "listen on ~a failed (address already in use)" + n))) +(interaction-eval #:eval more-eval (require xml net/url)) + +(define (whole-prog which [last? #f]) (let ([file (format "step~a.txt" which)]) (margin-note (keep-file file) "Here's the " - (if last? + (if last? "final program" "whole program so far") " in plain text: " (link file "step " which) "."))) +(define-syntax-rule (REQ m) @racket[(require @#,racketmodname[m])]) + +(define (xreplcmd name . args) + (define namestr (format ",~a" name)) + (define content + (litchar (if (null? args) namestr (apply string-append namestr " " args)))) + (link-element "plainlink" content `(xrepl ,(format "~a" name)))) + +) + @title{More: Systems Programming with Racket} @author["Matthew Flatt"] @@ -79,20 +94,36 @@ start @exec{racket} with no command-line arguments: > } -If you're using a plain terminal, if you have GNU Readline installed -on your system, and if you'd like Readline support in @exec{racket}, -then evaluate @racket[(require readline)]. If you also evaluate -@racket[(install-readline!)], then your @filepath{~/.racketrc} is -updated to load Readline whenever you start @exec{racket} for -interactive evaluation. Readline is not needed if you're running a -shell inside Emacs or if you're on Windows and use a @exec{cmd} -window. - -@margin-note{Unfortunately, for legal reasons related to GPL vs. LGPL, - @exec{racket} cannot provide Readline automatically.} +To get a richer read-eval-print-loop, evaluate @REQ[xrepl]. You will +get Readline-based input if you have GNU Readline installed on your +system, and a useful set of meta-commands to support exploration and +development. @interaction[ -(eval:alts (require readline) (void)) +(eval:alts @#,REQ[xrepl] (void)) +] + +To get this as a default, use the @xreplcmd{install!} command---your +@filepath{~/.racketrc} will be updated to load @racketmodname[xrepl] +whenever you start @exec{racket} for interactive evaluation. + +@margin-note{Unfortunately, for legal reasons related to GPL vs. LGPL, + @exec{racket} cannot provide @racketmodname[xrepl] or Readline + automatically.} + +@; FIXME: probably needs revisions, and questionable whether readline +@; should be mentioned by itself. One thing to consider is that with +@; readline it's possible to pretend that the whole thing is one +@; session, whereas xrepl changes the prompt. + +If you want @emph{just} readline support in @exec{racket}, evaluate +@REQ[readline]. To install this in your @filepath{~/.racketrc}, +evaluate @racket[(install-readline!)]. Readline is not needed if you're +using @racketmodname[xrepl], if you're running a shell inside Emacs, or +if you're on Windows and use a @exec{cmd} window. + +@interaction[ +(eval:alts @#,REQ[readline] (void)) (eval:alts (install-readline!) (void)) ] @@ -116,6 +147,9 @@ racket Back in @exec{racket}, try loading the file and running @racket[go]: +@margin-note{If you use @racketmodname[xrepl], you can use + @xreplcmd["enter"]{serve.rkt}.} + @interaction[ #:eval more-eval (eval:alts (enter! "serve.rkt") (show-load #f))