lispy.el parinfer function reference

Back to github This file in org-mode General function reference

General Notes

The keybindings here assume that lispy's parinfer key theme is in use. These keybindings are modeled after the behavior of the corresponding keys for parinfer, but they are adapted to lispy. This means that no inference is used, so none of the accompanying problems from that method are present. This also means that the functionality is not exactly the same.

Take ( as an example. In parinfer, the wrapping behavior is based on the indentation. The lispy equivalent will wrap to the end of the line where the current sexp ends by default.

With parinfer, starting with:

(defun foo (a b)
  let ((x (+ a b)))
    (print x))

pressing ( will give:

(defun foo (a b)
  (let ((x (+ a b)))
    (print x)))

With lispy, the result will be this:

(defun foo (a b)
  ( let ((x (+ a b))))
  (print x))

This means that you cannot first indent and then expect the wrapping to behave based on that indentation as you would with parinfer. However, it could be argued that lispy's version of parinfer's ( is actually more powerful since setting up the correct indentation may be tedious. To change how many sexps are wrapped in lispy, you can simply use a prefix arg. To achieve the same result as in the parinfer example, you could press C-0 (:

(defun foo (a b)
  ( let ((x (+ a b)))
     (print x)))

Another thing to note is that lispy will insert a space by default after wrapping. This example with missing parens around the let is somewhat contrived. Often you will want to insert something at the beginning of the sexp when wrapping, and in these cases, this behavior is convenient.

See the individual function references for more information.

Global bindings

Function reference

lispy--auto-wrap

This function is used to generate lispy-parens-auto-wrap, lispy-braces-auto-wrap and lispy-brackets-auto-wrap, which in turn take prefix arg. Each will act as their counterpart (lispy-parens, lispy-braces, and lispy-brackets respectively), but the behavior with no arg and with an arg of -1 have been swapped. With no arg, each will wrap to the end of the line where the current sexp ends or as far as possible before then. With an arg of -1, each will never wrap.

See the documentation for lispy-pair for visual examples.


lispy-parens-auto-wrap

Bound to (.

Call lispy--auto-wrap specialized with ().


lispy-braces-auto-wrap

Bound to {.

Call lispy--auto-wrap specialized with {}.


lispy-brackets-auto-wrap

Bound to [.

Call lispy--auto-wrap specialized with [].


lispy-barf-to-point

Not bound by default.

Barf to the closest sexp before the point. When prefix arg is not nil, barf from the left.

For the following examples, assume that ) has been bound to lispy-barf-to-point.

(foo bar baz)

-> ) ->

(foo bar) baz
(foo bar baz)

-> C-u ) ->

foo bar (baz)

lispy-barf-to-point-nostring

Bound to ), ], and }.

Like lispy-barf-to-point but self-inserts in strings and comments.


lispy--barf-to-point-or-jump-nostring

This function is used to generate alternative commands to lispy-barf-to-point-nostring that are delimiter specific. When it is not possible to barf for the specified delimiter, each command will jump out of the sexp delimited by that delimiter.

For the following examples, assume that ) has been bound to lispy-parens-barf-to-point-or-jump-nostring.

[(foo bar baz)]

-> ) ->

[(foo bar) baz]
[(foo bar baz)]

-> C-u ) ->

[foo bar (baz)]
([foo bar baz])

-> ) ->

([foo bar baz]) 
([foo bar baz])

-> C-u ) ->

([foo bar baz])

lispy-parens-barf-to-point-or-jump-nostring

Not bound by default.

Call lispy--barf-to-point-or-jump-nostring specialized with ().


lispy-brackets-barf-to-point-or-jump-nostring

Not bound by default.

Call lispy--barf-to-point-or-jump-nostring specialized with {}.


lispy-braces-barf-to-point-or-jump-nostring

Not bound by default.

Call lispy--barf-to-point-or-jump-nostring specialized with [].


lispy-indent-adjust-parens

Bound to TAB.

If the current line is indented incorrectly or the point is before the indentation, indent the line correctly and move the point past the indentation. Otherwise call lispy-up-slurp (see its visual examples for more information), which can be thought of as indenting the region or current line to the next level and adjusting the parentheses accordingly.


lispy-dedent-adjust-parens

Bound to <backtab>.

Move the region or all of the following sexps in the curent sexp to the right (out of the current sexp). This can be of thought as dedenting the code to the previous level and adjusting the parentheses accordingly.

(foo
 bar
 baz)

-> <backtab> ->

(foo)
bar
baz
(foo
 bar 
 baz)

-> <backtab> ->

(foo
 baz)
bar 

lispy-delete-backward-or-splice-or-slurp

Bound to DEL.

The result depends on the following conditions:

after lispy-left

Splice.

(foo (baz bar))

-> DEL ->

(foo baz bar)

after lispy-right

Slurp to the end of the line where the current sexp ends or as far as possible before then without moving the point. If it is not possible to slurp further, move the point backward.

(foo baz) bar

-> DEL ->

(foo baz bar)
(foo baz) 

-> DEL ->

(foo baz)

after the opening quote of a string

Delete the entire string. Since splicing isn't particularly useful for strings, this approach was chosen as an alternative to just unbalancing the quotes like parinfer does.

"foo" "baz"

-> DEL ->

"foo"  

after the closing quote of a string

Move the point back like in case 2 when the point is after a closing delimiter and no further slurping can be done. Since slurping isn't particularly useful for strings, this approach was chosen as an alternative to just unbalancing the quotes like parinfer does.

"foo" 

-> DEL ->

"foo"

otherwise

lispy-delete-or-splice-or-slurp

Bound to C-d.

The result depends on the following conditions:

before lispy-left

Splice.

(foo (baz bar))

-> C-d ->

(foo baz bar)

before lispy-right

Slurp to the end of the line where the current sexp ends or as far as possible before then without moving the point. If it is not possible to slurp further, move the point forward.

(foo baz) bar

-> C-d ->

(foo baz bar)
(foo baz)

-> C-d ->

(foo baz) 

before the opening quote of a string

Delete the entire string.

"foo" <span style="color: #2A00FF;">"baz"

-> C-d ->

"foo"  

before the closing quote of a string

Move the point forward.

"foo"

-> C-d ->

"foo" 

otherwise

Call lispy-delete.