What to use for paredit-convolute-sexp in paredit mode

He is changing

(abcd (1 2 |3 4) ha ha ha) 

in

 |(1 2 (abcd 3 4 ha ha ha)) 

What is the use of this conversion?

+4
source share
3 answers

Strictly speaking, it is used to reverse the nesting of an internal expression.

As an example:

 (let [foo bar] (if ab| c)) 

becomes

 (if ab (let [foo bar]| c)) 

As with use, I never had practical use for it specifically, but it’s a good building block for a larger macro

+4
source

Also just quickly add practical use, you can check out 1:40 of this lesson: http://emacsrocks.com/e14.html

call M-? with a cursor to open do-something extends the scope of let, from this:

 (defun my-other-command () (when (and (this-predicate) (that-predicate)) (let ((v (calculate-v)) (x (calculate-x))) (do-something) (do-some-more) (do-a-third-thing)))) 

straight to it:

 (defun my-other-command () (let ((v (calculate-v)) (x (calculate-x))) (when (and (this-predicate) (that-predicate)) (do-something) (do-some-more) (do-a-third-thing)))) 

Hooray! Andres

+9
source

To add a Nirk answer

For users smartparens Mx sp-prefix-save-excursion Mx sp-convolute-sexp modifies

 (let [foo bar] (if ab| c)) 

and

 (let [foo bar] (if ab |c)) 

in

 (if ab (let [foo bar] |c)) 

For users paredit Mx paredit-convolute-sexp modifies

 (let [foo bar] (if ab| c)) 

and

 (let [foo bar] (if ab |c)) 

in

 |(if ab(let [foo bar] c)) 

and

 |(if ab (let [foo bar] c)) 

For those who don't use any of them, you can still use convolute commands if you enable

 (require 'paredit) (require 'smartparens) 

in the initialization file, and only these two lines DO NOT configure your Emacs to use paredit or smartparens mode, and therefore everything is fine. If you install the paredit package from the package archive, the autoloads file may or may not configure Emacs to use paredit mode, and paredit does not have a configuration interface. If you install the smartparens package, regardless of what the autoloads file does, you can use the Customize interface to set smartparens-global-mode to nil if its default value is not nil (by default it is zero, although at the moment) .

0
source

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


All Articles