Racket Mode
***********

Introduction
************

The Racket Mode (https://www.racket-mode.com/) package consists of a variety of Emacs major and minor modes, including:

  * racket-mode: A major mode for editing .rkt files.

  * racket-xp-mode: An optional minor mode that enhances racket-mode to explain and explore code.

  * racket-repl-mode: A major mode for running programs providing a REPL.

  * Various other modes to support specific features:

       * racket-logger-mode

       * racket-profile-mode

       * racket-debug-mode

Racket Mode uses a ``back end server'' written in Racket, which is responsible for running files and implementing commands that cannot be implemented in Emacs Lisp. (Racket Mode's Racket code is also delivered as part of the Emacs package --- not as a Racket package. Delivering both Emacs and Racket code in one Emacs package simplifies installation and updates. The main drawback is that the Racket code is not automatically byte-compiled, as would normally be done by raco pkg install. To address this: see racket-mode-start-faster.)

For code, issues, and pull requests, see the Git repo (https://github.com/greghendershott/racket-mode).

To fund this work, see GitHub Sponsors (https://github.com/users/greghendershott/sponsorship) or PayPal (https://www.paypal.me/greghendershott).

Install
*******

The recommended way to use Racket Mode is to install the package from MELPA (https://melpa.org/#/racket-mode).

Configure Emacs to use MELPA
============================

To use MELPA:

  * Add the following to your ~/.emacs or ~/.emacs.d/init.el:

     (require 'package)
     (add-to-list 'package-archives
     	      '("melpa" . "https://melpa.org/packages/")
     	      t)

  * Restart Emacs.

  * Type M-x  package-refresh-contents RET .

Install Racket Mode
===================

When Emacs is configured to use MELPA, simply type M-x  package-install RET  racket-mode RET .

Minimal Racket
==============

If you have installed the minimal Racket distribution (for example by using the homebrew formula (https://github.com/Homebrew/homebrew-core/blob/master/Formula/minimal-racket.rb)) Racket Mode needs some additional packages (like errortrace and macro-debugger). A simple way to get all these packages is to install the drracket Racket package. In a command shell:

     raco pkg install drracket

Uninstall
=========

To uninstall Racket Mode, simply type M-x  package-delete RET  racket-mode RET .

You should probably also exit and restart Emacs.

Update
======

Be aware that updating an Emacs package doesn't necessarily fully update Emacs' state. (One example symptom: an ``invalid function'' error message.)

After updating the package, you might need to restart Emacs.

In some cases, you might even need to:

 1. Uninstall Racket Mode.

 2. Exit and restart Emacs.

 3. Install Racket Mode.

Configure
*********

Although Racket Mode can be customized with many Variables, there is only one that you might need to set: racket-program. This is the name or pathname of the Racket executable. It defaults to Racket.exe on Windows else racket.

On Windows or Linux, this default will probably work for you.

On macOS, downloading Racket doesn't add its bin directory to your PATH. Even after you add it, GUI Emacs doesn't automatically use your path (unless you use the handy exec-path-from-shell (https://melpa.org/#/exec-path-from-shell) package). Therefore you might want to set racket-program to a complete pathname.

You can setq this directly in your Emacs init file (~/.emacs or ~/.emacs.d/init.el), or, use M-x  customize, as you prefer.

Key bindings
============

To customize things like key bindings, you can use racket-mode-hook in your Emacs init file to modify racket-mode-map. For example, although C-c C-c  is bound by default to the racket-run command, let's say you wanted F5  to be an additional binding:

     (add-hook 'racket-mode-hook
     	  (lambda ()
     	    (define-key racket-mode-map (kbd "<f5>") 'racket-run)))

Likewise for racket-repl-mode-hook and racket-repl-mode-map.

Font-lock (syntax highlighting)
===============================

Font-lock (as Emacs calls syntax highlighting) can be controlled using the variable font-lock-maximum-decoration, which defaults to t (maximum). You can set it to a number, where 0 is the lowest level. You can even supply an association list to specify different values for different major modes.

Historically you might choose a lower level for speed. These days you might do so because you prefer a simpler appearance.

Racket Mode supports four, increasing levels of font-lock:

  * 0: Just strings, comments, and #lang.

  * 1: #:keyword and self-evaluating literals like numbers, quoted symbols (including symbols with spaces delimited by | characters), and #rx and #px regular expressions.

  * 2: Identifiers in define-like and let-like forms.

  * 3: Identifiers provided by racket, typed/racket, racket/syntax, and syntax/parse. (This level effectively treats Racket as a language, instead of a language for making languages.).

Completion
==========

In Emacs, a major mode may supply a ``completion-at-point function''. This function is used by manual completion commands like complete-symbol (bound by default to C-M-i ), as well as by auto-completion packages like company-mode.

  * racket-mode supplies racket-complete-at-point, which simply supplies the same symbols that it knows how to font-lock. This does not require the Racket Mode back end to be running. But of course the completion candidates do not correspond to your program's definitions or those it imports. This is a static, ``better than nothing'' fallback.

  * racket-xp-mode --- an optional minor mode that enhances racket-mode --- supplies racket-xp-complete-at-point, which uses a static analysis to find local and imported binding names. Although this requires the Racket Mode back end to be running --- and will automatically start it --- it does not require the edit buffer to be racket-run.

  * racket-repl-mode supplies racket-repl-complete-at-point, which uses the result of namespace-mapped-symbols on the program currently running in the REPL.

These completion functions are set by default. (However, racket-xp-mode is not enabled by default. To do so: racket-xp-mode.)

If you want TAB  to do completion as well as indent, add the following to your Emacs init file:

     (setq tab-always-indent 'complete)

This changes the behavior of Emacs' standard indent-for-tab-command, to which TAB  is bound by default in racket-mode and racket-repl-mode.

Xref (definitions and references)
=================================

Several modes support the Emacs commands

  * M-.  xref-find-definitions

  * M-?  xref-find-references

  * M-,  xref-pop-marker-stack

To do so, each mode adds a local hook for xref-backend-functions:

  * racket-mode: #'racket-mode-xref-backend-function

  * racket-xp-mode: #'racket-xp-xref-backend-function

  * racket-repl-mode: #'racket-repl-xref-backend-function

If you prefer, you can remove the local hook --- e.g. for racket-mode: (remove-hook 'xref-backend-functions #'racket-mode-xref-function t).

You can M-x customize-group and enter xref to adjust some other settings. For example, the customization variable xref-prompt-for-identifier controls which commands prompt you and when. You might prefer to set it to nil.

If you use paredit, by default it binds M-?  to paredit-convolute-sexp. You can change that binding in paredit-mode-map allowing the global binding for M-?  to be used, or, pick some other key for xref-find-references in the global map.

Finally, what to expect:

  * Racket does not have a global or project-wide database of definitions and references.

  * Various modules can export identifiers with the same symbolic value -- for example a different ``define'' is provided by racket/base, typed/racket/base, and other modules.

  * A module can import something, then rename, contract, and re-export it.

As a result, to find a definition, it is necessary to know exactly which identifier is meant --- either by expanding the module (as is done by racket-xp-mode) or by actually running it (racket-repl-mode). Once known, we can usually find the definition site, even through a chain of renaming and/or contract-wrapping exports. In addition, when point is on a module within  require form, we can usually find the source file. (In plain racket-mode edit buffers not enhanced by racket-xp-mode, the only thing that xref-find-definitions does is visit relative requires, e.g. foo.rkt in (require "foo.rkt").)

As for finding references, the default xref implementation is used, which greps for strings among a project's files. Although racket-xp-mode can sometimes do better, using drracket/check-syntax for definitions and references within the current buffer, beyond those it also falls back to the default implementation.

In any case, using the Emacs xref API allows for consistent command names, shortcut keys, and even a special buffer to navigate among references and visit each source location.

Indent
======

Indentation can be customized in a way similar to lisp-mode and scheme-mode: racket-indent-line.

paredit
=======

If you use paredit (https://melpa.org/#/paredit), you might want to add keybindings to paredit-mode-map:

  * Bind the curly brace keys to paredit-open-curly and paredit-close-curly.

  * Bind whatever keys you prefer for paredit-wrap-square and paredit-wrap-curly.

For example, with use-package (https://melpa.org/#/use-package):

     (use-package paredit
       :ensure t
       :config
       (dolist (m '(emacs-lisp-mode-hook
     	       racket-mode-hook
     	       racket-repl-mode-hook))
         (add-hook m #'paredit-mode))
       (bind-keys :map paredit-mode-map
     	     ("{"   . paredit-open-curly)
     	     ("}"   . paredit-close-curly))
       (unless terminal-frame
         (bind-keys :map paredit-mode-map
     	       ("M-[" . paredit-wrap-square)
     	       ("M-{" . paredit-wrap-curly))))

smartparens
===========

If instead of paredit you prefer smartparens (https://melpa.org/#/smartparens), you can use the default configuration it provides for Lisp modes generally and for Racket Mode specifically:

     (require 'smartparens-config)

Edit buffers and REPL buffers
=============================

By default, all racket-mode edit buffers share one racket-repl-mode buffer. For example, if you run foo.rkt, the REPL prompt changes to foo.rkt>, and the REPL is inside the file module namespace. If you then run bar.rkt, the REPL prompt changes to bar.rkt>, and you are in that namespace.

If you prefer, you can use more than one REPL buffer, by customizing the variable racket-repl-buffer-name-function: Another option is to have one REPL buffer for each edit buffer, similar to Dr Racket. Yet another option is to share the same REPL buffer for files belonging to the same project. You can also define your own, custom function.

eldoc
=====

By default Racket Mode sets eldoc-documentation-function to nil --- no eldoc-mode support. You may set it to racket-eldoc-function in a racket-mode-hook and racket-repl-mode-hook if you really want to use eldoc-mode with Racket. But it is not a very satisfying experience because Racket is not a very ``eldoc-friendly'' language. Although Racket Mode attempts to discover argument lists, contracts, or types this doesn't work in many common cases:

  * Many Racket primitives are defined in #%kernel or #%runtime. There's no easy way to determine their argument lists. Most do not provide a contract.

  * Many of the interesting Racket forms are syntax (macros) not functions. There's no easy way to determine their ``argument lists''.

  * When a form has documentation, Racket Mode can show the \"bluebox\'' -- but often that does not fit in a single line as you would normally expect with eldoc.

A more satisfying experience is to use racket-xp-describe or racket-xp-documentation.

Start faster
============

You can use racket-mode-start-faster to make the Racket REPL start faster.

Unicode input method
====================

An optional Emacs input method, racket-unicode, lets you easily type various Unicode symbols that might be useful when writing Racket code.

To automatically enable the racket-unicode input method in racket-mode and racket-repl-mode buffers, put the following code in your Emacs init file:

     (add-hook 'racket-mode-hook      #'racket-unicode-input-method-enable)
     (add-hook 'racket-repl-mode-hook #'racket-unicode-input-method-enable)

See racket-unicode-input-method-enable.

See racket-insert-lambda.

Reference
*********

The following sections are generated from the doc strings for each command, variable, or face. (As a result, some of the formatting might not be quite as nice or correct as in the previous sections.)

You can also view these by using the normal Emacs help mechanism:

  * C-h f  and enter the name of a command.

  * C-h v  and enter the name of a variable.

Commands
********

Edit
====

racket-mode
-----------

M-x  racket-mode

Major mode for editing Racket source files.

Key
Binding
}
racket-insert-closing
]
racket-insert-closing
)
racket-insert-closing
TAB
indent-for-tab-command
C-x C-e
racket-send-last-sexp
C-M-y
racket-insert-lambda
C-M-u
racket-backward-up-list
C-M-x
racket-send-definition
C-c C-u
racket-unfold-all-tests
C-c C-f
racket-fold-all-tests
C-c C-d
racket-documentation-search
C-c C-p
racket-cycle-paren-shapes
C-c C-x C-f
racket-open-require-path
C-c C-e r
racket-expand-region
C-c C-e e
racket-expand-last-sexp
C-c C-e x
racket-expand-definition
C-c C-e f
racket-expand-file
C-c C-r
racket-send-region
C-c C-o
racket-profile
C-c C-l
racket-logger
C-c C-t
racket-test
C-c C-z
racket-repl
C-c C-k
racket-run-module-at-point
C-c C-c
racket-run-module-at-point

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

racket-insert-lambda
--------------------

C-M-y

Insert λ.

To insert Unicode symbols generally, see racket-unicode-input-method-enable.

racket-fold-all-tests
---------------------

C-c C-f

Fold (hide) all test submodules.

racket-unfold-all-tests
-----------------------

C-c C-u

Unfold (show) all test submodules.

racket-tidy-requires
--------------------

M-x  racket-tidy-requires

Make a single ``require'' form, modules sorted, one per line.

The scope of this command is the innermost module around point, including the outermost module for a file using a ``#lang'' line. All require forms within that module are combined into a single form. Within that form:

  * A single subform is used for each phase level, sorted in this order: for-syntax, for-template, for-label, for-meta, and plain (phase 0).

       * Within each level subform, the modules are sorted:

            * Collection path modules -- sorted alphabetically.

            * Subforms such as only-in.

            * Quoted relative requires -- sorted alphabetically.

At most one required module is listed per line.

See also: racket-trim-requires and racket-base-requires.

racket-trim-requires
--------------------

M-x  racket-trim-requires

Like racket-tidy-requires but also deletes unnecessary requires.

Note: This only works when the source file can be fully expanded with no errors.

Note: This only works for requires at the top level of a source file using #lang. It does NOT work for require forms inside module forms. Furthermore, it is not smart about module+ or module* forms -- it might delete top level requires that are actually needed by such submodules.

See also: racket-base-requires.

racket-base-requires
--------------------

M-x  racket-base-requires

Change from ``#lang racket'' to ``#lang racket/base''.

Adds explicit requires for imports that are provided by ``racket'' but not by ``racket/base''.

This is a recommended optimization for Racket applications. Avoiding loading all of ``racket'' can reduce load time and memory footprint.

Also, as does racket-trim-requires, this removes unneeded modules and tidies everything into a single, sorted require form.

Note: This only works when the source file can be fully expanded with no errors.

Note: This only works for requires at the top level of a source file using #lang. It does NOT work for require forms inside module forms. Furthermore, it is not smart about module+ or module* forms -- it might delete top level requires that are actually needed by such submodules.

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
---------------------------------

M-x  racket-add-require-for-identifier

Add a require for the identifier at point.

When more than one module supplies an identifer with the same name, they are listed for you to choose one. The list is sorted alphabetically, except modules starting with ``racket/'' and ``typed/racket/'' are sorted before others. While at the prompt, as a convenience you can press C-h to see the ``Search Manuals'' page for locally installed packages -- effectively like doing ``raco doc'' at the command line.

A ``require'' form is inserted into the buffer, followed by doing a racket-tidy-requires.

Caveat: This works in terms of identifers 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
------------------

M-x  racket-indent-line

Indent current line as Racket code.

Normally you don't need to use this command directly, it is used automatically when you press keys like RET or TAB. However you might refer to it when configuring custom indentation, explained below.

This behaves like lisp-indent-line, except that whole-line comments are treated the same regardless of whether they start with single or double semicolons.

  * Automatically indents forms that start with ``begin'' in the usual way that ``begin'' is indented.

  * Automatically indents forms that start with ``def'' or ``with-'' in the usual way that ``define'' is indented.

  * Has rules for many specific standard Racket forms.

To extend, use your Emacs init file to

     (put SYMBOL 'racket-indent-function INDENT)

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.

For example:

     (put 'test-case 'racket-indent-function 1)

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

     (test-case foo
     	   blah
     	   blah)

to this:

     (test-case foo
       blah
       blah)

If racket-indent-function has no property for a symbol, scheme-indent-function 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.

racket-smart-open-bracket-mode
------------------------------

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 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 racket-smart-open-bracket-mode has higher priority. See also the variable minor-mode-map-alist.

racket-insert-closing
---------------------

]  or )

Insert a matching closing delimiter.

With 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
-------------------------

C-c C-p

Cycle the sexpr among () [] {}.

racket-backward-up-list
-----------------------

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-unicode-input-method-enable
----------------------------------

M-x  racket-unicode-input-method-enable

Set input method to racket-unicode.

The racket-unicode input method lets you easily type various Unicode symbols that might be useful when writing Racket code.

To automatically enable the racket-unicode input method in racket-mode and racket-repl-mode buffers, put the following code in your Emacs init file:

     (add-hook 'racket-mode-hook #'racket-unicode-input-method-enable)
     (add-hook 'racket-repl-mode-hook #'racket-unicode-input-method-enable)

To temporarily enable this input method for a single buffer you can use ``M-x racket-unicode-input-method-enable''.

Use the standard Emacs key C-\ to toggle the input method.

When the racket-unicode input method is active, you can for example type ``All'' and it is immediately replaced with ``∀''. A few other examples:

omega
ω
x_1
x₁
x^1
x¹
A
𝔸
test-->>E
test-->>∃ (racket/redex)
vdash
⊢

To see a table of all key sequences use ``M-x describe-input-method <RET> racket-unicode''.

If you want to add your own mappings to the ``racket-unicode'' input method, you may add code like the following example in your Emacs init file:

     ;; Either (require 'racket-mode) here, or, if you use
     ;; use-package, put the code below in the :config section.
     (with-temp-buffer
       (racket-unicode-input-method-enable)
       (set-input-method "racket-unicode")
       (let ((quail-current-package (assoc "racket-unicode"
     				      quail-package-alist)))
         (quail-define-rules ((append . t))
     			("^o" ["ᵒ"]))))

If you don’t like the highlighting of partially matching tokens you can turn it off by setting input-method-highlight-flag to nil.

racket-align
------------

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'':

     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])

Or with point on the quote before ``a'':

     (list 'a 12        (list 'a   12
           'bar 23)           'bar 23)

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; racket-align will display an error message:

     (let ([a 0][b 1]
           [c 2])       error; unchanged
       ....)

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:

     (let ([foo         (let ([foo
            0]                 0]
           [bar 1]            [bar 1]
           [x 2])             [x   2])
       ....)              ....)

See also: racket-unalign.

racket-unalign
--------------

M-x  racket-unalign

The opposite of 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 racket-xp-mode.

Explore
=======

racket-xp-mode
--------------

M-x  racket-xp-mode

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

This minor mode is an optional enhancement to 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:

     (require 'racket-xp)
     (add-hook 'racket-mode-hook #'racket-xp-mode)

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 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.

  * Completion candidates.

  * Defintions' source and documentation.

When point is on a definition or use, related items are highlighted using racket-xp-def-face and racket-xp-use-face -- instead of drawing arrows as in Dr Racket. Information is displayed using the function(s) in the hook variable 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:

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

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.

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

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

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 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 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, racket-xp-next-error and racket-xp-previous-error to 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 M-. , xref-pop-marker-stack M-, , and xref-find-references: 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
M-.
xref-find-definitions
C-c C-d
racket-xp-documentation
C-c C-.
racket-xp-describe
C-c # P
racket-xp-previous-error
C-c # N
racket-xp-next-error
C-c # g
racket-xp-annotate
C-c # r
racket-xp-rename
C-c # ?
xref-find-references
C-c # .
xref-find-definitions
C-c # p
racket-xp-previous-use
C-c # n
racket-xp-next-use
C-c # k
racket-xp-previous-definition
C-c # j
racket-xp-next-definition

racket-xp-describe
------------------

C-c C-.

Describe the identifier at point in a *Racket Describe* buffer.

With C-u  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.

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.

  * 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)".

You can quit the buffer by pressing q. Also, at the bottom of the buffer are Emacs buttons -- which you may navigate among using TAB, and activate using RET -- for xref-find-definitions and racket-xp-documentation.

racket-xp-documentation
-----------------------

C-c C-d

View documentation in an external web browser.

The command varies based on how many C-u  command prefixes you supply.

 1. None.

     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 racket-documentation-search-location determines whether the search is done locally as with `raco doc`, or visits a URL.

 2. C-u

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

     Otherwise behaves like 1.

 3. C-u  C-u

     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-documentation-search
---------------------------

C-c C-d

Search documentation.

This command is useful in several situations:

  * You are not using racket-xp-mode for a racket-mode edit buffer, so racket-xp-documentation is not available.

  * There is no racket-repl-mode buffer with a live namespace, so 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.

Run
===

racket-repl-mode
----------------

M-x  racket-repl-mode

Major mode for Racket REPL.

You may use xref-find-definitions M-.  and xref-pop-marker-stack M-, : 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
}
racket-insert-closing
]
racket-insert-closing
)
racket-insert-closing
C-c C-\
racket-repl-exit
C-c C-c
racket-repl-break
C-c C-l
racket-logger
C-c C-z
racket-repl-switch-to-edit
C-c C-.
racket-repl-describe
C-c C-d
racket-repl-documentation
C-c C-e r
racket-expand-region
C-c C-e e
racket-expand-last-sexp
C-c C-e x
racket-expand-definition
C-c C-e f
racket-expand-file
C-w
comint-kill-region
C-a
comint-bol
C-M-y
racket-insert-lambda
C-M-q
prog-indent-sexp
C-M-u
racket-backward-up-list
TAB
indent-for-tab-command
C-j
newline-and-indent
RET
racket-repl-submit

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

racket-run
----------

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 racket-submodules-to-run.

See also racket-run-module-at-point, which runs just the specific module at point.

With C-u  uses errortrace for improved stack traces. Otherwise follows the racket-error-context setting.

With C-u  C-u  instruments code for step debugging. See racket-debug-mode and the variable 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 racket-run-and-switch-to-repl, which is even more like Dr Racket's Run command because it selects the REPL window after running.

In the racket-repl-mode buffer, output that describes a file and position is automatically ``linkified''. Examples of such text include:

  * Racket error messages.

  * rackunit test failure location messages.

  * print representation 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.

racket-run-and-switch-to-repl
-----------------------------

<f5>

This is racket-run followed by selecting the REPL buffer window.

racket-run-module-at-point
--------------------------

C-c C-k  or C-c C-c

Save the buffer and run the module at point.

Like 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
-----------

C-c C-z

Show a Racket REPL buffer in some window.

IMPORTANT

The main, intended use of Racket Mode's REPL is that you find-file some specific .rkt file, then racket-run it. The REPL will then match that file.

If the REPL isn't running, and you want to start it for no file in particular? Then you could use this command. But the resulting REPL will have a minimal ``#lang racket/base'' namespace. You could enter "(require racket)" if you want the equivalent of ``#lang racket''. You could also "(require racket/enter)" if you want things like ``enter!''. But in some sense you'd be ``using it wrong''. If you really don't want to use Racket Mode's REPL as intended, then you might as well use a plain Emacs shell buffer to run command-line Racket.

racket-repl-describe
--------------------

C-c C-.

Describe the identifier at point in a *Racket Describe* buffer.

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.

  * 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). If it has a contract or a Typed Racket type, that is also displayed.

You can quit the buffer by pressing q. Also, at the bottom of the buffer are Emacs buttons -- which you may navigate among using TAB, and activate using RET -- for racket-repl-visit-definition and racket-repl-documentation.

racket-repl-documentation
-------------------------

C-c C-d

View documentation in an external web browser.

The command varies based on how many C-u  command prefixes you supply.

 1. None.

     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 racket-documentation-search-location determines whether the search is done locally as with `raco doc`, or visits a URL.

 2. C-u

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

     Otherwise behaves like 1.

 3. C-u  C-u

     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
-------------

<C-M-f5>

Do ``racket <file>'' in a shell buffer.

racket-profile
--------------

C-c C-o

Like racket-run-module-at-point but with profiling.

Results are presented in a 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: 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
-------------------

M-x  racket-profile-mode

Major mode for results of racket-profile.

Key
Binding
,
racket-profile-sort
f
racket-profile-show-non-project
z
racket-profile-show-zero
p
racket-profile-prev
n
racket-profile-next
g
racket-profile-refresh
q
quit-window

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

racket-logger
-------------

C-c C-l

Create the racket-logger-mode buffer.

racket-logger-mode
------------------

M-x  racket-logger-mode

Major mode for Racket logger output.

The customization variable 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
g
racket-logger-clear
p
racket-logger-previous-item
n
racket-logger-next-item
w
toggle-truncate-lines
l
racket-logger-topic-level

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 step during initialization.

racket-debug-mode
-----------------

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. You can instrument entire files, and also individual functions.

     a. Entire Files

     Use two C-u  command prefixes for either racket-run or racket-run-module-at-point.

     The file will be instrumented for step debugging before it is run. Also instrumented are files determined by the variable 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.

     b. Function Definitions

     Move point inside a function definition form and use C-u  C-M-x  to ``instrument'' the function for step debugging. Then in the REPL, enter an expression that causes the instrumented function to be run, directly or indirectly.

     You can instrument any number of functions.

     You can even instrument while stopped at a break. For example, to instrument a function you are about to call, so you can ``step into'' it:

       * M-x  racket-xp-visit-definition to visit the definition.

       * C-u  C-M-x  to instrument the definition.

       * M-x  racket-unvisit to return.

       * Continue stepping.

     Limitation: Instrumenting a function required from another module won't redefine that function. Instead, it attempts to define an instrumented function of the same name, in the module the REPL is inside. The define will fail if it needs definitions visible only in that other module. In that case you'll probably need to use entire-file instrumentation as described above.

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

     Also, in the racket-mode buffer where the break is located, 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
?
racket-debug-help
h
racket-debug-run-to-here
p
racket-debug-prev-breakable
n
racket-debug-next-breakable
c
racket-debug-continue
u
racket-debug-step-out
o
racket-debug-step-over
SPC
racket-debug-step

Test
====

racket-test
-----------

<C-f5>  or C-c C-t

Run the ``test'' submodule.

Put your tests in a ``test'' submodule. For example:

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

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

With C-u  also runs the tests with coverage instrumentation and highlights uncovered code using font-lock-warning-face.

See also:

  * racket-fold-all-tests

  * racket-unfold-all-tests

racket-raco-test
----------------

M-x  racket-raco-test

Do ``raco test -x <file>'' in a shell buffer to run the ``test'' submodule.

Eval
====

racket-send-region
------------------

C-c C-r

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

racket-send-definition
----------------------

C-M-x

Send the current definition to the Racket REPL.

racket-send-last-sexp
---------------------

C-x C-e

Send the previous sexp to the Racket REPL.

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

Collections
===========

racket-open-require-path
------------------------

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.

racket-find-collection
----------------------

M-x  racket-find-collection

Given a collection name, try to find its directory and files.

Takes a collection name from point.

With C-u  prompts you.

If only one directory is found, ido-find-file-in-dir lets you pick a file there.

If more than one directory is found, ido-completing-read lets you pick one, then ido-find-file-in-dir lets you pick a file there.

Note: This requires the raco-find-collection package to be installed. To install it, in shell enter:

raco pkg install raco-find-collection

Tip: This works best with ido-enable-flex-matching set to t. Also handy is the flx-ido package from MELPA.

See also: racket-open-require-path.

Macro expand
============

racket-stepper-mode
-------------------

M-x  racket-stepper-mode

Major mode for Racket stepper output.

Used by the commands racket-expand-file, racket-expand-definition, racket-expand-region, and racket-expand-last-sexp.

Key
Binding
k
racket-stepper-previous-item
p
racket-stepper-previous-item
j
racket-stepper-next-item
n
racket-stepper-next-item
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 step during initialization.

racket-expand-file
------------------

C-c C-e f

Expand the racket-mode buffer's file in racket-stepper-mode.

Uses the macro-debugger package to do the expansion.

You do need to 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 C-u  also expands syntax from racket/base -- which can result in very many expansion steps.

racket-expand-region
--------------------

C-c C-e r

Expand the active region using racket-stepper-mode.

Uses Racket's expand-once in the namespace from the most recent racket-run.

racket-expand-definition
------------------------

C-c C-e x

Expand the definition around point using racket-stepper-mode.

Uses Racket's expand-once in the namespace from the most recent racket-run.

racket-expand-last-sexp
-----------------------

C-c C-e e

Expand the sexp before point using racket-stepper-mode.

Uses Racket's expand-once in the namespace from the most recent racket-run.

Other
=====

racket-mode-start-faster
------------------------

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 racket-run or racket-repl command must start the Racket process, it will start faster.

If you run this command, ever, you should 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 racket-program. Otherwise, you might get an error message due to the bytecode being different versions.

Showing information
===================

racket-show-pseudo-tooltip
--------------------------

Show using an overlay that resembles a tooltip.

This is nicer than 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. In that case, we simply left-justify everything and do not draw any border.

racket-show-echo-area
---------------------

Show things in the echo area.

A value for the variable racket-show-functions.

racket-show-header-line
-----------------------

Show things using a buffer header line.

A value for the variable 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
-------------------

Show things using pos-tip-show if available.

A value for the variable racket-show-functions.

Associating edit buffers with REPL buffers
==========================================

racket-repl-buffer-name-shared
------------------------------

M-x  racket-repl-buffer-name-shared

All racket-mode edit buffers share one racket-repl-mode buffer.

A value for the variable racket-repl-buffer-name-function.

racket-repl-buffer-name-unique
------------------------------

M-x  racket-repl-buffer-name-unique

Each racket-mode edit buffer gets its own racket-repl-mode buffer.

A value for the variable racket-repl-buffer-name-function.

racket-repl-buffer-name-project
-------------------------------

M-x  racket-repl-buffer-name-project

All racket-mode buffers in a project share a racket-repl-mode buffer.

A value for the variable racket-repl-buffer-name-function.

The ``project'' is determined by racket-project-root.

racket-project-root
-------------------

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
--------------------------------------

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

A suitable value for the variable racket-browse-url-function.

On some operating systems, the default handling for file URLs will ignore anchors -- the portion of the URL after the # character. But Racket documentation URLs depend on these to jump to a location within a page. This function attempts to work around that problem by using a temporary HTML file with a meta redirect as a ``trampoline''.

You might think that Emacs' browse-url would handle this portably, but as of Emacs 26 it does not. Although a user may customize the variable browse-url-browser-function to a specific technique that works, the default doesn't necessarily work for anchors on for instance macOS or Windows.

For Racket Mode, we do want Racket documentation to ``just work'' -- and because it does not do so on 2/3 operating systems, we reluctantly handle this. Note that a user can customize the variable racket-browse-url-function to browse-url -- which indeed is our default on *nix -- or to browse-url-browser-function in case they have customized that, or indeed to whatever they want. So this is an attempt to work better by default, while still supporting users who want to customize.

Variables
*********

General variables
=================

racket-program
--------------

Pathname of the racket executable.

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 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 racket-run or racket-run-module-at-point by using 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:

     ;; Local Variables:
     ;; racket-user-command-line-arguments: ("-f" "bar")
     ;; End:

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

     ("-f" "bar")

The following values will not work:

     '("-f" "bar")
     (list "-f" "bar")

racket-path-from-emacs-to-racket-function
-----------------------------------------

A function used to transform Emacs Lisp pathnames before supplying to the Racket back end.

If you run Emacs on Windows Subsystem for Linux, and want to run Racket programs using Windows Racket.exe rather than Linux racket, you can set this to racket-wsl-to-windows. In that case you probably also want to customize the ``reverse'': racket-path-from-racket-to-emacs-function.

racket-path-from-racket-to-emacs-function
-----------------------------------------

A function used to transform pathnames supplied by the Racket back end before using them in Emacs.

The default on Windows replaces back with forward slashes. The default elsewhere is identity.

If you run Emacs on Windows Subsystem for Linux, and want to run Racket programs using Windows Racket.exe rather than Linux racket, you can set this to racket-windows-to-wsl. In that case you probably also want to customize the ``reverse'': racket-path-from-emacs-to-racket-function.

racket-browse-url-function
--------------------------

Function to call to browse a URL.

On Linux this defaults to browse-url, otherwise it defaults to racket-browse-url-using-temporary-file.

racket-xp-after-change-refresh-delay
------------------------------------

Seconds to wait before refreshing racket-xp-mode annotations.

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

racket-xp-highlight-unused-regexp
---------------------------------

Only give 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-documentation-search-location
------------------------------------

The location of the Racket ``Search Manuals'' web page. Where racket-documentation-search, racket-xp-documentation and racket-repl-documentation should look for the search page.

  * If the value of this variable is `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. the help desk. Apart from ``%s'', the string should be a properly encoded URL.

REPL variables
==============

racket-repl-buffer-name-function
--------------------------------

How to associate racket-mode edit buffers with racket-repl-mode buffers.

The default is nil, which is equivalent to supplying racket-repl-buffer-name-shared: One REPL buffer is shared.

Other predefined choices include racket-repl-buffer-name-unique and racket-repl-buffer-name-project.

This is used when a racket-mode buffer is created. Changing this to a new value only affects racket-mode buffers created later.

Any such function takes no arguments, should look at buffer-file-name if necessary, and either setq-default or setq-local the variable racket-repl-buffer-name to a desired racket-repl-mode buffer name. As a result, 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:

  * racket-run

  * racket-run-and-switch-to-repl <f5>

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

  * racket-run-module-at-point C-c C-k  or C-c C-c

  * racket-test <C-f5>  or C-c C-t

  * racket-profile

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 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-pretty-print
-------------------

Use pretty-print instead of print in REPL?

Other variables
===============

racket-indent-curly-as-sequence
-------------------------------

Indent {} with items aligned with the head item?

This is indirectly disabled if racket-indent-sequence-depth is 0. This is safe to set as a file-local variable.

racket-indent-sequence-depth
----------------------------

To what depth should racket-indent-line search.

This affects the indentation of forms like '() `() #() -- and {} if 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 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 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.

Experimental debugger variables
===============================

racket-debuggable-files
-----------------------

Used to tell racket-run what files may be instrumented for debugging. Must be a list of strings that are pathnames, such as from racket--buffer-file-name, -or-, a function that returns such a list given the pathname of the file being run. If any path strings are relative, they are made absolute using expand-file-name with the directory of the file being run. The symbol `run-file may be supplied in the list; it will be replaced with the pathname of the file being run. Safe to set as a file-local variable.

Showing information
===================

racket-show-functions
---------------------

A special hook variable to customize racket-show.

Example functions include:

  * racket-show-pseudo-tooltip

  * racket-show-echo-area

  * racket-show-pos-tip

  * racket-show-header-line

Each function should accept two arguments: VAL and POS.

VAL is:

  * Non-blank string: Display the string somehow.

  * Blank string: Hide any previously displayed string.

  * nil: Hide any persistent UI that might have been created to show strings, such as by racket-show-header-line.

POS is the buffer position for which to show the message. It may be nil only when VAL is nil or a blank string. When the buffer content is a span, POS should be the end of the span. That way, for example, a function that shows a tooltip can position it not to hide the interesting span in the buffer.

Faces
*****

All
===

racket-keyword-argument-face
----------------------------

Face for #:keyword arguments.

racket-selfeval-face
--------------------

Face for self-evaluating expressions like numbers, symbols, strings.

racket-here-string-face
-----------------------

Face for here strings.

racket-xp-def-face
------------------

Face racket-xp-mode uses to highlight definitions.

racket-xp-use-face
------------------

Face racket-xp-mode uses to highlight uses.

racket-xp-unused-face
---------------------

Face racket-xp-mode uses to highlight unused requires or definitions.

racket-logger-config-face
-------------------------

Face for racket-logger-mode configuration.

racket-logger-topic-face
------------------------

Face for racket-logger-mode topics.

racket-logger-fatal-face
------------------------

Face for racket-logger-mode fatal level.

racket-logger-error-face
------------------------

Face for racket-logger-mode error level.

racket-logger-warning-face
--------------------------

Face for racket-logger-mode warning level.

racket-logger-info-face
-----------------------

Face for racket-logger-mode info level.

racket-logger-debug-face
------------------------

Face for racket-logger-mode debug level.