开发者

PLT scheme (Racket)

开发者 https://www.devze.com 2023-02-23 04:19 出处:网络
H开发者_C百科as anyone got any idea how or if it is possible to carry parentheses auto complete in drScheme/RacketDrRacket doesn\'t auto-complete closing parentheses (which I\'m assuming is what you\'

H开发者_C百科as anyone got any idea how or if it is possible to carry parentheses auto complete in drScheme/Racket


DrRacket doesn't auto-complete closing parentheses (which I'm assuming is what you're asking about), but it will insert the correct paren shape -- so you can quickly hit ]]] a few times until you're closing off the right level.

But as a sidenote, it is much easier to work in any sexpr language (or actually any other language) if you keep the parentheses (of all shapes) and double quotes etc balanced at all times. DrRacket makes this easy to do by making Alt-( insert a pair of parens and leaving the cursor in the middle. Emacs does the same too, but DrRacket has similar keys for square brackets, curly braces, and double quotes. This style of work is very effective since you never need to count parens or even look at the highlights. It's also easy for working on code since the same holds then -- provided that the code is indented properly (which means that the parens fade to something you don't look at consciously).


I agree with Eli that it's easier to keep parens balanced at all times and would like to add that it's easy to implement the builtin behaviour and work from there to customize all you want. In DrRacket via "Edit/Keybindings/Add User-defined keybindings" you could add a file like the following which adds a binding to "Control-#" to insert a pair of parens at the cursor (or around the current selection if any). After that you have to restart DrRacket.

#lang s-exp framework/keybinding-lang
(keybinding "c:#"
        (λ (text evt)
          (define a (send text get-start-position))
          (define b (send text get-end-position))
          (send text insert #\( a)
          (send text insert #\) (+ b 1))
          (send text move-position 'left)))


If there is anyone with this problem 11 years later, do the following

  1. Go to preferences on Mac might be settings on Windows

  2. Click on the editing tab

  3. Enable automatic parenthesis

0

精彩评论

暂无评论...
验证码 换一张
取 消