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)l et ((x (+ a b))) (print x))
pressing ( will give:
(defun foo (a b) (l et ((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-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 |
-> ) -> |
(foo bar) |
(foo bar |
-> C-u ) -> |
foo bar |
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 |
-> ) -> |
[(foo bar) |
[(foo bar |
-> C-u ) -> |
[foo bar |
([foo bar |
-> ) -> |
([foo bar baz]) |
([foo bar |
-> C-u ) -> |
|
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 |
-> <backtab> -> |
(foo) |
(foo bar |
-> <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 ( |
-> DEL -> |
(foo |
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) |
-> DEL -> |
(foo baz |
(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" " |
-> 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
Call lispy-delete-backward
.
lispy-delete-or-splice-or-slurp
Bound to C-d.
The result depends on the following conditions:
before lispy-left
Splice.
(foo |
-> C-d -> |
(foo |
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 |
-> C-d -> |
(foo baz |
(foo baz |
-> C-d -> |
(foo baz) |
before the opening quote of a string
Delete the entire string.
"foo" |
-> C-d -> |
"foo" |
before the closing quote of a string
Move the point forward.
"foo
|
-> C-d -> |
"foo" |
otherwise
Call lispy-delete
.