You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This commit is a squash of nearly 250 commits from the long-running
branch, `hash-lang`.
Major themes:
1. Change REPL I/O. We no longer use a TCP connection to do I/O for
each REPL. Instead use commands (input) and notifications (output).
Furthermore send various kinds of output as distinct notifications.
2. Support use of hash-lang colors, indent, navigation when editing
and in REPL.
Add racket-hash-lang-mode, an alternative to racket-mode for editing
source files, which uses coloring, indent and navigation supplied by a
lang.
Any number of racket-mode or racket-hash-lang-mode buffers may take
turns using the same racket-repl-mode. The last-run edit buffer's
settings are used in the REPL.
Needs Racket 6.12+ for interval-map-ref/bounds.
Use syntax-color/color-textoid when available (with new-enough
versions of Racket and/or syntax-color-lib) but not required.
3. racket-xp-mode: Do "semantic" highlighting of binding sites.
Intended for use by racket-hash-lang-mode to get more than just lexer
colors.
---
Fixesgreghendershott#482.
Fixesgreghendershott#619.
Fixesgreghendershott#642.
Fixesgreghendershott#663.
Fixesgreghendershott#667.
Fixesgreghendershott#671.
Fixesgreghendershott#672.
Fixesgreghendershott#673.
Closesgreghendershott#64.
Closesgreghendershott#633.
Closes PR greghendershott#661.
#+MACRO: img @@texinfo:@image{$1,,,$2. Command I/O via pipe (local) or ssh (remote). REPL I/O via one TCP connection per REPL buffer (local/remote). Each back end provides zero or more REPLs.,.svg}@@
4
+
#+MACRO: img @@texinfo:@image{$1,,,$2. Command I/O via pipe (local) or ssh (remote). Each back end provides zero or more REPLs.,.svg}@@
The [[https://www.racket-mode.com/][Racket Mode]] package consists of a variety of Emacs major and minor modes, including:
34
34
35
-
- ~racket-mode~: A major mode for editing ~.rkt~ files.
35
+
- ~racket-mode~: A major mode to edit ~.rkt~ files. Generally assumes ~#lang racket~.
36
36
37
-
- {{{ref(racket-xp-mode)}}}: An optional minor mode that enhances ~racket-mode~ to explain and explore code.
37
+
- {{{ref(racket-hash-lang-mode)}}}: An alternative to ~racket-mode~ using behavior specified by a ~#lang~ for colors, indent, expression navigation, etc. /Experimental/.
38
38
39
-
- ~racket-repl-mode~: A major mode for running programs providing a REPL.
39
+
- {{{ref(racket-xp-mode)}}}: A minor mode to enhance either edit mode. Explain and explore code, similar to background check-syntax in Dr Racket.
40
+
41
+
- ~racket-repl-mode~: A major mode to run programs and use a REPL.
40
42
41
43
- Various other modes to support specific features:
42
44
- {{{ref(racket-logger-mode)}}}
@@ -45,7 +47,7 @@ The [[https://www.racket-mode.com/][Racket Mode]] package consists of a variety
45
47
46
48
For code, issues, and pull requests, see the [[https://github.com/greghendershott/racket-mode][Git repo]].
47
49
48
-
To fund this work, see [[https://github.com/users/greghendershott/sponsorship][GitHub Sponsors]] or [[https://www.paypal.me/greghendershott][PayPal]].
50
+
To sponsor this work, see [[https://github.com/users/greghendershott/sponsorship][GitHub Sponsors]] or [[https://www.paypal.me/greghendershott][PayPal]].
49
51
50
52
* Install, Update, and Uninstall
51
53
@@ -163,6 +165,29 @@ On macOS, downloading Racket doesn't add its ~bin~ directory to your ~PATH~. Eve
163
165
164
166
You can ~setq~ this directly in your Emacs init file (=~/.emacs= or =~/.emacs.d/init.el=), or, use {{{kbd(M-x)}}} ~customize~, as you prefer.
165
167
168
+
** Which major mode to use
169
+
170
+
Racket is a programming language.
171
+
172
+
Racket is also a "language-oriented programming language". Most Racket source files contain a `#lang` line. The lang may be an s-expression lang like ~racket~, or an at-expression lang like ~scribble/manual~, or something completely different like ~datalog~ or ~rhombus~.
173
+
174
+
The Racket Mode package offers a choice of two major modes to use in buffers for viewing and editing source code. Each has pros and cons.
175
+
176
+
Whereas ~racket-mode~ is in the tradition of Emacs ~lisp-mode~ and ~scheme-mode~ and assumes s-expression langs, ~racket-hash-lang-mode~ takes the approach of DrRacket to work for all langs.
177
+
178
+
- ~racket-mode~ is the original, "classic" mode for ~#lang racket~ and related s-expression languages. It is implemented entirely in Emacs and does /not/ need Racket Mode's back end racket process running. Font-lock (coloring) uses rules for a fixed set of identifiers from ~racket~ lang and popular modules like ~racket/match~. Indentation uses rules for a fixed set of forms, and may be customized (see below).
179
+
180
+
- ~racket-hash-lang-mode~ uses font-lock (colors) and indentation determined by the lang; to get this information it /does/ need the Racket Mode's back end racket process running. Although basic editing should feel fast, you might notice some delay when indenting. You might see colors appear after a small delay (but it will not block editing). Speaking of colors, they will be "plainer" than ~racket-mode~ -- mostly just for different kinds of tokens like numbers, comments, strings, and keywords. This looks similar to DrRacket. However if you /also/ enable the minor mode ~racket-xp-mode~, it will eventually add more colors at definition and use sites, and vary the colors depending on whether the identifier is local, imported, or from the module language. So you may see the "syntax" highlighting appear fairly quickly from ~racket-hash-lang-mode~, and later see more "semantic" highlighting contributed by ~racket-xp-mode~. The end result will be about as rich, although not exactly the same, as ~racket-mode~.
181
+
182
+
You can use different major modes for different kinds of files:
183
+
184
+
- For editing ~.rkt~ files and s-expression langs, which mode to use is personal preference.
185
+
186
+
- For ~.scrbl~ and at-expression langs like ~scribble/manual~, ~racket-hash-lang-mode~ is probably better than ~racket-mode~. (Note there is also an unrelated ~scribble-mode~ package.)
187
+
188
+
- For non-s-expression langs like ~datalog~ or ~rhombus~ (~.rhm~), ~racket-hash-lang-mode~ is definitely better than ~racket-mode~. (Note there is also an unrelated ~rhombus-mode~ package.)
189
+
190
+
You can use ~auto-mode-alist~ to tell Emacs which major mode to use initially for certain file extensions. Also, in a buffer you can use ~M-x racket-mode~ and ~M-x racket-hash-lang-mode~ to switch between them.
166
191
** Key bindings
167
192
168
193
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 {{{kbd(C-c C-c)}}} is bound by default to the ~racket-run~ command, let's say you wanted {{{kbd(F5)}}} to be an additional binding:
@@ -171,13 +196,16 @@ To customize things like key bindings, you can use ~racket-mode-hook~ in your Em
Likewise for ~racket-repl-mode-hook~ and ~racket-repl-mode-map~.
178
202
179
203
** Font-lock (syntax highlighting)
180
204
205
+
#+BEGIN_QUOTE
206
+
Note: The alternative major mode {{{ref(racket-hash-lang-mode)}}} disables all of the following behavior and uses colors determined by the #lang.
207
+
#+END_QUOTE
208
+
181
209
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.
182
210
183
211
Historically you might choose a lower level for speed. These days you might do so because you prefer a simpler appearance.
@@ -249,12 +277,20 @@ In any case, using the Emacs xref API allows for consistent command names, short
249
277
250
278
** Indent
251
279
280
+
#+BEGIN_QUOTE
281
+
Note: The alternative major mode {{{ref(racket-hash-lang-mode)}}} disables all of the following behavior and uses indentation determined by the #lang.
282
+
#+END_QUOTE
283
+
252
284
Indentation can be customized in a way similar to lisp-mode and scheme-mode: {{{ref(racket-indent-line)}}}.
253
285
254
286
(Indentation preserves your line breaks. If you want to use an auto-reformatter --- an expressive pretty printer that chooses line breaks while computing an optimal layout --- the Racket package [[https://docs.racket-lang.org/fmt/][fmt]] is supported by the Emacs package [[https://github.com/lassik/emacs-format-all-the-code][emacs-format-all-the-code]].)
255
287
256
288
** paredit
257
289
290
+
#+BEGIN_QUOTE
291
+
Note: If you use {{{ref(racket-hash-lang-mode)}}}, you can use ~racket-hash-lang-mode-hook~ to enable/disable paredit based on the specific #lang.
292
+
#+END_QUOTE
293
+
258
294
If you use [[https://melpa.org/#/paredit][paredit]], you might want to add keybindings to ~paredit-mode-map~:
259
295
260
296
- Bind the curly brace keys to ~paredit-open-curly~ and ~paredit-close-curly~.
0 commit comments