Light table paredit surround with parens

How can I take a form and make it an argument to another function surrounding it with parentheses with a single command?

In the example below, suppose the cursor starts from the very beginning and I do not move it.

(max 1 2 3) -> ((max. 1 2 3)) -> (= 3 (max. 1 2 3))

So my commands will be: 'magic-key-combination' β†’ '=' β†’ '' 'β†’' 3 '

+4
source share
2 answers

There is no single built-in command that does all this, however you can bind a key to several commands.

Try adding the following to your user.keymapfile (just replace "ctrl-m" with your preferred magic key combination).

{:+ {...
     :editor {...
              "ctrl-m" [:paredit.select.parent 
                        (:editor.open-pair "(")
                         :paredit.move.down.backward 
                         :paredit.move.up.backward  
                         :editor.char-right]
              ...}}}

. -, , paredit, !

+2

, . "(max 1 2 3)", "= 3" , :

= 3 (max 1 2 3)

. LightTable :

(= 3 (max 1 2 3))

, .

+1

Source: https://habr.com/ru/post/1531928/


All Articles