Skip to content

Commit

Permalink
Try to eval "skeleton" of file with error
Browse files Browse the repository at this point in the history
The resulting REPL has a namespace with bindings from module
languages, requires, and definitions. That way things like completion
and racket-describe are more likely to work while you are editing the
file to fix the error.

Closes #272.
  • Loading branch information
Greg Hendershott committed Sep 1, 2017
1 parent 0f8f36e commit 2f13e68
Show file tree
Hide file tree
Showing 5 changed files with 361 additions and 72 deletions.
87 changes: 46 additions & 41 deletions Reference.md
Expand Up @@ -23,33 +23,43 @@

Save and evaluate the buffer in REPL, much like DrRacket's Run.

If point is within a submodule form, the REPL "enters" that
submodule (uses its language info and namespace).
With a C-u prefix, uses errortrace for improved stack traces.
Otherwise follows the [`racket-error-context`](#racket-error-context) setting.

If point is within a Racket `module` form, the REPL "enters"
that submodule (uses its language info and namespace).

When you run again, the file is evaluated from scratch -- the
custodian releases resources like threads and the evaluation
environment is reset to the contents of the file. In other words,
like DrRacket, this provides the predictability of a "static"
baseline, plus the ability to explore interatively using the
baseline, plus the ability to explore interactively using the
REPL.

See also [`racket-run-and-switch-to-repl`](#racket-run-and-switch-to-repl), which is even more like
DrRacket's Run because it selects the REPL window (gives it the
focus), too.

With a C-u prefix, uses errortrace for improved stack traces.
Otherwise follows the [`racket-error-context`](#racket-error-context) setting.
If your source file has a syntax or runtime error, a "skeleton"
of your file is evaluated to get identifiers from module
languages, `require`s, and definitions. That way, things like
completion and [`racket-describe`](#racket-describe) are more likely to work while
you edit the file to fix the error. If not even the "skeleton"
evaluation succeeds, you'll have only identifiers provided by
racket/base, until you fix the error and run again.

Output in the `*Racket REPL*` buffer that describes a file and
position is automatically "linkified". To visit, move point
there and press <kdb>RET</kbd>, mouse click, or use a
Compilation mode command such as C-x ` (next error).
Examples of such text include:
position is automatically "linkified". Examples of such text
include:

- Racket error messages.
- `rackunit` test failure location messages.
- `print`s of `#<path>` objects.

To visit these locations, move point there and press RET or mouse
click. Or, use the standard `next-error` and `previous-error`
commands.

In the `*Racket REPL*` buffer you can issue some special
commands. Some of them are the foundation for Emacs commands.
Others are available only as a command in the REPL.
Expand Down Expand Up @@ -103,13 +113,13 @@ Major mode for results of [`racket-profile`](#racket-profile).
key binding
--- -------
RET racket--profile-visit
, racket--profile-sort
g racket--profile-refresh
n racket--profile-next
p racket--profile-prev
q racket--profile-quit
z racket--profile-show-zero
RET racket--profile-visit
, racket--profile-sort
g racket--profile-refresh
n racket--profile-next
p racket--profile-prev
q racket--profile-quit
z racket--profile-show-zero
```
Expand Down Expand Up @@ -145,15 +155,15 @@ For more information see:
key binding
--- -------
C-c Prefix Command
g racket-logger-clear
l racket-logger-topic-level
n racket-logger-next-item
p racket-logger-previous-item
w toggle-truncate-lines
x racket-logger-exit
C-c Prefix Command
g racket-logger-clear
l racket-logger-topic-level
n racket-logger-next-item
p racket-logger-previous-item
w toggle-truncate-lines
x racket-logger-exit
C-c C-z racket-repl
C-c C-z racket-repl
```
Expand Down Expand Up @@ -534,16 +544,16 @@ special commands to navigate among the definition and its uses.
key binding
--- -------
TAB racket-check-syntax-mode-goto-next-def
. racket-check-syntax-mode-goto-def
h racket-check-syntax-mode-help
j racket-check-syntax-mode-goto-next-def
k racket-check-syntax-mode-goto-prev-def
n racket-check-syntax-mode-goto-next-use
p racket-check-syntax-mode-goto-prev-use
q racket-check-syntax-mode-quit
r racket-check-syntax-mode-rename
<backtab> racket-check-syntax-mode-goto-prev-def
TAB racket-check-syntax-mode-goto-next-def
. racket-check-syntax-mode-goto-def
h racket-check-syntax-mode-help
j racket-check-syntax-mode-goto-next-def
k racket-check-syntax-mode-goto-prev-def
n racket-check-syntax-mode-goto-next-use
p racket-check-syntax-mode-goto-prev-use
q racket-check-syntax-mode-quit
r racket-check-syntax-mode-rename
<backtab> racket-check-syntax-mode-goto-prev-def
```
Expand Down Expand Up @@ -592,7 +602,7 @@ can turn it off by setting `input-method-highlight-flag` to nil via
`M-x customize-variable`.

### racket-align
<kbd>M-]</kbd>
<kbd>M-x racket-align</kbd>

Align values in the same column.

Expand Down Expand Up @@ -652,7 +662,7 @@ usual. For example:
See also: [`racket-unalign`](#racket-unalign).

### racket-unalign
<kbd>M-}</kbd>
<kbd>M-x racket-unalign</kbd>

The opposite of [`racket-align`](#racket-align).

Expand Down Expand Up @@ -841,11 +851,6 @@ Face for self-evaluating expressions like numbers, symbols, strings.
### racket-here-string-face
Face for self-evaluating expressions like numbers, symbols, strings.

### racket-paren-face
No documentation.



### racket-check-syntax-def-face
Face [`racket-check-syntax`](#racket-check-syntax) uses to highlight definitions.

Expand Down
4 changes: 3 additions & 1 deletion error.rkt
Expand Up @@ -67,13 +67,15 @@
(context-item->string x))
"\n"))

(define-runtime-path run.rkt "run.rkt")
(define-runtime-path run.rkt "run.rkt")
(define-runtime-path namespace.rkt "namespace.rkt")
(define (system-context? ci)
(match-define (cons id src) ci)
(or (not src)
(let ([src (srcloc-source src)])
(and (path? src)
(or (equal? src run.rkt)
(equal? src namespace.rkt)
(under-system-path? src))))))

(define (under-system-path? path)
Expand Down

0 comments on commit 2f13e68

Please sign in to comment.