* Commands

** Edit

*** racket-mode
{{{kbd(M-x)}}} ~racket-mode~

Major mode for editing Racket source files.

|Key|Binding|
|{{{kbd(TAB)}}}|~indent-for-tab-command~|
|{{{kbd(C-M-u)}}}|@@texinfo:@ref{racket-backward-up-list}@@|
|{{{kbd(C-c C-p)}}}|@@texinfo:@ref{racket-cycle-paren-shapes}@@|
|{{{kbd(C-c C-s)}}} or {{{kbd(C-c C-.)}}}|@@texinfo:@ref{racket-describe-search}@@|
|{{{kbd(C-c C-d)}}}|@@texinfo:@ref{racket-documentation-search}@@|
|{{{kbd(C-c C-z)}}}|~racket-edit-switch-to-repl~|
|{{{kbd(C-c C-e x)}}}|@@texinfo:@ref{racket-expand-definition}@@|
|{{{kbd(C-c C-e f)}}}|@@texinfo:@ref{racket-expand-file}@@|
|{{{kbd(C-c C-e e)}}}|@@texinfo:@ref{racket-expand-last-sexp}@@|
|{{{kbd(C-c C-e r)}}}|@@texinfo:@ref{racket-expand-region}@@|
|{{{kbd(C-c C-f)}}}|@@texinfo:@ref{racket-fold-all-tests}@@|
|{{{kbd())}}} or {{{kbd(])}}} or {{{kbd(@})}}}|@@texinfo:@ref{racket-insert-closing}@@|
|{{{kbd(C-M-y)}}}|@@texinfo:@ref{racket-insert-lambda}@@|
|{{{kbd(C-c C-l)}}}|@@texinfo:@ref{racket-logger}@@|
|{{{kbd(C-c C-x C-f)}}}|@@texinfo:@ref{racket-open-require-path}@@|
|{{{kbd(C-c C-o)}}}|@@texinfo:@ref{racket-profile}@@|
|{{{kbd(C-c C-c)}}} or {{{kbd(C-c C-k)}}}|@@texinfo:@ref{racket-run-module-at-point}@@|
|{{{kbd(C-M-x)}}}|@@texinfo:@ref{racket-send-definition}@@|
|{{{kbd(C-x C-e)}}}|@@texinfo:@ref{racket-send-last-sexp}@@|
|{{{kbd(C-c C-r)}}}|@@texinfo:@ref{racket-send-region}@@|
|{{{kbd(C-c C-t)}}}|@@texinfo:@ref{racket-test}@@|
|{{{kbd(C-c C-u)}}}|@@texinfo:@ref{racket-unfold-all-tests}@@|



In addition to any hooks its parent mode ~prog-mode~ might have run,
this mode runs the hook ~racket-mode-hook~, as the final or
penultimate step during initialization.

*** racket-insert-lambda
{{{kbd(C-M-y)}}}

Insert λ.

To insert Unicode symbols generally, see @@texinfo:@ref{racket-input-mode}@@.

*** racket-insert-symbol
{{{kbd(M-x)}}} ~racket-insert-symbol~

Insert a symbol from @@texinfo:@ref{racket-input-translations}@@.

A command alternative to the "Racket" input method activated by
@@texinfo:@ref{racket-input-mode}@@.

Presents a ~completing-read~ UI, in which the symbols that would
be inserted are shown as annotations -- a preview unlike what is
currently provided by the Emacs UI for input method.

*** racket-fold-all-tests
{{{kbd(C-c C-f)}}}

Fold (hide) all test submodules.

*** racket-unfold-all-tests
{{{kbd(C-c C-u)}}}

Unfold (show) all test submodules.

*** racket-tidy-requires
{{{kbd(M-x)}}} ~racket-tidy-requires~

Make a single, sorted "require" form for each module.

Use a single require-spec for each phase-level, sorted in this
order: for-syntax, for-template, for-label, for-meta, and
plain (phase 0).

Within each phase-level, sort require-specs by module name.

Format at most one module per line.

Simplify gratuitous require-specs. For example reduce (only-in m)
to m and elide (combine-in).

See also: @@texinfo:@ref{racket-trim-requires}@@ and @@texinfo:@ref{racket-base-requires}@@.

*** racket-trim-requires
{{{kbd(M-x)}}} ~racket-trim-requires~

Like @@texinfo:@ref{racket-tidy-requires}@@ but also delete unnecessary requires.

Use macro-debugger/analysis/check-requires to analyze.

The analysis:

- Needs the ~macro-debugger-lib~ package.

- Only works when the source file can be fully expanded with no
errors.

- Only works for requires at the top level of a source file using
#lang -- not for requires inside submodule forms. Furthermore,
the analysis is not smart about module+ or module* forms -- it
might delete outer requires that are actually needed by such
submodules.

See also: @@texinfo:@ref{racket-base-requires}@@.

*** racket-base-requires
{{{kbd(M-x)}}} ~racket-base-requires~

Change from "#lang racket" to "#lang racket/base".

Using "racket/base" is a recommended optimization for Racket
applications. Loading all of "racket" is slower and uses more
memory.

Add explicit requires for imports that are provided by "racket"
but not by "racket/base".

Also do the equivalent of @@texinfo:@ref{racket-trim-requires}@@ and
~nil~. See those commands for additional notes
and caveats.

Note: Currently this only helps change "#lang racket" to
"#lang racket/base". It does not help with other similar
conversions, such as changing "#lang typed/racket" to "#lang
typed/racket/base".

*** racket-add-require-for-identifier
{{{kbd(M-x)}}} ~racket-add-require-for-identifier~

Add a require for an identifier.

Useful when you know the name of an export but don't remember
from what module it is exported.

After you choose an identifier, this command will:

- Insert the identifier at point if not already there.

- Insert a "require" form and do @@texinfo:@ref{racket-tidy-requires}@@.

Caveat: This works only for identifiers that are documented. The
mechanism is similar to that used for Racket's "Search Manuals"
feature. Today there exists no system-wide database of
identifiers that are exported but not documented.

*** racket-indent-line
{{{kbd(M-x)}}} ~racket-indent-line~

Indent current line as Racket code.

Normally you don't invoke this command directly. Instead, because
it is used as the value for the variable ~indent-line-function~
in @@texinfo:@ref{racket-mode}@@ and @@texinfo:@ref{racket-repl-mode}@@ buffers, it is used
automatically when you press keys like RET or TAB. However you
might refer to it when configuring custom indentation, explained
below.

Following the tradition of ~lisp-mode~ and ~scheme-mode~, the
primary way to determine the indentation of a form is to look for
a rule stored as a ~racket-indent-function~ property.

To extend, use your Emacs init file to

#+BEGIN_SRC emacs-lisp
    (put SYMBOL 'racket-indent-function INDENT)
#+END_SRC

SYMBOL is the name of the Racket form like "test-case" and
INDENT is an integer or the symbol "defun". When INDENT is an
integer, the meaning is the same as for lisp-indent-function and
scheme-indent-function: Indent the first INDENT arguments
specially and indent any further arguments like a body. (The
number may be negative; see discussion below.)

For example:

#+BEGIN_SRC emacs-lisp
    (put 'test-case 'racket-indent-function 1)
#+END_SRC

This will change the indent of ~test-case~ from this:

#+BEGIN_SRC racket
    (test-case foo
               blah
               blah)
#+END_SRC

to this:

#+BEGIN_SRC racket
    (test-case foo
      blah
      blah)
#+END_SRC

For backward compatibility, if ~racket-indent-function~ has no
property for a symbol, a scheme-indent-function property is also
considered, although the "with-" indents defined by scheme-mode
are ignored. This is only to help people who may have extensive
scheme-indent-function settings, particularly in the form of file
or dir local variables. Otherwise prefer putting properties on
~racket-indent-function~.

If no explicit rules match, regular expressions are used for a
couple special cases:

- Forms that start with "begin" indent like "begin".

- Forms that start with "def" or "with-" indent like
  "define".

On the one hand this is convenient when you create your own
"DRY" macros; they will indent as expected without you needing
to make custom indent rules. On the other hand there can be false
matches; for example a function or form named "defer" will
indent like "define". This is a known drawback and is unlikely
to be fixed unless/until Racket macros someday support a protocol
to communicate how they should be indented.

There is also automatic handling for:

- Forms that begin with a #:keyword (as found in contracts)

- Literal forms like #hasheq()

- Quoted forms when the variable @@texinfo:@ref{racket-indent-sequence-depth}@@
  is > 0.

- {} forms when the variable @@texinfo:@ref{racket-indent-curly-as-sequence}@@ is
  not nil.

Finally and otherwise, a form will be indented as if it were a
procedure application.

--- --- ---

Note: Racket Mode extends the traditional Emacs lisp indent spec
to allow a /negative/ integer, which means that all distinguished
forms should align with the first one. This style originated with
"for/fold", which has two distinguished forms. Traditionally
those would indent like this:

#+BEGIN_SRC racket
    (for/fold ([x xs])
        ([y ys])            ; twice body indent
      body)
#+END_SRC

However the popularly desired indent is:

#+BEGIN_SRC racket
    (for/fold ([x xs])
              ([y ys])      ; same as first distingushed form
      body)
#+END_SRC

This idea extends to optional distinguished forms, such as Typed
Racket annotation "prefixes" in "for/fold", "for/x", and
even "let" forms:

#+BEGIN_SRC racket
    (for/fold : Type
              ([x xs])
              ([y ys])      ; same as first distingushed form
      body)
#+END_SRC


*** racket-smart-open-bracket-mode
{{{kbd(M-x)}}} ~racket-smart-open-bracket-mode~

Minor mode to let you always type ~[~' to insert ~(~ or ~[~ automatically.

Behaves like the "Automatically adjust opening square brackets"
feature in Dr. Racket.

By default, inserts a ~(~. Inserts a ~[~ in the following cases:

  - ~let~-like bindings -- forms with ~let~ in the name as well
    as things like ~parameterize~, ~with-handlers~, and
    ~with-syntax~.

  - ~case~, ~cond~, ~match~, ~syntax-case~, ~syntax-parse~, and
    ~syntax-rules~ clauses.

  - ~for~-like bindings and ~for/fold~ accumulators.

  - ~class~ declaration syntax, such as ~init~ and ~inherit~.

When the previous s-expression in a sequence is a compound
expression, uses the same kind of delimiter.

To force insert ~[~, use ~quoted-insert~.

Combined with @@texinfo:@ref{racket-insert-closing}@@ this means that you can
press the unshifted ~[~ and ~]~ keys to get whatever delimiters
follow the Racket conventions for these forms. When something
like ~electric-pair-mode~ or ~paredit-mode~ is active, you need
not even press ~]~.

Tip: When also using ~paredit-mode~, enable that first so that
the binding for the ~[~' key in the map for
@@texinfo:@ref{racket-smart-open-bracket-mode}@@ has higher priority. See also
the variable ~minor-mode-map-alist~.

Tip: When using this with @@texinfo:@ref{racket-hash-lang-mode}@@, you may want
to use @@texinfo:@ref{racket-hash-lang-module-language-hook}@@ to enable it IFF
the module langugage is something like "racket".

This is a minor mode.  If called interactively, toggle the
~Racket-Smart-Open-Bracket mode~ mode.  If the prefix argument is
positive, enable the mode, and if it is zero or negative, disable the
mode.

If called from Lisp, toggle the mode if ARG is ~toggle~.  Enable the
mode if ARG is nil, omitted, or is a positive number.  Disable the mode
if ARG is a negative number.

To check whether the minor mode is enabled in the current buffer,
evaluate the variable @@texinfo:@ref{racket-smart-open-bracket-mode}@@.

The mode's hook is called both when the mode is enabled and when it is
disabled.

*** racket-insert-closing
{{{kbd(])}}}or {{{kbd())}}}

Insert a matching closing delimiter.

With {{{kbd(C-u)}}} insert the typed character as-is.

This is handy if you're not yet using something like
~paredit-mode~, ~smartparens-mode~, ~parinfer-mode~, or simply
~electric-pair-mode~ added in Emacs 24.5.

*** racket-cycle-paren-shapes
{{{kbd(C-c C-p)}}}

Cycle the sexpr among () [] {}.

*** racket-backward-up-list
{{{kbd(C-M-u)}}}

Like ~backward-up-list~ but works when point is in a string or comment.

Typically you should not use this command in Emacs Lisp --
especially not repeatedly. Instead, initially use
~racket--escape-string-or-comment~ to move to the start of a
string or comment, if any, then use normal ~backward-up-list~
repeatedly.

*** racket-input-mode
{{{kbd(M-x)}}} ~racket-input-mode~

A minor mode to enable the "Racket" input method.

The Racket input method lets you type @@texinfo:@ref{racket-input-prefix}@@,
followed by a key sequence from @@texinfo:@ref{racket-input-translations}@@,
directly in a buffer, to insert a symbol.

For example when @@texinfo:@ref{racket-input-prefix}@@ is the default "\", you
can type "\All" and it is immediately replaced with "∀".

To enable @@texinfo:@ref{racket-input-mode}@@ (and the Racket input method) for
all new buffers, put the following in your Emacs init file:

#+BEGIN_SRC elisp
    (dolist (hook '(racket-mode-hook
                    racket-hash-lang-mode-hook
                    racket-repl-mode-hook))
      (add-hook hook #'racket-input-mode))
#+END_SRC

Tip: You may use the standard Emacs key C-\ to toggle the
current input method.

Tip: If you don’t like the highlighting of partially matching
tokens you can disable that using ~input-method-highlight-flag~.

See the Emacs manual for other information about input methods.

Tip: Another way to use @@texinfo:@ref{racket-input-translations}@@ is by using a
command: @@texinfo:@ref{racket-insert-symbol}@@.

This is a minor mode.  If called interactively, toggle the ~Racket-Input
mode~ mode.  If the prefix argument is positive, enable the mode, and if
it is zero or negative, disable the mode.

If called from Lisp, toggle the mode if ARG is ~toggle~.  Enable the
mode if ARG is nil, omitted, or is a positive number.  Disable the mode
if ARG is a negative number.

To check whether the minor mode is enabled in the current buffer,
evaluate the variable @@texinfo:@ref{racket-input-mode}@@.

The mode's hook is called both when the mode is enabled and when it is
disabled.

*** racket-align
{{{kbd(M-x)}}} ~racket-align~

Align values in the same column.

Useful for binding forms like "let" and "parameterize",
conditionals like "cond" and "match", association lists, and
any series of couples like the arguments to "hash".

Before choosing this command, put point on the first of a series
of "couples". A couple is:

- A list of two or more sexprs: "[sexpr val sexpr ...]".
- Two sexprs: "sexpr val".

Each "val" moves to the same column and is
~prog-indent-sexp~-ed (in case it is a multi-line form).

For example with point on the "[" before "a":

#+BEGIN_SRC racket
    Before             After

    (let ([a 12]       (let ([a   12]
          [bar 23])          [bar 23])
      ....)              ....)

    ([a . 12]          ([a   . 12]
     [bar . 23])        [bar . 23])

    (cond [a? #t]      (cond [a?   #t]
          [b? (f x           [b?   (f x
                 y)]                  y)]
          [else #f])         [else #f])
#+END_SRC

Or with point on the quote before "a":

#+BEGIN_SRC racket
    (list a 12        (list a   12
          bar 23)           bar 23)
#+END_SRC

If more than one couple is on the same line, none are aligned,
because it is unclear where the value column should be. For
example the following form will not change; @@texinfo:@ref{racket-align}@@ will
display an error message:

#+BEGIN_SRC racket
    (let ([a 0][b 1]
          [c 2])       error; unchanged
      ....)
#+END_SRC

When a couple's sexprs start on different lines, that couple is
ignored. Other, single-line couples in the series are aligned as
usual. For example:

#+BEGIN_SRC racket
    (let ([foo         (let ([foo
           0]                 0]
          [bar 1]            [bar 1]
          [x 2])             [x   2])
      ....)              ....)
#+END_SRC

See also: @@texinfo:@ref{racket-unalign}@@.

*** racket-unalign
{{{kbd(M-x)}}} ~racket-unalign~

The opposite of @@texinfo:@ref{racket-align}@@.

Effectively does M-x ~just-one-space~ and ~prog-indent-sexp~ for
each couple's value.

*** racket-complete-at-point


A value for the variable ~completion-at-point-functions~.

Completion candidates are drawn from the same symbols used for
font-lock. This is a static list. If you want dynamic, smarter
completion candidates, enable the minor mode @@texinfo:@ref{racket-xp-mode}@@.

** Hash Langs

*** racket-hash-lang-mode
{{{kbd(M-x)}}} ~racket-hash-lang-mode~

Use color-lexer, indent, and navigation supplied by a #lang.

An experimental major mode alternative to @@texinfo:@ref{racket-mode}@@ for
source file edit buffers.

In your Emacs configuration, you may want to update the
variable ~auto-mode-alist~ to use @@texinfo:@ref{racket-hash-lang-mode}@@ for
file extensions like ".rkt", ".scrbl", and/or ".rhm".

Languages supply colors for lexer tokens like strings and
comments; see the customization variable
@@texinfo:@ref{racket-hash-lang-token-face-alist}@@. For more colors see the hook
variable @@texinfo:@ref{racket-hash-lang-module-language-hook}@@, which can also
be used to vary configurations per language.

A discussion of the information provided by a Racket language:

  <https://docs.racket-lang.org/tools/lang-languages-customization.html>

|Key|Binding|
|{{{kbd(TAB)}}}|~indent-for-tab-command~|
|{{{kbd(RET)}}}|~newline-and-indent~|
|{{{kbd(C-c C-z)}}}|~racket-edit-switch-to-repl~|
|{{{kbd(C-c C-e x)}}}|@@texinfo:@ref{racket-expand-definition}@@|
|{{{kbd(C-c C-e f)}}}|@@texinfo:@ref{racket-expand-file}@@|
|{{{kbd(C-c C-e e)}}}|@@texinfo:@ref{racket-expand-last-sexp}@@|
|{{{kbd(C-c C-e r)}}}|@@texinfo:@ref{racket-expand-region}@@|
|{{{kbd(C-c C-f)}}}|@@texinfo:@ref{racket-fold-all-tests}@@|
|{{{kbd(C-M-q)}}}|@@texinfo:@ref{racket-hash-lang-C-M-q-dwim}@@|
|{{{kbd(C-M-b)}}}|@@texinfo:@ref{racket-hash-lang-backward}@@|
|{{{kbd(C-M-d)}}}|@@texinfo:@ref{racket-hash-lang-down}@@|
|{{{kbd(C-M-f)}}}|@@texinfo:@ref{racket-hash-lang-forward}@@|
|{{{kbd(C-M-u)}}}|@@texinfo:@ref{racket-hash-lang-up}@@|
|{{{kbd(C-M-y)}}}|@@texinfo:@ref{racket-insert-lambda}@@|
|{{{kbd(C-c C-l)}}}|@@texinfo:@ref{racket-logger}@@|
|{{{kbd(C-c C-x C-f)}}}|@@texinfo:@ref{racket-open-require-path}@@|
|{{{kbd(C-c C-o)}}}|@@texinfo:@ref{racket-profile}@@|
|{{{kbd(C-c C-c)}}} or {{{kbd(C-c C-k)}}}|@@texinfo:@ref{racket-run-module-at-point}@@|
|{{{kbd(C-M-x)}}}|@@texinfo:@ref{racket-send-definition}@@|
|{{{kbd(C-x C-e)}}}|@@texinfo:@ref{racket-send-last-sexp}@@|
|{{{kbd(C-c C-r)}}}|@@texinfo:@ref{racket-send-region}@@|
|{{{kbd(C-c C-t)}}}|@@texinfo:@ref{racket-test}@@|
|{{{kbd(C-c C-u)}}}|@@texinfo:@ref{racket-unfold-all-tests}@@|




In addition to any hooks its parent mode ~prog-mode~ might have run,
this mode runs the hook ~racket-hash-lang-mode-hook~, as the final or
penultimate step during initialization.

*** racket-hash-lang-backward
{{{kbd(C-M-b)}}}

Like ~backward-sexp~ but uses #lang supplied navigation.

*** racket-hash-lang-forward
{{{kbd(C-M-f)}}}

Like ~forward-sexp~ but uses #lang supplied navigation.

*** racket-hash-lang-up
{{{kbd(C-M-u)}}}

Like ~backward-up-list~ but uses #lang supplied navigation.

*** racket-hash-lang-down
{{{kbd(C-M-d)}}}

Like ~down-list~ but uses #lang supplied navigation.

*** racket-hash-lang-C-M-q-dwim
{{{kbd(C-M-q)}}}

Fill or indent depending on lang lexer's token at point.

When the lang lexer token is...

  - "text", for example in Scribble document text, do
    ~fill-paragraph~.

  - "comment", do ~fill-comment~.

  - "whitespace", give an error message.

  - anything else, do ~prog-indent-sexp~.


** Explore

*** racket-xp-mode
{{{kbd(M-x)}}} ~racket-xp-mode~

A minor mode that analyzes expanded code to explain and explore.

This minor mode is an optional enhancement to @@texinfo:@ref{racket-mode}@@ edit
buffers. Like any minor mode, you can turn it on or off for a
specific buffer. If you always want to use it, put the following
code in your Emacs init file:

#+BEGIN_SRC elisp
    (require 'racket-xp)
    (add-hook 'racket-mode-hook #'racket-xp-mode)
#+END_SRC

Note: This mode won't do anything unless/until the Racket Mode
back end is running. It will try to start the back end
automatically. You do /not/ need to @@texinfo:@ref{racket-run}@@ the buffer you
are editing.

This mode uses the drracket/check-syntax package to analyze
fully-expanded programs, without needing to evaluate a.k.a.
"run" them. The resulting analysis provides information for:

- Visually annotating bindings -- local or imported definitions
  and references to them.

- Visually annotating expressions in a tail position, as well as
  the enclosing expression with respect to which they are in a
  tail position.

- Completion candidates.

- Defintions' source and documentation.

When point is on a definition or use, related items are
highlighted using @@texinfo:@ref{racket-xp-def-face}@@ and @@texinfo:@ref{racket-xp-use-face}@@
-- instead of drawing arrows as in Dr Racket. Information is
displayed using the function(s) in the hook variable
@@texinfo:@ref{racket-show-functions}@@; it is also available when hovering the
mouse cursor.

Note: If you find these point-motion features too distracting
and/or slow, in your ~racket-xp-mode-hook~ you may disable them:

#+BEGIN_SRC elisp
  (require 'racket-xp)
  (add-hook 'racket-xp-mode-hook
            (lambda ()
              (remove-hook 'pre-redisplay-functions
                           #'racket-xp-pre-redisplay
                           t)))
#+END_SRC

The remaining features discussed below will still work.

You may also use commands to navigate among a definition and its
uses, or to rename a local definitions and all its uses:

  - @@texinfo:@ref{racket-xp-next-definition}@@
  - @@texinfo:@ref{racket-xp-previous-definition}@@
  - @@texinfo:@ref{racket-xp-next-use}@@
  - @@texinfo:@ref{racket-xp-previous-use}@@

In the following little example, not only does
drracket/check-syntax distinguish the various "x" bindings, it
understands the two different imports of "define":

#+BEGIN_SRC racket
  #lang racket/base
  (define x 1)
  x
  (let ([x x])
    (+ x 1))
  (module m typed/racket/base
    (define x 2)
    x)
#+END_SRC

When point is on the opening parenthesis of an expression in tail
position, it is highlighted using the face
@@texinfo:@ref{racket-xp-tail-position-face}@@.

When point is on the opening parenthesis of an enclosing
expression with respect to which one or more expressions are in
tail position, it is highlighted using the face
@@texinfo:@ref{racket-xp-tail-target-face}@@.

Furthermore, when point is on the opening parenthesis of either
kind of expression, all of the immediately related expressions
are also highlighted. Various commands move among them:

  - @@texinfo:@ref{racket-xp-tail-up}@@
  - @@texinfo:@ref{racket-xp-tail-down}@@
  - @@texinfo:@ref{racket-xp-tail-next-sibling}@@
  - @@texinfo:@ref{racket-xp-tail-previous-sibling}@@

The function ~racket-xp-complete-at-point~ is added to the
variable ~completion-at-point-functions~. Note that in this case,
it is not smart about submodules; identifiers are assumed to be
definitions from the file's module or its imports. In addition to
supplying completion candidates, it supports the
":company-location" property to inspect the definition of a
candidate and the ":company-doc-buffer" property to view its
documentation.

When you edit the buffer, existing annotations are retained;
their positions are updated to reflect the edit. Annotations for
new or deleted text are not requested until after
@@texinfo:@ref{racket-xp-after-change-refresh-delay}@@ seconds. The request is
made asynchronously so that Emacs will not block -- for
moderately complex source files, it can take some seconds simply
to fully expand them, as well as a little more time for the
drracket/check-syntax analysis. When the results are ready, all
annotations for the buffer are completely refreshed.

You may also set @@texinfo:@ref{racket-xp-after-change-refresh-delay}@@ to nil
and use the ~racket-xp-annotate~ command manually.

The mode line changes to reflect the current status of
annotations, and whether or not you had a syntax error.

If you have one or more syntax errors, ~next-error~ and
~previous-error~ navigate among them. Although most languages
will stop after the first syntax error, some like Typed Racket
will try to collect and report multiple errors.

You may use ~xref-find-definitions~ {{{kbd(M-.)}}},
~xref-pop-marker-stack~ {{{kbd(M-x)}}} ~xref-pop-marker-stack~, and
~xref-find-references~: @@texinfo:@ref{racket-xp-mode}@@ adds a backend to the
variable ~xref-backend-functions~. This backend uses information
from the drracket/check-syntax static analysis. Its ability to
find references is limited to the current file; when it finds
none it will try the default xref backend implementation which is
grep-based.

Tip: This mode follows the convention that a minor mode may only
use a prefix key consisting of "C-c" followed by a punctuation
key. As a result, ~racket-xp-control-c-hash-keymap~ is bound to
"C-c #" by default. Although you might find this awkward to
type, remember that as an Emacs user, you are free to bind this
map to a more convenient prefix, and/or bind any individual
commands directly to whatever keys you prefer.

|Key|Binding|
|{{{kbd(C-c # N)}}}|~next-error~|
|{{{kbd(C-c # P)}}}|~previous-error~|
|{{{kbd(C-c C-s)}}}|@@texinfo:@ref{racket-describe-search}@@|
|{{{kbd(C-c # g)}}}|~racket-xp-annotate~|
|{{{kbd(C-c C-.)}}}|@@texinfo:@ref{racket-xp-describe}@@|
|{{{kbd(C-c C-d)}}}|@@texinfo:@ref{racket-xp-documentation}@@|
|{{{kbd(C-c # j)}}}|@@texinfo:@ref{racket-xp-next-definition}@@|
|{{{kbd(C-c # n)}}}|@@texinfo:@ref{racket-xp-next-use}@@|
|{{{kbd(C-c # k)}}}|@@texinfo:@ref{racket-xp-previous-definition}@@|
|{{{kbd(C-c # p)}}}|@@texinfo:@ref{racket-xp-previous-use}@@|
|{{{kbd(C-c # r)}}}|~racket-xp-rename~|
|{{{kbd(C-c # v)}}}|@@texinfo:@ref{racket-xp-tail-down}@@|
|{{{kbd(C-c # >)}}}|@@texinfo:@ref{racket-xp-tail-next-sibling}@@|
|{{{kbd(C-c # <)}}}|@@texinfo:@ref{racket-xp-tail-previous-sibling}@@|
|{{{kbd(C-c # ^)}}}|@@texinfo:@ref{racket-xp-tail-up}@@|
|{{{kbd(M-.)}}} or {{{kbd(C-c # .)}}}|~xref-find-definitions~|
|{{{kbd(C-c # ?)}}}|~xref-find-references~|



This is a minor mode.  If called interactively, toggle the ~Racket-Xp
mode~ mode.  If the prefix argument is positive, enable the mode, and if
it is zero or negative, disable the mode.

If called from Lisp, toggle the mode if ARG is ~toggle~.  Enable the
mode if ARG is nil, omitted, or is a positive number.  Disable the mode
if ARG is a negative number.

To check whether the minor mode is enabled in the current buffer,
evaluate the variable @@texinfo:@ref{racket-xp-mode}@@.

The mode's hook is called both when the mode is enabled and when it is
disabled.

*** racket-xp-describe
{{{kbd(C-c C-.)}}}

Describe the identifier at point.

The command varies based on how many {{{kbd(C-u)}}} command prefixes you supply.

- {{{kbd(C-c C-.)}}}

  Uses the symbol at point. If no such symbol exists, you are
  prompted enter the identifier, but in this case it only
  considers definitions or imports at the file's module level --
  not local bindings nor definitions in submodules.

  - If the identifier has installed Racket documentation, then a
    simplified version of the HTML is presented in the buffer,
    including the "blue box", documentation prose, and
    examples.

  - Otherwise, if the identifier is a function, then its
    signature is displayed, for example "(name arg-1-name
    arg-2-name)".

- {{{kbd(C-u)}}} {{{kbd(C-c C-.)}}}

  Always prompts you to enter a symbol, defaulting to the symbol
  at point if any.

- {{{kbd(C-u)}}} {{{kbd(C-u)}}} {{{kbd(C-c C-.)}}}

  This is an alias for @@texinfo:@ref{racket-describe-search}@@, which uses
  installed documentation in a @@texinfo:@ref{racket-describe-mode}@@ buffer
  instead of an external web browser.

The intent is to give a quick reminder or introduction to
something, regardless of whether it has installed documentation
-- and to do so within Emacs, without switching to a web browser.

This buffer is also displayed when you use ~company-mode~ and
press F1 or C-h in its pop up completion list.

*** racket-xp-documentation
{{{kbd(C-c C-d)}}}

View documentation in an external web browser.

The command varies based on how many {{{kbd(C-u)}}}
command prefixes you supply.

- {{{kbd(C-c C-d)}}}

  Uses the symbol at point. Tries to find documentation for an
  identifer defined in the expansion of the current buffer.

  If no such identifer exists, opens the Search Manuals page. In
  this case, the variable @@texinfo:@ref{racket-documentation-search-location}@@
  determines whether the search is done locally as with ~raco
  doc~, or visits a URL.

- {{{kbd(C-u)}}} {{{kbd(C-c C-d)}}}

  Always prompts you to enter a symbol, defaulting to the symbol
  at point if any.

- {{{kbd(C-u)}}} {{{kbd(C-u)}}} {{{kbd(C-c C-d)}}}

  Always prompts you to enter anything, defaulting to the symbol
  at point if any.

  Proceeds directly to the Search Manuals page. Use this if you
  would like to see documentation for all identifiers named
  "define", for example.

*** racket-xp-next-definition
{{{kbd(C-c # j)}}}

Move point to the next definition.

*** racket-xp-previous-definition
{{{kbd(C-c # k)}}}

Move point to the previous definition.

*** racket-xp-next-use
{{{kbd(C-c # n)}}}

When point is on a use, go to the next, sibling use.

*** racket-xp-previous-use
{{{kbd(C-c # p)}}}

When point is on a use, go to the previous, sibling use.

*** racket-xp-next-error
{{{kbd(M-x)}}} ~racket-xp-next-error~

An obsolete alias for ~next-error~.

*** racket-xp-previous-error
{{{kbd(M-x)}}} ~racket-xp-previous-error~

An obsolete alias for ~previous-error~.

*** racket-xp-tail-up
{{{kbd(C-c # ^)}}}

Go "up" to the expression enclosing an expression in tail position.

When point is on the opening parenthesis of an expression in tail
position, go its "target" -- that is, go to the enclosing
expression with the same continuation as the tail expression.

*** racket-xp-tail-down
{{{kbd(C-c # v)}}}

Go "down" to the first tail position enclosed by the current expression.

*** racket-xp-tail-next-sibling
{{{kbd(C-c # >)}}}

Go to the next tail position sharing the same enclosing expression.

*** racket-xp-tail-previous-sibling
{{{kbd(C-c # <)}}}

Go to the previous tail position sharing the same enclosing expression.

*** racket-documentation-search
{{{kbd(C-c C-d)}}}

Search documentation.

This command is useful in several situations:

- You are not using @@texinfo:@ref{racket-xp-mode}@@ for a @@texinfo:@ref{racket-mode}@@ edit
  buffer, so @@texinfo:@ref{racket-xp-documentation}@@ is not available.

- There is no @@texinfo:@ref{racket-repl-mode}@@ buffer with a live namespace, so
  @@texinfo:@ref{racket-repl-documentation}@@ is not available or helpful.

- You want to search for definitions provided by all modules --
  for example, the "define" syntax provided by racket/base, by
  typed/racket/base, and by other modules, as well definitions or
  topics that merely include "define".

This command does not try to go directly to the help topic for a
definition provided by any specific module. Instead it goes to
the Racket "Search Manuals" page.

*** racket-describe-mode
{{{kbd(M-x)}}} ~racket-describe-mode~

Major mode for viewing Racket documentation.

Many of the default key bindings are similar to ~Info-mode~, as
listed below.

To see "On this page" links, use {{{kbd(M-g i)}}} for ~imenu~, or,
when ~context-menu-mode~ is enabled, right click the mouse.

Supports bookmarks: ~bookmark-set~.

Supports org links: ~org-store-link~, ~org-insert-link~, and
~org-open-at-point~.

Internal, intra-doc links -- which go to other doc pages in the
same @@texinfo:@ref{racket-describe-mode}@@ buffer in Emacs -- are given
@@texinfo:@ref{racket-doc-link-face}@@ unless the documentation specifies some
non-default face.

External links -- which are opened using the variable
@@texinfo:@ref{racket-browse-url-function}@@, by default in an external web
browser program -- are given @@texinfo:@ref{racket-ext-link-face}@@.

|Key|Binding|
|{{{kbd(<)}}}|~beginning-of-buffer~|
|{{{kbd(>)}}}|~end-of-buffer~|
|{{{kbd(q)}}}|~quit-window~|
|{{{kbd(l)}}} or {{{kbd(b)}}} or {{{kbd(C-c C-b)}}}|~racket-describe-back~|
|{{{kbd(x)}}}|~racket-describe-browse-external~|
|{{{kbd(r)}}} or {{{kbd(f)}}} or {{{kbd(C-c C-f)}}}|~racket-describe-forward~|
|{{{kbd(n)}}}|~racket-describe-nav-next~|
|{{{kbd(p)}}}|~racket-describe-nav-prev~|
|{{{kbd(C-^)}}}|~racket-describe-nav-top~|
|{{{kbd(^)}}}|~racket-describe-nav-up~|
|{{{kbd(i)}}} or {{{kbd(C-c C-s)}}}|@@texinfo:@ref{racket-describe-search}@@|
|{{{kbd(g)}}}|~revert-buffer~|
|{{{kbd(DEL)}}} or {{{kbd(S-SPC)}}}|~scroll-down-command~|
|{{{kbd(SPC)}}}|~scroll-up-command~|



In addition to any hooks its parent mode ~special-mode~ might have
run, this mode runs the hook ~racket-describe-mode-hook~, as the final
or penultimate step during initialization.

*** racket-describe-search
{{{kbd(C-c C-.)}}}or {{{kbd(C-c C-s)}}}

Search installed documentation; view using @@texinfo:@ref{racket-describe-mode}@@.

** Run

*** racket-repl-mode
{{{kbd(M-x)}}} ~racket-repl-mode~

Major mode for Racket REPL.

You may use ~xref-find-definitions~ {{{kbd(M-.)}}} and
~xref-pop-marker-stack~ {{{kbd(M-x)}}} ~xref-pop-marker-stack~:
@@texinfo:@ref{racket-repl-mode}@@ adds a backend to the variable
~xref-backend-functions~. This backend uses information about
identifier bindings and modules from the REPL's namespace.

|Key|Binding|
|{{{kbd(TAB)}}}|~indent-for-tab-command~|
|{{{kbd(C-j)}}}|~newline-and-indent~|
|{{{kbd(C-M-q)}}}|~prog-indent-sexp~|
|{{{kbd(C-M-u)}}}|@@texinfo:@ref{racket-backward-up-list}@@|
|{{{kbd(C-c C-s)}}}|@@texinfo:@ref{racket-describe-search}@@|
|{{{kbd(C-c C-e x)}}}|@@texinfo:@ref{racket-expand-definition}@@|
|{{{kbd(C-c C-e f)}}}|@@texinfo:@ref{racket-expand-file}@@|
|{{{kbd(C-c C-e e)}}}|@@texinfo:@ref{racket-expand-last-sexp}@@|
|{{{kbd(C-c C-e r)}}}|@@texinfo:@ref{racket-expand-region}@@|
|{{{kbd())}}} or {{{kbd(])}}} or {{{kbd(@})}}}|@@texinfo:@ref{racket-insert-closing}@@|
|{{{kbd(C-M-y)}}}|@@texinfo:@ref{racket-insert-lambda}@@|
|{{{kbd(C-c C-l)}}}|@@texinfo:@ref{racket-logger}@@|
|{{{kbd(C-c C-c)}}}|~racket-repl-break~|
|{{{kbd(C-c C-u)}}}|~racket-repl-clear-input~|
|{{{kbd(C-c C-o)}}}|~racket-repl-delete-output~|
|{{{kbd(C-c C-.)}}}|@@texinfo:@ref{racket-repl-describe}@@|
|{{{kbd(C-c C-d)}}}|@@texinfo:@ref{racket-repl-documentation}@@|
|{{{kbd(C-c C-\)}}}|~racket-repl-exit~|
|{{{kbd(M-n)}}}|~racket-repl-next-input~|
|{{{kbd(C-c C-n)}}}|~racket-repl-next-prompt-or-run~|
|{{{kbd(M-p)}}}|~racket-repl-previous-input~|
|{{{kbd(C-c C-p)}}}|~racket-repl-previous-prompt-or-run~|
|{{{kbd(RET)}}}|~racket-repl-submit~|
|{{{kbd(C-c C-z)}}}|~racket-repl-switch-to-edit~|



This mode runs the hook ~racket-repl-mode-hook~, as the final or
penultimate step during initialization.

*** racket-run
{{{kbd(M-x)}}} ~racket-run~

Save the buffer in REPL and run your program.

As well as evaluating the outermost, file module, automatically
runs the submodules specified by the customization variable
@@texinfo:@ref{racket-submodules-to-run}@@.

See also @@texinfo:@ref{racket-run-module-at-point}@@, which runs just the
specific module at point.

The command varies based on how many {{{kbd(C-u)}}}
prefix arguments you supply.

- {{{kbd(<f5>)}}}

  Follows the @@texinfo:@ref{racket-error-context}@@ setting.

- {{{kbd(C-u)}}} {{{kbd(<f5>)}}}

  Uses errortrace for improved stack traces, as if
  @@texinfo:@ref{racket-error-context}@@ were set to "high".

  This lets you keep @@texinfo:@ref{racket-error-context}@@ set to a faster
  value like "low" or "medium", then conveniently re-run
  when you need a better strack trace.

- {{{kbd(C-u)}}} {{{kbd(C-u)}}} {{{kbd(<f5>)}}}

  Instruments code for step debugging. See @@texinfo:@ref{racket-debug-mode}@@
  and the variable @@texinfo:@ref{racket-debuggable-files}@@.

Each run occurs within a Racket custodian. Any prior run's
custodian is shut down, releasing resources like threads and
ports. Each run's evaluation environment is reset to the contents
of the source file. In other words, like Dr Racket, this provides
the benefit that your source file is the "single source of
truth". At the same time, the run gives you a REPL inside the
namespace of the module, giving you the ability to explore it
interactively. Any explorations are temporary, unless you also
make them to your source file, they will be lost on the next run.

See also @@texinfo:@ref{racket-run-and-switch-to-repl}@@, which is even more like
Dr Racket's Run command because it selects the REPL window after
running.

To visit error locations, move point there and press RET or mouse
click. Or, use the standard ~next-error~ and ~previous-error~
commands from either the edit or REPL buffer.

*** racket-run-and-switch-to-repl
{{{kbd(<f5>)}}}

This is @@texinfo:@ref{racket-run}@@ followed by selecting the REPL buffer window.

This is similar to how Dr Racket behaves.

To make it even more similar, you may add @@texinfo:@ref{racket-repl-clear}@@ to
the variable @@texinfo:@ref{racket-before-run-hook}@@.

*** racket-run-module-at-point
{{{kbd(C-c C-k)}}}or {{{kbd(C-c C-c)}}}

Save the buffer and run the module at point.

Like @@texinfo:@ref{racket-run}@@ but runs the innermost module around point,
which is determined textually by looking for "module",
"module*", or "module+" forms nested to any depth, else
simply the outermost, file module.

*** racket-repl
{{{kbd(M-x)}}} ~racket-repl~

Show a Racket REPL buffer in some window.

The intended use of Racket Mode's REPL is that you ~find-file~
some specific file, then run it using a command like @@texinfo:@ref{racket-run}@@
or @@texinfo:@ref{racket-run-module-at-point}@@. The resulting REPL will
correspond to those definitions and match your expectations.

Therefore this @@texinfo:@ref{racket-repl}@@ command -- which is intended as a
convenience for people who want to "just get a quick scratch
REPL" -- is actually implemented as running the file named in
the customization variable @@texinfo:@ref{racket-repl-command-file}@@. When that
file doesn't exist, it is created to contain just "#lang
racket/base". You may edit the file to use a different lang,
require other modules, or whatever.

*** racket-repl-describe
{{{kbd(C-c C-.)}}}

Describe the identifier at point.

The command varies based on how many {{{kbd(C-u)}}} prefix arguments you supply.

- {{{kbd(C-c C-.)}}}

  Uses the symbol at point. If no such symbol exists, you are
  prompted enter the identifier, but in this case it only
  considers definitions or imports at the file's module level --
  not local bindings nor definitions in submodules.

  - If the identifier has installed Racket documentation, then a
    simplified version of the HTML is presented in the buffer,
    including the "blue box", documentation prose, and
    examples.

  - Otherwise, if the identifier is a function, then its
    signature is displayed, for example "(name arg-1-name
    arg-2-name)".

- {{{kbd(C-u)}}} {{{kbd(C-c C-.)}}}

  Always prompts you to enter a symbol, defaulting to the symbol
  at point if any.

- {{{kbd(C-u)}}} {{{kbd(C-u)}}} {{{kbd(C-c C-.)}}}

  This is an alias for @@texinfo:@ref{racket-describe-search}@@, which uses
  installed documentation in a @@texinfo:@ref{racket-describe-mode}@@ buffer
  instead of an external web browser.

The intent is to give a quick reminder or introduction to
something, regardless of whether it has installed documentation
-- and to do so within Emacs, without switching to a web browser.

*** racket-repl-documentation
{{{kbd(C-c C-d)}}}

View documentation in an external web browser.

The command varies based on how many {{{kbd(C-u)}}} command prefixes you supply.

- {{{kbd(C-c C-d)}}}

  Uses the symbol at point. Tries to find documentation for an
  identifer defined in the current namespace.

  If no such identifer exists, opens the Search Manuals page. In
  this case, the variable @@texinfo:@ref{racket-documentation-search-location}@@
  determines whether the search is done locally as with ~raco
  doc~, or visits a URL.

- {{{kbd(C-u)}}} {{{kbd(C-c C-d)}}}

  Prompts you to enter a symbol, defaulting to the symbol at
  point if any.

- {{{kbd(C-u)}}} {{{kbd(C-u)}}} {{{kbd(C-c C-d)}}}

  Prompts you to enter anything, defaulting to the symbol at
  point if any.

  Proceeds directly to the Search Manuals page. Use this if you
  would like to see documentation for all identifiers named
  "define", for example.

*** racket-racket
{{{kbd(C-M-<f5>)}}}

Use command-line racket to run the file.

Uses a shell or terminal buffer as specified by the configuration
variable @@texinfo:@ref{racket-shell-or-terminal-function}@@.

*** racket-profile
{{{kbd(C-c C-o)}}}

Like @@texinfo:@ref{racket-run-module-at-point}@@ but with profiling.

Results are presented in a @@texinfo:@ref{racket-profile-mode}@@ buffer, which
also lets you quickly view the source code.

You may evaluate expressions in the REPL. They are also profiled.
Use ~racket-profile-refresh~ to see the updated results. In
other words a possible workflow is: @@texinfo:@ref{racket-profile}@@ a .rkt file,
call one its functions in the REPL, and refresh the profile
results.

Caveat: Only source files are instrumented. You may need to
delete compiled/*.zo files.

*** racket-profile-mode
{{{kbd(M-x)}}} ~racket-profile-mode~

Major mode for results of @@texinfo:@ref{racket-profile}@@.

|Key|Binding|
|{{{kbd(q)}}}|~quit-window~|
|{{{kbd(g)}}}|~racket-profile-refresh~|
|{{{kbd(f)}}}|~racket-profile-show-non-project~|
|{{{kbd(z)}}}|~racket-profile-show-zero~|
|{{{kbd(.)}}} or {{{kbd(RET)}}}|~racket-profile-visit~|




In addition to any hooks its parent mode ~tabulated-list-mode~ might
have run, this mode runs the hook ~racket-profile-mode-hook~, as the
final or penultimate step during initialization.

*** racket-logger
{{{kbd(C-c C-l)}}}

Create the @@texinfo:@ref{racket-logger-mode}@@ buffer.

*** racket-logger-mode
{{{kbd(M-x)}}} ~racket-logger-mode~

Major mode for Racket logger output.

The customization variable @@texinfo:@ref{racket-logger-config}@@ determines the
levels for topics. During a session you may change topic levels
using ~racket-logger-topic-level~.

For more information see:
  <https://docs.racket-lang.org/reference/logging.html>

|Key|Binding|
|{{{kbd(g)}}}|~racket-logger-clear~|
|{{{kbd(n)}}}|~racket-logger-next-item~|
|{{{kbd(p)}}}|~racket-logger-previous-item~|
|{{{kbd(l)}}}|~racket-logger-topic-level~|
|{{{kbd(w)}}}|~toggle-truncate-lines~|




In addition to any hooks its parent mode ~special-mode~ might have
run, this mode runs the hook ~racket-logger-mode-hook~, as the final
or penultimate step during initialization.

*** racket-debug-mode
{{{kbd(M-x)}}} ~racket-debug-mode~

Minor mode for debug breaks.

This feature is **EXPERIMENTAL**!!! It is likely to have
significant limitations and bugs. You are welcome to open an
issue to provide feedback. Please understand that this feature
might never be improved -- it might even be removed someday if it
turns out to have too little value and/or too much cost.

How to debug:

1. "Instrument" code for step debugging.

   Use two {{{kbd(C-u)}}} command prefixes for either
   @@texinfo:@ref{racket-run}@@ or @@texinfo:@ref{racket-run-module-at-point}@@.

   The file will be instrumented for step debugging before it is
   run. Any imported files are also instrumented if they are in
   the variable @@texinfo:@ref{racket-debuggable-files}@@.

   The run will break at the first breakable position.

   Tip: After you run to completion and return to a normal
   REPL prompt, the code remains instrumented. You may enter
   expressions that evaluate instrumented code and it will
   break so you can step debug again.

2. When a break occurs, the @@texinfo:@ref{racket-repl-mode}@@ prompt changes. In
   this debug REPL, local variables are available for you to use
   and even to ~set!~.

   Also, in the @@texinfo:@ref{racket-mode}@@ buffer where the break is located,
   @@texinfo:@ref{racket-debug-mode}@@ is enabled. This minor mode makes the
   buffer read-only, provides visual feedback -- about the break
   position, local variable values, and result values -- and
   provides shortcut keys:

|Key|Binding|
|{{{kbd(c)}}}|~racket-debug-continue~|
|{{{kbd(g)}}}|~racket-debug-go~|
|{{{kbd(?)}}}|~racket-debug-help~|
|{{{kbd(n)}}}|~racket-debug-next-breakable~|
|{{{kbd(N)}}}|~racket-debug-next-breakpoint~|
|{{{kbd(p)}}}|~racket-debug-prev-breakable~|
|{{{kbd(P)}}}|~racket-debug-prev-breakpoint~|
|{{{kbd(h)}}}|~racket-debug-run-to-here~|
|{{{kbd(SPC)}}}|~racket-debug-step~|
|{{{kbd(u)}}}|~racket-debug-step-out~|
|{{{kbd(o)}}}|~racket-debug-step-over~|
|{{{kbd(!)}}}|@@texinfo:@ref{racket-debug-toggle-breakpoint}@@|



This is a minor mode.  If called interactively, toggle the ~Racket-Debug
mode~ mode.  If the prefix argument is positive, enable the mode, and if
it is zero or negative, disable the mode.

If called from Lisp, toggle the mode if ARG is ~toggle~.  Enable the
mode if ARG is nil, omitted, or is a positive number.  Disable the mode
if ARG is a negative number.

To check whether the minor mode is enabled in the current buffer,
evaluate the variable @@texinfo:@ref{racket-debug-mode}@@.

The mode's hook is called both when the mode is enabled and when it is
disabled.

*** racket-repl-clear


Delete all text in the REPL.

A suitable value for the hook @@texinfo:@ref{racket-before-run-hook}@@ if you
want the REPL buffer to be cleared before each run, much like
with Dr Racket. To do so you can use ~customize~, or, add to your
Emacs init file something like:

  (add-hook 'racket-before-run-hook #'racket-repl-clear)

See also the command @@texinfo:@ref{racket-repl-clear-leaving-last-prompt}@@.

*** racket-repl-clear-leaving-last-prompt
{{{kbd(M-x)}}} ~racket-repl-clear-leaving-last-prompt~

Delete all text in the REPL, except for the last prompt.

** Test

*** racket-test
{{{kbd(C-<f5>)}}}or {{{kbd(C-c C-t)}}}

Run the "test" submodule.

Put your tests in a "test" submodule. For example:

#+BEGIN_SRC racket
    (module+ test
      (require rackunit)
      (check-true #t))
#+END_SRC

Any rackunit test failure messages show the location. You may use
~next-error~ to jump to the location of each failing test.

With {{{kbd(C-u)}}} uses errortrace for improved stack traces.
Otherwise follows the @@texinfo:@ref{racket-error-context}@@ setting.

With {{{kbd(C-u)}}} {{{kbd(C-u)}}} also runs the
tests with coverage instrumentation and highlights uncovered code
using ~font-lock-warning-face~.

See also:
- @@texinfo:@ref{racket-fold-all-tests}@@
- @@texinfo:@ref{racket-unfold-all-tests}@@


*** racket-raco-test
{{{kbd(M-x)}}} ~racket-raco-test~

Use command-line raco test to run the "test" submodule.

Uses a shell or terminal buffer as specified by the configuration
variable @@texinfo:@ref{racket-shell-or-terminal-function}@@.

** Eval

*** racket-send-region
{{{kbd(C-c C-r)}}}

Send the current region (if any) to the Racket REPL.

See the customization variable @@texinfo:@ref{racket-repl-echo-sent-expressions}@@.

*** racket-send-definition
{{{kbd(C-M-x)}}}

Send the current definition to the Racket REPL.

See the customization variable @@texinfo:@ref{racket-repl-echo-sent-expressions}@@.

*** racket-send-last-sexp
{{{kbd(C-x C-e)}}}

Send the expression before point to the Racket REPL.

The expression may be either an at-expression or an s-expression.

When the expression is a sexp comment, the sexp itself is sent,
without the #; prefix.

See the customization variable @@texinfo:@ref{racket-repl-echo-sent-expressions}@@.

** Collections

*** racket-open-require-path
{{{kbd(C-c C-x C-f)}}}

Like Dr Racket's Open Require Path.

Type (or delete) characters that are part of a module path name.
"Fuzzy" matches appear. For example try typing "t/t/r".

Choices are displayed in a vertical list. The current choice is
at the top, marked with "->".

- C-n and C-p move among the choices.
- RET on a directory adds its contents to the choices.
- RET on a file exits doing ~find-file~.
- C-g aborts.

** Macro expand

*** racket-stepper-mode
{{{kbd(M-x)}}} ~racket-stepper-mode~

Major mode for Racket stepper output.

Used by the commands @@texinfo:@ref{racket-expand-file}@@,
@@texinfo:@ref{racket-expand-definition}@@, @@texinfo:@ref{racket-expand-region}@@, and
@@texinfo:@ref{racket-expand-last-sexp}@@.

|Key|Binding|
|{{{kbd(n)}}} or {{{kbd(j)}}}|~racket-stepper-next-item~|
|{{{kbd(p)}}} or {{{kbd(k)}}}|~racket-stepper-previous-item~|
|{{{kbd(g)}}}|~racket-stepper-refresh~|
|{{{kbd(RET)}}}|~racket-stepper-step~|




In addition to any hooks its parent mode ~special-mode~ might have
run, this mode runs the hook ~racket-stepper-mode-hook~, as the final
or penultimate step during initialization.

*** racket-expand-file
{{{kbd(C-c C-e f)}}}

Expand the @@texinfo:@ref{racket-mode}@@ buffer's file in @@texinfo:@ref{racket-stepper-mode}@@.

Uses the ~macro-debugger~ package to do the expansion.

You do _not_ need to @@texinfo:@ref{racket-run}@@ the file first; the namespace
active in the REPL is not used.

If the file is non-trivial and/or is not compiled to a .zo
bytecode file, then it might take many seconds before the
original form is displayed and you can start stepping.

With {{{kbd(C-u)}}} behaves as if @@texinfo:@ref{racket-expand-hiding}@@
were 'disabled.

*** racket-expand-region
{{{kbd(C-c C-e r)}}}

Expand the active region using @@texinfo:@ref{racket-stepper-mode}@@.

Uses the ~macro-debugger~ package to do the expansion.

With {{{kbd(C-u)}}} behaves as if @@texinfo:@ref{racket-expand-hiding}@@
were 'disabled.

*** racket-expand-definition
{{{kbd(C-c C-e x)}}}

Expand the definition around point using @@texinfo:@ref{racket-stepper-mode}@@.

Uses the ~macro-debugger~ package to do the expansion.

With {{{kbd(C-u)}}} behaves as if @@texinfo:@ref{racket-expand-hiding}@@
were 'disabled.

*** racket-expand-last-sexp
{{{kbd(C-c C-e e)}}}

Expand the sexp before point using @@texinfo:@ref{racket-stepper-mode}@@.

Uses the ~macro-debugger~ package to do the expansion.

With {{{kbd(C-u)}}} behaves as if @@texinfo:@ref{racket-expand-hiding}@@
were 'disabled.

** Packages

*** racket-package-refresh
{{{kbd(M-x)}}} ~racket-package-refresh~

Refresh the local copy of package catalogs.

Will make HTTP requests to remote catalog servers. May take a few
seconds to complete.

*** list-racket-packages
{{{kbd(M-x)}}} ~list-racket-packages~

Open a @@texinfo:@ref{racket-package-mode}@@ buffer for the active back end.

*** racket-package-mode
{{{kbd(M-x)}}} ~racket-package-mode~

Major mode for Racket package management.

The list of packages is equivalent to "raco pkg show -all" on
the active back end -- that is, all packages installed manually
or as dependencies -- plus packages available from your
configured catalogs, assuming you have run the command
@@texinfo:@ref{racket-package-refresh}@@.

On each row you can press RET to ~describe-racket-package~, which
opens a buffer where you can view details, and use buttons to
install/update/remove the package.

|Key|Binding|
|{{{kbd(RET)}}}|~racket-package-describe~|




In addition to any hooks its parent mode ~tabulated-list-mode~ might
have run, this mode runs the hook ~racket-package-mode-hook~, as the
final or penultimate step during initialization.

*** describe-racket-package
{{{kbd(M-x)}}} ~describe-racket-package~

Describe details of a Racket package.

Depending on the package status, buttons let you install, update,
and/or remove the package and its dependencies. These convenience
buttons are equivalent to using the command line on the active
back end to do "raco pkg {install update remove} --auto". For
other operations, you still need to use "raco pkg" yourself;
see <https://docs.racket-lang.org/pkg/cmdline.html>.

Detail values are links when possible:

- The /Catalog/ (when "https://pkgs.racket-lang.org") links to
  the package's web page, which may have additional details not
  available locally.

- The /Source/ links to the repo's web page or local filesystem.

- The /Directory/ for an installed package opens a dired buffer.

- Each /Dependencies/ name links to details about that package.

- For installed packages, each /Modules/ item links to the local
  file. There is also a button to each module's locally installed
  documentation, if any.

If the package is available from a catalog, additional details
will be shown, assuming you have run the command
@@texinfo:@ref{racket-package-refresh}@@.

** Other

*** racket-debug-toggle-breakpoint
{{{kbd(M-x)}}} ~racket-debug-toggle-breakpoint~

Add or remove a breakpoint.

Each breakpoint has a condition and a list of actions.

The condition is a Racket expression that is evaluated in a
context where local variables exist. Examples:

  - "#t" means break always.

  - If the code around the breakpoint is something like
     "(for ([n 100]) _)", then a condition like
     "(zero? (modulo n 10))" is every 10 times through the
     loop.

Actions is a list of symbols; you may specify one or more. The
action symbols are:

  - "break" causes a break, enabling @@texinfo:@ref{racket-debug-mode}@@.

  - "log" and "print" display information about local
    variables to the logger or REPL output, respectively.
    Although @@texinfo:@ref{racket-debug-mode}@@ already shows these values "in
    situ" when you reach a break, this may be useful if you want
    a history. Specifying "log" or "print", but not
    "break", is equivalent to what many debuggers call a
    watchpoint instead of a breakpoint: Output some information
    and automatically resume.

Note: Although @@texinfo:@ref{racket-debug-mode}@@ provides a convenient
keybinding, you may invoke this command anytime using M-x.

Note: If you're warned that point isn't known to be a breakable
position, that might be because it truly isn't, or, just because
you are not in @@texinfo:@ref{racket-debug-mode}@@ and the breakable positions
aren't yet known. Worst case, if you set a breakpoint someplace
that is not breakable, it is ignored. With a few exceptions --
such as close paren positions that are tail calls -- most open
parens and close parens are breakble positions.

*** racket-mode-start-faster
{{{kbd(M-x)}}} ~racket-mode-start-faster~

Compile Racket Mode's .rkt files for faster startup.

Racket Mode is implemented as an Emacs Lisp "front end" that
talks to a Racket process "back end". Because Racket Mode is
delivered as an Emacs package instead of a Racket package,
installing it does not do the ~raco setup~ that is normally done
for Racket packages.

This command will do a ~raco make~ of Racket Mode's .rkt files,
creating bytecode files in ~compiled/~ subdirectories. As a
result, when a command must start the Racket process, it will
start somewhat faster.

On many computers, the resulting speed up is negligible, and
might not be worth the complication.

If you run this command, ever, you will need to run it again
after:

- Installing an updated version of Racket Mode. Otherwise, you
  might lose some of the speed-up.

- Installing a new version of Racket and/or changing the value of
  the variable @@texinfo:@ref{racket-program}@@. Otherwise, you might get an
  error message due to the bytecode being different versions.

To revert to compiling on startup, use
@@texinfo:@ref{racket-mode-start-slower}@@. 

*** racket-mode-start-slower
{{{kbd(M-x)}}} ~racket-mode-start-slower~

Delete the "compiled" directories made by @@texinfo:@ref{racket-mode-start-faster}@@.

* Variables

** General variables

*** racket-program
Pathname of the Racket executable or command line to launch it.

- If the value of this variable is a string, it will be interpreted as a
  simple command without arguments.

- If it is a list of strings, the first element will be taken to be the
  executable, and the rest of the list command line arguments to pass to
  it before any other arguments.

Note that a back end configuration can override this with a
non-nil ~racket-program~ property list value. See
@@texinfo:@ref{racket-add-back-end}@@.

*** racket-command-timeout
How many seconds to wait for command server responses.

Note: This is mostly obsolete, fortunately, because it applies
only to commands that must block the Emacs UI until they get a
response. Instead most Racket Mode commands these days receive
their response asychronously.

*** racket-memory-limit
Terminate the Racket process if memory use exceeds this value in MB.

Changes to this value take effect upon the next @@texinfo:@ref{racket-run}@@. A value
of 0 means no limit.

Caveat: This uses Racket's ~custodian-limit-memory~, which does
not enforce the limit exactly. Instead, the program will be
terminated upon the first garbage collection where memory exceeds
the limit (maybe by a significant amount).

*** racket-error-context
The amount of context for error messages.

Each increasing level supplies better context ("stack trace")
for error messages, but causing your program to run more slowly.

  - low corresponds to compile-enforce-module-constants #t and
    compile-context-preservation-enabled #f.

  - medium corresponds to compile-enforce-module-constants #f and
    compile-context-preservation-enabled #t, which disables some
    optimizations like inlining.

  - high corresponds to medium plus the use of errortrace, which
    extensively instruments your code and therefore might cause
    it to run significantly slower.

Tip: Regardless of this setting, you can enable high errortrace
for a specific @@texinfo:@ref{racket-run}@@ or @@texinfo:@ref{racket-run-module-at-point}@@ by
using {{{kbd(C-u)}}}. This lets you normally run with a
lower, faster setting, and re-run when desired to get a
more-helpful error message.

*** racket-user-command-line-arguments
List of command-line arguments to supply to your Racket program.

Accessible in your Racket program in the usual way --- the
parameter ~current-command-line-arguments~ and friends.

This is an Emacs buffer-local variable --- convenient to set as a
file local variable. For example at the end of your .rkt file:

#+BEGIN_SRC elisp
    ;; Local Variables:
    ;; racket-user-command-line-arguments: ("-f" "bar")
    ;; End:
#+END_SRC

Set this way, the value must be an *unquoted* list of strings.
For example:

#+BEGIN_SRC elisp
    ("-f" "bar")
#+END_SRC

The following values will /not/ work:

#+BEGIN_SRC elisp
    '("-f" "bar")
    (list "-f" "bar")
#+END_SRC


*** racket-browse-url-function
Function to call to browse a URL.

Defaults to @@texinfo:@ref{racket-browse-url-using-temporary-file}@@ on macOS and
~browse-url-browser-function~ on other platforms.

*** racket-xp-after-change-refresh-delay
Seconds to wait before refreshing @@texinfo:@ref{racket-xp-mode}@@ annotations.

Set to nil to disable automatic refresh and manually use ~racket-xp-annotate~.

*** racket-xp-highlight-unused-regexp
Only give @@texinfo:@ref{racket-xp-unused-face}@@ to unused bindings that match this regexp.

The default is to highlight identifiers that do not start with
an underline, which is a common convention.

*** racket-xp-add-binding-faces
Have @@texinfo:@ref{racket-xp-mode}@@ fontify binding identifier sites.

A 'font-lock-face property is added for bindings from:

  - the module language, using @@texinfo:@ref{racket-xp-binding-lang-face}@@ and
    @@texinfo:@ref{racket-xp-binding-lang-use-face}@@.

  - other imports, using @@texinfo:@ref{racket-xp-binding-import-face}@@ and
    @@texinfo:@ref{racket-xp-binding-import-use-face}@@.

  - local definitions, using @@texinfo:@ref{racket-xp-binding-local-face}@@ and
    @@texinfo:@ref{racket-xp-binding-local-use-face}@@.

This has a visible effect only when there is /not/ also a
'face property applied by the major mode's fontification.

*** racket-xp-eldoc-level
How much documentation to show via ~eldoc~.

Used by ~racket-xp-eldoc-point~ and ~racket-xp-eldoc-sexp-app~.

- Minimal: Only the help-echo string.

- Summary: Also the signature a.k.a. "blubox" from the
  documentation.

- Complete: Also the complete prose documentation.

A third-party package like ~eldoc-box~ can be useful for all but
the minimal level. Even some bluebox signatures can take many
lines to show on screen.

*** racket-documentation-search-location
The location of the Racket "Search Manuals" web page.
Where @@texinfo:@ref{racket-documentation-search}@@, @@texinfo:@ref{racket-xp-documentation}@@
and @@texinfo:@ref{racket-repl-documentation}@@ should look for the search page.

- If the value of this variable is the symbol "local", open the
  search page from the local documentation, as with "raco doc".

- Otherwise, the value is a string recognizable by ~format~, with
  "%s" at the point at which to insert the user's search text
  after applying ~url-hexify-string~. Apart from "%s", the
  string should be a properly encoded URL.

*** racket-expand-hiding
The macro hiding policy for commands like @@texinfo:@ref{racket-expand-file}@@.

** Hash lang variables

*** racket-hash-lang-token-face-alist
An association list from color-lexer token symbols to face symbols.

Note: In many Racket languages, the lexer classifies tokens for
identifiers as 'symbol. In many programs, a majority of the
source consists of identifiers at binding definition and use
sites. Therefore the appearance of "symbol" tokens is
significant, and a matter of personal preference.

  - If you prefer a "plainer" appearance, similar to Dr Racket:
    Add 'symbol with the value 'default. This gives an
    explicit 'face property that prevails over any
    'font-lock-face property that a minor mode might apply to
    enhance the basic fontification.

  - If you prefer a more "colorful" appearance, similar to
    "classic" @@texinfo:@ref{racket-mode}@@: Do /not/ map 'symbol tokens in
    this list. See @@texinfo:@ref{racket-hash-lang-module-language-hook}@@ for
    ideas.

Note: Some tokens are hardwired and not customizable by this
list: Comment tokens use the face ~font-lock-comment-face~,
sometimes blended with other faces. Parenthesis tokens use the
face ~parenthesis~ if defined, as by the paren-face package.
String tokens use ~font-lock-string-face~. Text tokens, e.g.
Scribble text, use the face @@texinfo:@ref{racket-hash-lang-text}@@.

*** racket-hash-lang-module-language-hook
Hook run when the module language changes.

Typically in Emacs each language gets its own major mode. As a
result, the major mode hook is your opportunity to express
preferences. However @@texinfo:@ref{racket-hash-lang-mode}@@ handles radically
different kinds of hash langs in one major mode. And a given
buffer can change langs when you edit the "#lang" line. As a
result, ~racket-hash-lang-mode-hook~ is not useful for per-lang
configuration. Instead you need a kind of "sub major mode
hook". This is that hook.

The hook is run when a file is first visited, and thereafter
whenever the "#lang" line is edited -- provided that results in
different language info; for example changing from "#lang
racket" to "#lang racket/base" will /not/ run the hook.

The function is called with a string returned by the lang's
"module-language" info key. This info key is supplied
automatically when a language is defined using
syntax/module-reader:

  <https://docs.racket-lang.org/syntax/reader-helpers.html#%28mod-path._syntax%2Fmodule-reader%29>.

Otherwise a lang might not supply this and the value will be nil.

The hook is useful when you want to vary Emacs behavior in ways
that go beyond what a lang can describe. This may include
enabling "fancy" or "classic" Emacs behaviors only for
s-expression langs.

For example, maybe you want to use ~paredit-mode~ when it is
suitable for the module language, else ~electric-pair-local-mode~:

#+BEGIN_SRC elisp
  (defun my-hook (module-language)
    (let ((rackety
           (member module-language
                   (list "racket" "racket/base"
                         "typed/racket" "typed/racket/base"))))
      (electric-pair-local-mode (if rackety -1 1))
      (paredit-mode (if rackety 1 -1))))
  (add-hook 'racket-hash-lang-module-language-hook #'my-hook)
#+END_SRC

A similar tactic can be used for ~smartparens~. In general,
neither of these modes is likely to work well unless the
hash-lang uses racket for drracket:grouping-position, in which
case @@texinfo:@ref{racket-hash-lang-mode}@@ uses the classic @@texinfo:@ref{racket-mode}@@
syntax-table for the buffer. Otherwise you should not enable one
of these modes, and instead just use the simple delimiter
matching of ~electric-pair-local-mode~, as configured by
@@texinfo:@ref{racket-hash-lang-mode}@@.

As another example, if you prefer more colors than just tokens,
choices include:

- Enable @@texinfo:@ref{racket-xp-mode}@@ in ~racket-hash-lang-mode-hook~ and in
  the module language hook locally set
  @@texinfo:@ref{racket-xp-add-binding-faces}@@:

#+BEGIN_SRC elisp
  (setq-local racket-xp-add-binding-faces t)
#+END_SRC

  OR

- Use some of the regexp search-based fontification from classic
  @@texinfo:@ref{racket-mode}@@ for rackety module languages:

#+BEGIN_SRC elisp
  (require 'racket-font-lock)
  (if rackety
      (font-lock-add-keywords nil
                              (append racket-font-lock-keywords-2
                                      racket-font-lock-keywords-3))
    (font-lock-remove-keywords nil
                               (append racket-font-lock-keywords-2
                                       racket-font-lock-keywords-3)))
#+END_SRC


** REPL variables

*** racket-repl-buffer-name-function
How to associate @@texinfo:@ref{racket-mode}@@ edit buffers with @@texinfo:@ref{racket-repl-mode}@@ buffers.

The default is nil, which is equivalent to supplying
@@texinfo:@ref{racket-repl-buffer-name-shared}@@: One REPL buffer is shared.

Other predefined choices include @@texinfo:@ref{racket-repl-buffer-name-unique}@@
and @@texinfo:@ref{racket-repl-buffer-name-project}@@.

This is used when a @@texinfo:@ref{racket-mode}@@ buffer is created. Changing
this to a new value only affects @@texinfo:@ref{racket-mode}@@ buffers created
later.

Any such function takes no arguments, should look at the variable
~buffer-file-name~ if necessary, and either ~setq-default~ or
~setq-local~ the variable ~racket-repl-buffer-name~ to a desired
@@texinfo:@ref{racket-repl-mode}@@ buffer name. As a result, @@texinfo:@ref{racket-run}@@
commands will use a buffer of that name, creating it if
necessary.

*** racket-submodules-to-run
Extra submodules to run.

This is a list of submodules. Each submodule is described as a
list, to support submodules nested to any depth.

This is used by commands that emulate the DrRacket Run command:


 - @@texinfo:@ref{racket-run}@@
 - @@texinfo:@ref{racket-run-and-switch-to-repl}@@ {{{kbd(<f5>)}}}

It is NOT used by commands that run one specific module, such as:

 - @@texinfo:@ref{racket-run-module-at-point}@@ {{{kbd(C-c C-k)}}}or {{{kbd(C-c C-c)}}}
 - @@texinfo:@ref{racket-test}@@ {{{kbd(C-<f5>)}}}or {{{kbd(C-c C-t)}}}
 - @@texinfo:@ref{racket-profile}@@

*** racket-repl-history-directory
Directory for @@texinfo:@ref{racket-repl-mode}@@ history files.

*** racket-history-filter-regexp
Input matching this regexp are NOT saved on the history list.
Default value is a regexp to ignore input that is all whitespace.

*** racket-images-inline
Whether to display inline images in the REPL.

*** racket-imagemagick-props
Use ImageMagick with these properties for REPL images.

When this property list is not empty -- and the variable
@@texinfo:@ref{racket-images-inline}@@ is true, and Emacs is built with with
ImageMagick support -- then ~create-image~ is called with
"imagemagick" as the type and with this property list.

For example, to scale images whose width is larger than 500
pixels, supply (:max-width 500).

*** racket-images-keep-last
How many images to keep in the image cache.

*** racket-images-system-viewer
The image viewer program to use for ~racket-view-image~.

*** racket-images-do-not-use-svg
Do not use SVG to render images?

Note: This value is used only when starting a back end -- /not/
for each run. If you change this, for it to take effect you must
restart by using ~racket-start-back-end~.

*** racket-pretty-print
Use pretty-print instead of plain print?

When true, before each run set global-port-print-handler to use
pretty-print from racket/pretty, which is suitable for
s-expressions.

Note: A configure-runtime submodule might replace this initial
value with its own global port print handler -- for example to
implement printing a non-s-expression syntax.

*** racket-repl-command-file
Name of the file used by @@texinfo:@ref{racket-repl}@@.

*** racket-repl-echo-sent-expressions
Should commands that send an expresion to the REPL echo it there?

The echoed expression and " => " are displayed using the face
@@texinfo:@ref{racket-repl-message}@@ to distinguish them from result values.

Affects @@texinfo:@ref{racket-send-last-sexp}@@, @@texinfo:@ref{racket-send-region}@@, and
@@texinfo:@ref{racket-send-definition}@@.

** Other variables

*** racket-doc-index-directory
Directory for @@texinfo:@ref{racket-describe-search}@@ doc index files.

*** racket-doc-index-predicate-function
A function used by @@texinfo:@ref{racket-describe-search}@@ to filter results.

The default value, the ~always~ function, filters nothing.

The function is given four string arguments -- TERM, WHAT,
FROM-LIBS, and FAMILIES -- and should return whether to include
the item in the list of completion candidates. An example that
limits candidates to the "Rhombus" family:

    (lambda (_term _what _from-libs families)
      (string-equal families "Rhombus")


*** racket-indent-curly-as-sequence
Indent ~{}~ with items aligned with the head item?

This is indirectly disabled if @@texinfo:@ref{racket-indent-sequence-depth}@@ is 0.
This is safe to set as a file-local variable.

*** racket-indent-sequence-depth
To what depth should @@texinfo:@ref{racket-indent-line}@@ search.

This affects the indentation of forms like '() `() #() --
and {} if @@texinfo:@ref{racket-indent-curly-as-sequence}@@ is t --- but not
#'() #`() ,() ,@(). A zero value disables, giving the
normal indent behavior of DrRacket or Emacs ~lisp-mode~ derived
modes like ~scheme-mode~. Setting this to a high value can make
indentation noticeably slower. This is safe to set as a
file-local variable.

*** racket-pretty-lambda
Display lambda keywords using λ. This is DEPRECATED.

Instead use ~prettify-symbols-mode~ in newer verisons of Emacs,
or, use @@texinfo:@ref{racket-insert-lambda}@@ to insert actual λ characters.

*** racket-smart-open-bracket-enable
This variable is obsolete and has no effect.

Instead of using this variable, you may bind the ~[~ key to the
~racket-smart-open-bracket~ command in the ~racket-mode-map~
and/or ~racket-repl-mode-map~ keymaps.

*** racket-logger-config
Configuration of @@texinfo:@ref{racket-logger-mode}@@ topics and levels.

The topic "*" respresents the default level used for topics not
assigned a level. Otherwise, the topic symbols are the same as
used by Racket's ~define-logger~.

The levels are those used by Racket's logging system: "debug",
"info", "warning", "error", "fatal".

For more information see:
  <https://docs.racket-lang.org/reference/logging.html>

The default value sets some known "noisy" topics to be one
level quieter. That way you can set the "*" topic to a level
like "debug" and not get overhwelmed by these noisy topics.

*** racket-before-run-hook
Normal hook done before various Racket Mode run commands.

Here "before" means that the @@texinfo:@ref{racket-repl-mode}@@ buffer might not
exist yet.

When hook functions are called, ~current-buffer~ is that of the
edit buffer when the run command was issued. If a hook function
instead needs the @@texinfo:@ref{racket-repl-mode}@@ buffer, it should get that
from the variable ~racket-repl-buffer-name~.

*** racket-after-run-hook
Normal hook done after various Racket Mode run commands.

Here "after" means that the run has completed and the REPL is
waiting at another prompt.

When hook functions are called, ~current-buffer~ is that of the
buffer when the run command was issued. If a hook function
instead needs the @@texinfo:@ref{racket-repl-mode}@@ buffer, it should get that
from the variable ~racket-repl-buffer-name~.

*** racket-sexp-comment-fade
How much to fade faces used in s-expression comment bodies.

A number from 0.0 to 1.0, where 0.0 is 0% fade and 1.0 is 100%
fade (invisible).

This feature works by creating faces that are alternatives for
faces used in s-expression comments. The alernative faces use a
faded foreground color. The colors are recalculated automatically
after you change the value of this customization variable and
after any ~load-theme~. However in other circumstances you might
need to use ~racket-refresh-sexp-comment-faces~.

** Experimental debugger variables

*** racket-debuggable-files
Used to tell @@texinfo:@ref{racket-run}@@ what files may be instrumented for debugging.

This isn't yet a defcustom becuase the debugger status is still
"experimental".

Must be either a list of file name strings, or, a function that
takes the name of the file being run and returns a list of file
names.

Each file name in the list is made absolute using
~expand-file-name~ with respect to the file being run and given
to ~racket-file-name-front-to-back~.

** Showing information

*** racket-show-functions
An "abnormal hook" variable to customize ~racket-show~.

This is a list of one or more functions.

Each such function must accept two arguments: STR and POS.

STR is one of:

  - Non-blank string: Display the string somehow.

  - Blank string: Hide any previously displayed string.

  - nil: Hide any persistent UI that might have been created. For
    instance @@texinfo:@ref{racket-show-header-line}@@ hides the header line.

POS may be nil when STR is nil or a blank string.

Otherwise POS is the buffer position -- typically the end of a
span -- that the non-blank STR describes.

A function that shows STR near POS should position it not to hide
the span, i.e. below and/or right of POS. Examples:
@@texinfo:@ref{racket-show-pseudo-tooltip}@@ and @@texinfo:@ref{racket-show-pos-tip}@@.

A function that shows STR in a fixed location may of course
ignore POS. Examples: @@texinfo:@ref{racket-show-echo-area}@@ and
@@texinfo:@ref{racket-show-header-line}@@

** Running racket and raco commands in a shell or terminal

*** racket-shell-or-terminal-function
How @@texinfo:@ref{racket-racket}@@ and @@texinfo:@ref{racket-raco-test}@@ run commands.

The function should accept a command string, not including a
newline, get or create a suitable buffer, send the command, and
send a newline or enter.

Predefined choices include @@texinfo:@ref{racket-shell}@@, @@texinfo:@ref{racket-term}@@,
@@texinfo:@ref{racket-ansi-term}@@, and @@texinfo:@ref{racket-vterm}@@.

** Racket input method

*** racket-input-prefix
A prefix used by the "Racket" input method.

This string is prepended to the key sequence strings in
@@texinfo:@ref{racket-input-translations}@@, when setting up the input method.

Using some non-nil, non-blank prefix avoids conflicts between key
sequences and portions of normal words. For example "oint"
would insert "∮" while you're typing "point" -- but not
"\oint".

If you change this setting manually with ~setq~ (instead of using
the customization buffer or ~setopt~) you need to call
~racket-input-setup~ in order for the change to take effect.

*** racket-input-translations
A list of translations.

Each element is (KEY-SEQUENCE-STRING TRANSLATION-STRING).

Used by the "Racket" input method activated by
@@texinfo:@ref{racket-input-mode}@@, as well as by the @@texinfo:@ref{racket-insert-symbol}@@
command.

If you change this setting manually with ~setq~ (instead of using
the customization buffer or ~setopt~) you need to call
~racket-input-setup~ in order for the change to take effect.

* Configuration functions

** Showing information

*** racket-show-pseudo-tooltip
~(racket-show-pseudo-tooltip str &optional pos)~


Show using an overlay that resembles a tooltip.

This is nicer than @@texinfo:@ref{racket-show-pos-tip}@@ because it:

  - Doesn't flicker while navigating.
  - Doesn't disappear after a timeout.
  - Performs well when ~x-gtk-use-system-tooltips~ is nil.

On the other hand, this does not look as nice when displaying
text that spans multiple lines or is too wide to fit the window.
In that case, we simply left-justify everything and do not draw
any border.

*** racket-show-echo-area
~(racket-show-echo-area str &optional _pos)~


Show things in the echo area.

A value for the variable @@texinfo:@ref{racket-show-functions}@@.

This does /not/ add STR to the "*Messages*" log buffer.

*** racket-show-header-line
~(racket-show-header-line str &optional _pos)~


Show things using a buffer header line.

A value for the variable @@texinfo:@ref{racket-show-functions}@@.

When there is nothing to show, keep a blank header-line. That
way, the buffer below doesn't "jump up and down" by a line as
messages appear and disappear. Only when V is nil do we remove
the header line.

*** racket-show-pos-tip
~(racket-show-pos-tip str &optional pos)~


Show things using ~pos-tip-show~ if available.

A value for the variable @@texinfo:@ref{racket-show-functions}@@.

** Associating edit buffers with REPL buffers

*** racket-repl-buffer-name-shared
~(racket-repl-buffer-name-shared)~


Share one @@texinfo:@ref{racket-repl-mode}@@ buffer per back end.

A value for the variable @@texinfo:@ref{racket-repl-buffer-name-function}@@.

*** racket-repl-buffer-name-unique
~(racket-repl-buffer-name-unique)~


Each @@texinfo:@ref{racket-mode}@@ edit buffer gets its own @@texinfo:@ref{racket-repl-mode}@@ buffer.

A value for the variable @@texinfo:@ref{racket-repl-buffer-name-function}@@.

*** racket-repl-buffer-name-project
~(racket-repl-buffer-name-project)~


Share a @@texinfo:@ref{racket-repl-mode}@@ buffer per back end and per project.

A value for the variable @@texinfo:@ref{racket-repl-buffer-name-function}@@.

The "project" is determined by @@texinfo:@ref{racket-project-root}@@.

*** racket-project-root
~(racket-project-root file)~


Given an absolute pathname for FILE, return its project root directory.

The "project" is determined by trying, in order:

- ~projectile-project-root~
- ~vc-root-dir~
- ~project-current~
- ~file-name-directory~

** Browsing file URLs with anchors

*** racket-browse-url-using-temporary-file
~(racket-browse-url-using-temporary-file url &rest _args)~


Browse a URL via a temporary HTML file using a meta redirect.

A suitable value for the variable @@texinfo:@ref{racket-browse-url-function}@@.

Racket documentation URLs depend on anchors -- the portion of the
URL after the # character -- to jump to a location within a page.
Unfortunately on some operating systems and/or versions of Emacs,
the default handling for browsing file URLs ignores anchors. This
function attempts to avoid the problem by using a temporary HTML
file with a meta redirect as a "trampoline".

Although the intent is to provide a default that "just works",
you do not need to use this. You can customize the variable
@@texinfo:@ref{racket-browse-url-function}@@ instead to be ~browse-url~, or
~browse-url-browser-function~ in case have have customized that,
or indeed whatever you want.

** Configuring back ends

*** racket-add-back-end
~(racket-add-back-end directory &rest plist)~


Add a description of a Racket Mode back end.

Racket Mode supports one or more back ends, which are Racket
processes supporting REPLs as well as various other Racket Mode
features.

DIRECTORY is a string describing a ~file-name-absolute-p~
directory on some local or remote server.

When a back end's DIRECTORY is the longest matching prefix of a
buffer's ~default-directory~, that back end is used for the
buffer.

DIRECTORY can be a local directory like "/" or
"/path/to/project", or a ~file-remote-p~ directory like
"/user@host:" or "/user@host:/path/to/project".

Note that you need not include a method -- such as the "ssh" in
"/ssh:user@host:" -- and if you do it is stripped: A back end
process is always started using SSH. Even if multiple buffers for
the same user+host+port use different methods, they will share
the same back end.

Practically speaking, DIRECTORY is a path you could give to
~find-file~ to successfully find some local or remote file, but
omitting any method. (Some remote file shorthand forms get
expanded to at least "/method:host:". When in doubt check
~buffer-file-name~ and follow its example.)

In addition to being used as a pattern to pick a back end for a
buffer, DIRECTORY determines:

- Whether the back end is local or remote.

- When remote, any explicit user and port used to make SSH
  connections (as opposed to relying on values from
  ~/.ssh/config).

- Other properties get reasonable defaults based on whether the
  back end is local or remote, as described below.

After DIRECTORY, the remainining arguments are optional; they are
alternating :keywords and values describing some other properties
of a back end:

- :racket-program

  When not nil this is used instead of the value of the
  customization variable @@texinfo:@ref{racket-program}@@.

- :remote-source-dir

  Where on a remote host to copy the back end's *.rkt files when
  they do not exist or do not match the digest of the local
  files. This must be ~file-name-absolute-p~ on the remote. Only
  supply the localname there (not a full ~file-remote-p~). The
  default value is "/tmp/racket-mode-back-end".

- :windows

  Whether the back end uses Windows style path names. Used to
  translate betwen slashes and backslashes between the Emacs
  front end (which uses slashes even on Windows) and the Racket
  back end (which expects native backslashes on Windows).

- :restart-watch-directories

  A list of ~directory-name-p~ strings. Each directory, and
  recursively its subdirectories, will be watched for file system
  changes. After any changes are detected, the next
  @@texinfo:@ref{racket-run}@@ (or @@texinfo:@ref{racket-run-module-at-point}@@ etc.) command
  will ask you if it should restart the back end for you. This
  may be helpful when you are changing source files used by the
  back end.

The default property values are appropriate for whether
DIRECTORY is local or remote:

- When DIRECTORY is remote, :windows defaults to nil.

- Otherwise, :windows defaults to a value based on ~system-type~.

Although the default values usually "just work" for local and
remote back ends, you might want a special configuration. Here
are a few examples.

#+BEGIN_SRC lisp
    ;; 1. A back end configuration for "/" is
    ;; created automatically and works fine as a default
    ;; for buffers visiting local files, so we don't need
    ;; to add one here.

    ;; 2. However assume we want buffers under /var/tmp/8.0
    ;; instead to use Racket 8.0.
    (racket-add-back-end "/var/tmp/8.0"
                         :racket-program "~/racket/8.0/bin/racket")

    ;; 3. A back end configuration will be created
    ;; automatically for buffers visiting file names like
    ;; "/ssh:user@linode", so we don't need to add one here.
    ;;
    ;; If ~/.ssh/config defines a Host alias named "linode",
    ;; with HostName and User settings, a file name as simple as
    ;; "/linode:" would work fine with tramp -- and the
    ;; automatically created back end configuration would work
    ;; fine, too.

    ;; 4. For example's sake, assume for buffers visiting
    ;; /ssh:headless:~/gui-project/ we want :racket-program instead
    ;; to be '("xvfb-run" "racket").
    (racket-add-back-end "/ssh:headless:~/gui-project/"
                         :racket-program '("xvfb-run" "racket"))
#+END_SRC

If you use various versions of Racket by setting PATH values via
direnv, .envrc files and ~envrc-global-mode~, then you need a
distinct back end for each such project subdirectory. One
approach is to use @@texinfo:@ref{racket-add-back-end}@@ for each project in your
Emacs init file. Another way to is to have a .dir-locals.el file
alongside each .envrc file:

#+BEGIN_SRC lisp
    ((nil . ((eval . (racket-add-back-end default-directory)))))
#+END_SRC


** Running racket and raco commands in a shell or terminal

*** racket-shell
~(racket-shell cmd)~


Run CMD using ~shell~.

A value for the variable @@texinfo:@ref{racket-shell-or-terminal-function}@@.

*** racket-term
~(racket-term cmd)~


Run CMD using ~term~.

A value for the variable @@texinfo:@ref{racket-shell-or-terminal-function}@@.

*** racket-ansi-term
~(racket-ansi-term cmd)~


Run CMD using ~ansi-term~.

A value for the variable @@texinfo:@ref{racket-shell-or-terminal-function}@@.

*** racket-vterm
~(racket-vterm cmd)~


Run CMD using ~vterm~, if that package is installed.

A value for the variable @@texinfo:@ref{racket-shell-or-terminal-function}@@.

* Faces

** All

*** racket-keyword-argument-face
Face for ~#:keyword~ arguments.

*** racket-reader-quoted-symbol-face
Face for symbols quoted using ' or `.

This face is given only to symbols directly quoted using the
reader shorthands ' or `. All other directly quoted values,
including symbols quoted using "quote" or "quasiquote", get
the face ~font-lock-constant-face~.

*** racket-reader-syntax-quoted-symbol-face
Face for symbols quoted using #' or #`.

This face is given only to symbols directly quoted using the
reader shorthands #' or #`. All other directly quoted
values, including symbols quoted using "syntax" or
"quasisyntax", get the face ~font-lock-constant-face~.

*** racket-here-string-face
Face for here strings.

*** racket-xp-def-face
Face @@texinfo:@ref{racket-xp-mode}@@ uses when point is on a definition.

*** racket-xp-use-face
Face @@texinfo:@ref{racket-xp-mode}@@ uses when point is on a use.

*** racket-xp-unused-face
Face @@texinfo:@ref{racket-xp-mode}@@ uses to highlight unused requires or definitions.

*** racket-xp-tail-target-face
Face @@texinfo:@ref{racket-xp-mode}@@ uses to highlight targets of a tail position.

*** racket-xp-tail-position-face
Face @@texinfo:@ref{racket-xp-mode}@@ uses to highlight expressions in a tail position.

*** racket-xp-binding-lang-face
Face @@texinfo:@ref{racket-xp-mode}@@ gives to the module language name.

See the variable ~nil~.

*** racket-xp-binding-lang-use-face
Face @@texinfo:@ref{racket-xp-mode}@@ gives uses of bindings imported from the module language.

See the variable ~nil~.

*** racket-xp-binding-import-face
Face @@texinfo:@ref{racket-xp-mode}@@ gives to imported module names.

See the variable ~nil~.

*** racket-xp-binding-import-use-face
Face @@texinfo:@ref{racket-xp-mode}@@ gives uses of imported bindings.

See the variable ~nil~.

*** racket-xp-binding-local-face
Face @@texinfo:@ref{racket-xp-mode}@@ gives to local definitions.

See the variable ~nil~.

*** racket-xp-binding-local-use-face
Face @@texinfo:@ref{racket-xp-mode}@@ gives to uses of local definitions.

See the variable ~nil~.

*** racket-logger-config-face
Face for @@texinfo:@ref{racket-logger-mode}@@ configuration.

*** racket-logger-topic-face
Face for @@texinfo:@ref{racket-logger-mode}@@ topics.

*** racket-logger-fatal-face
Face for @@texinfo:@ref{racket-logger-mode}@@ fatal level.

*** racket-logger-error-face
Face for @@texinfo:@ref{racket-logger-mode}@@ error level.

*** racket-logger-warning-face
Face for @@texinfo:@ref{racket-logger-mode}@@ warning level.

*** racket-logger-info-face
Face for @@texinfo:@ref{racket-logger-mode}@@ info level.

*** racket-logger-debug-face
Face for @@texinfo:@ref{racket-logger-mode}@@ debug level.

*** racket-doc-link-face
Face @@texinfo:@ref{racket-describe-mode}@@ uses for links within documentation.
Note: When some special face is already specified by the
documentation, then to avoid visual clutter this face is NOT also
added.

*** racket-ext-link-face
Face @@texinfo:@ref{racket-describe-mode}@@ uses for external links.
See the variable @@texinfo:@ref{racket-browse-url-function}@@.

*** racket-doc-output-face
Face @@texinfo:@ref{racket-describe-mode}@@ uses for Scribble @example or @interactions output.

*** racket-doc-litchar-face
Face @@texinfo:@ref{racket-describe-mode}@@ uses for Scribble @litchar.

*** racket-repl-message
Face @@texinfo:@ref{racket-repl-mode}@@ uses for messages from the back end.

*** racket-repl-prompt
Face @@texinfo:@ref{racket-repl-mode}@@ uses for prompts.

*** racket-repl-value
Face @@texinfo:@ref{racket-repl-mode}@@ uses for ~print~-ed values.

*** racket-repl-error-message
Face @@texinfo:@ref{racket-repl-mode}@@ uses for error messages.

*** racket-repl-error-location
Face @@texinfo:@ref{racket-repl-mode}@@ uses for error locations.

*** racket-repl-stdout
Face @@texinfo:@ref{racket-repl-mode}@@ uses for output to current-output-port.

*** racket-repl-stderr
Face @@texinfo:@ref{racket-repl-mode}@@ uses for output to current-error-port.

*** racket-hash-lang-text
Face @@texinfo:@ref{racket-hash-lang-mode}@@ uses for text tokens.

