@@ -197,6 +197,44 @@ re-tokenization has progressed sufficiently.")
197
197
198
198
(defvar-local racket-hash-lang-mode-lighter " #lang" )
199
199
200
+ (defconst racket--agnostic-syntax-table
201
+ (let ((table (make-syntax-table )))
202
+ ; ; From Emacs Lisp Info node "Syntax Table Internals":
203
+ ; ;
204
+ ; ; Code Class
205
+ ; ; 0 whitespace
206
+ ; ; 1 punctuation
207
+ ; ; 2 word
208
+ ; ; 3 symbol
209
+ ; ; 4 open parenthesis
210
+ ; ; 5 close parenthesis
211
+ (map-char-table (lambda (key code+char )
212
+ (unless (<= 0 (car code+char) 5 )
213
+ (aset table key '(3 ))))
214
+ table)
215
+ table)
216
+ " Like `standard-syntax-table' but even simpler.
217
+
218
+ The only syntax categories in this table are whitespace,
219
+ punctuation, word, symbol, and open/close parens. Chars with any
220
+ other syntax are changed to symbol syntax.
221
+
222
+ For example we change all string-quote syntax to symbol, because
223
+ the chars used to delimit strings vary among programming
224
+ languages. Although that example happens to be the only practical
225
+ difference from `standard-syntax-table' , today, we still make a
226
+ generalized pass over it to be sure.
227
+
228
+ Note: Open/close paren syntax is preserved on the theory that,
229
+ although the /meaning/ of those characters may vary among langs,
230
+ their use as paired delimiters is likely universal, and it is
231
+ useful to support various Emacs features such as
232
+ rainbow-delimiters.
233
+
234
+ Note: `standard-syntax-table' is a better choice for spans lexed
235
+ as \" text\" tokens, because ?\" is definitely a string delimiter
236
+ in English." )
237
+
200
238
;;;### autoload
201
239
(define-derived-mode racket-hash-lang-mode prog-mode
202
240
'racket-hash-lang-mode-lighter
@@ -226,7 +264,7 @@ A discussion of the information provided by a Racket language:
226
264
(add-hook 'kill-buffer-hook
227
265
#'racket-mode-maybe-offer-to-kill-repl-buffer
228
266
nil t )
229
- (set-syntax-table racket--plain -syntax-table)
267
+ (set-syntax-table racket--agnostic -syntax-table)
230
268
; ; Tell `parse-partial-sexp' to consider syntax-table text
231
269
; ; properties.
232
270
(setq-local parse-sexp-lookup-properties t )
@@ -415,7 +453,7 @@ lang's attributes that we care about have changed."
415
453
; ; properties we add from tokens.
416
454
(set-syntax-table (if (plist-get plist 'racket-grouping )
417
455
racket-mode-syntax-table
418
- racket--plain -syntax-table))
456
+ racket--agnostic -syntax-table))
419
457
; ; Similarly for `forward-sexp-function' . The
420
458
; ; drracket:grouping-position protocol doesn't support a nuance
421
459
; ; where a `forward-sexp-function' should signal an exception
@@ -566,7 +604,7 @@ that need be set."
566
604
(put-face beg end (racket--sexp-comment-face (get-face-at beg))))
567
605
('parenthesis (when (facep 'parenthesis )
568
606
(put-face beg end 'parenthesis )))
569
- ('text (put-stx beg end racket--plain- syntax-table)
607
+ ('text (put-stx beg end ( standard- syntax-table) )
570
608
(put-face beg end racket-hash-lang-text))
571
609
(kind
572
610
(if-let (face (cdr (assq kind racket-hash-lang-token-face-alist)))
0 commit comments