lispy.el function reference
Back to github | This file in org-mode | Parinfer function reference |
G az AZ x Global bindings
key | function name |
---|---|
] | lispy-forward |
[ | lispy-backward |
( | lispy-parens |
{ | lispy-braces |
} | lispy-brackets |
" | lispy-quotes |
) | lispy-right-nostring |
; | lispy-comment |
DEL | lispy-delete-backward |
C-d | lispy-delete |
C-k | lispy-kill |
C-y | lispy-yank |
C-e | lispy-move-end-of-line |
C-, | lispy-kill-at-point |
C-M-, | lispy-mark |
C-1 | lispy-describe-inline |
C-2 | lispy-arglist-inline |
C-3 | lispy-right |
C-4 | lispy-x |
C-8 | lispy-parens-down |
M-d | lispy-kill-word |
M-k | lispy-kill-sentence |
M-m | lispy-mark-symbol |
M-DEL | lispy-backward-kill-word |
M-. | lispy-goto-symbol |
M-, | pop-tag-mark |
G az AZ x [a-z] local bindings
key | function name |
---|---|
a | lispy-ace-symbol |
b | lispy-back |
c | lispy-clone |
d | lispy-different |
e | lispy-eval |
f | lispy-flow |
g | lispy-goto |
h | lispy-left |
i | lispy-tab |
j | lispy-down |
k | lispy-up |
l | lispy-right |
m | lispy-mark-list |
n | lispy-new-copy |
o | lispy-other-mode |
p | lispy-eval-other-window |
q | lispy-ace-paren |
r | lispy-raise |
s | lispy-move-down |
t | lispy-teleport |
u | lispy-undo |
v | lispy-view |
w | lispy-move-up |
x | see |
y | lispy-occur |
z | lispy-knight |
> | lispy-slurp |
< | lispy-barf |
- | lispy-ace-subword |
/ | lispy-splice |
G az AZ x [A-Z] local bindings
key | function name |
---|---|
A | lispy-beginning-of-defun |
B | lispy-ediff-regions |
C | lispy-convolute |
D | pop-tag-mark |
E | lispy-eval-and-insert |
F | lispy-follow |
G | lispy-goto-local |
H | lispy-ace-symbol-replace |
I | lispy-shifttab |
J | lispy-outline-next |
K | lispy-outline-prev |
L | unbound |
M | lispy-multiline |
N | lispy-narrow |
O | lispy-oneline |
P | lispy-paste |
Q | lispy-ace-char |
R | lispy-raise-some |
S | lispy-stringify |
U | unbound |
V | lispy-visit |
W | lispy-widen |
X | unbound |
Y | unbound |
Z | lispy-edebug-stop |
SPC | lispy-space |
G az AZ x x[a-z] local bindings
key | function name |
---|---|
xb | lispy-bind-variable |
xc | lispy-to-cond |
xd | lispy-to-defun |
xf | lispy-flatten |
xi | lispy-to-ifs |
xl | lispy-to-lambda |
xe | lispy-edebug |
xh | lispy-describe |
xj | lispy-debug-step-in |
xr | lispy-eval-and-replace |
xu | lispy-unbind-variable |
xB | lispy-store-region-and-buffer |
xT | lispy-ert |
Function reference
lispy-forward
Bound to ].
Works as replacement for the standard forward-list
.
Takes a numeric prefix arg
and moves forward list arg
times or
until error.
Unlike forward-list
, no error will be reported if it's not possible
to move arg
times. It that case, move as many times as possible.
To facilitate entering a very large arg
, arg
0 is interpreted as
arg
2000.
Return t
if could move at least once, otherwise
call lispy-right
and return nil
.
Unlike forward-list
, parens in strings and comments are ignored.
lispy-backward
Bound to [.
Works as replacement for the standard backward-list
.
Takes a numeric prefix arg
and moves backward list arg
times or
until error.
Unlike backward-list
, no error will be reported if it's not possible
to move arg
times. It that case, move as many times as possible.
To facilitate entering a very large arg
, arg
0 is interpreted as
arg
2000.
Return t
if could move at least once, otherwise
call lispy-left
return nil
.
Unlike backward-list
, parens in strings and comments are ignored.
lispy-right
Bound to C-3 and l.
Works as replacement for the standard up-list
.
Takes a numeric prefix arg
and moves up forward list arg
times or
until error.
Unlike up-list
, no error will be reported if it's not possible to
move up arg
times. It that case, move as many times as possible.
Return point if could move arg
times, otherwise return nil
.
Unlike up-list
, parens in strings and comments are ignored.
lispy-right-nostring
Bound to ).
Works the same ways as lispy-right
, except self-inserts in
strings and comments.
Self-inserting in strings and comments makes parens different from the other pair functions that always insert the whole pair:
key | function | inserts |
---|---|---|
{ | lispy-braces | {} |
} | lispy-brackets | [] |
" | lispy-quotes | "" |
When you want to insert a single character from the pair, use C-q. Or insert a pair and delete the other character.
lispy-left
Bound to h.
Takes a numeric prefix arg
and moves up backward list arg
times or
until error. This is a combination of arg
times lispy-right
and once
lispy-different
.
When the region is active, the region (not the code) will move up
backward arg
times:
(defun lispy-right (arg) "Move outside list forwards ARG times. Return nil on failure, t otherwise." (interactive "p") (if (region-active-p) |
-> h -> |
(defun lispy-right (arg) "Move outside list forwards ARG times. Return nil on failure, t otherwise." (interactive "p") |
lispy-down
Bound to j.
Takes a numeric prefix arg
and moves down the current list arg
times.
Here, current list means the innermost list that contains the point. Moving down means so literally only if there is a newline after each element of current list, otherwise it's down or left.
j maintains a guarantee that it will not exit the current list, so you can use e.g. 99j to move to the last element of the current list.
When region is active, j will move the region by forward-sexp
,
i.e. move the point and the mark by forward-sexp
.
This allows to easily mark any element(s) of current list. j maintains a guarantee that the region will not exit the currrent list, so if you want to mark last 3 elements of the current list, you can mark the first 3 elements of the current list and press 99j.
For example, starting with:
( a b c d e f g h i j k l m n o p q r s t u v w x y z)
after mi:
(ab c d e f g h i j k l m n o p q r s t u v w x y z)
after 2>:
(a b cd e f g h i j k l m n o p q r s t u v w x y z)
after 99j:
(a b c d e f g h i j k l m n o p q r s t u v w x y z)
lispy-up
Bound to k.
Takes a numeric prefix arg
and moves up the current list arg
times.
Here, current list means the innermost list that contains the point. Moving up means so literally only if there is a newline after each element of current list, otherwise it's up or right.
k maintains a guarantee that it will not exit the current list, so you can use e.g. 99k to move to the first element of current list.
When region is active, k will move the region by backward-sexp
,
i.e. move the point and the mark by backward-sexp
.
lispy-different
Bound to d.
Switch to the different side of current sexp.
When region is active, equivalent to exchange-point-and-mark
.
lispy-flow
Bound to f.
Flow in the direction of current paren, i.e.
looking at lispy-left
Find the next lispy-left
not in comment or string going down the
file.
looking back lispy-right
Find the next lispy-right
not in comment or string going up the
file.
lispy-back
Bound to b.
Move point to the previous position in lispy-back
history.
The following functions write to this history:
key | function name |
---|---|
l | lispy-right |
h | lispy-left |
f | lispy-flow |
j | lispy-down |
k | lispy-up |
m | lispy-mark-list |
q | lispy-ace-paren |
i | lispy-mark-car |
lispy-knight
Bound to z.
zj and zk are bound in a hydra that allows to move through the leftmost parens on each line.
This is useful if you want to navigate disregarding syntax: since j and k can't exit the parent list they're not suitable for this.
zj and zk move like the knight figure in chess, in a combination of horizontal and vertical movement.
lispy-mark-car
Bound to i while the region is active.
Mark the first element (car) of the currently selected thing (list or region).
when at list boundary
(defun lispy-right (arg) "Move outside list forwards ARG times\. Return nil on failure, t otherwise\." (interactive "p") (if (region-active-p) (lispy-mark-right arg) (lispy--out-forward arg))) |
-> i -> |
(defun |
when at string boundary
Mark its inner contents.
(list "spam spam spam" |
-> i -> |
(list "spam spam spam |
when at region boundary
(list "spam spam spam |
-> i -> |
(list "spam |
when a quoted symbol is marked
Select the unquoted part, it's useful for a subsequent e
(lispy-eval
).
(add-to-list 'auto-mode-alist |
-> i -> |
(add-to-list 'auto-mode-alist |
lispy-move-end-of-line
Bound to C-e.
Works as replacement for the standard move-end-of-line
.
Regular move-end-of-line
does nothing the second time when called
twice in a row.
When called twice in a row and
inside string
Move to the end of the string.
otherwise
Return to the starting position.
lispy-ace-paren
Bound to q.
Starting with this:
(defun lispy-define-key (keymap key def &optional from-start) "Forward to (`define-key' KEYMAP KEY (`lispy-defun' DEF FROM-START))." (let ((func (defalias (intern (concat "special-" (symbol-name def))) (lispy--insert-or-call def from-start))))( unless (member func ac-trigger-commands) (push func ac-trigger-commands)) (unless (member func company-begin-commands) (push func company-begin-commands)) (eldoc-add-command func) (define-key keymap (kbd key) func)))
by pressing q you get this:
adefun lispy-define-key bkeymap key def &optional from-start) "Forward to c`define-key' KEYMAP KEY d`lispy-defun' DEF FROM-START))." elet fgfunc hdefalias iintern jconcat "special-" ksymbol-name def))) llispy--insert-or-call def from-start))))m unless nmember func ac-trigger-commands) opush func ac-trigger-commands)) punless qmember func company-begin-commands) rpush func company-begin-commands)) seldoc-add-command func) tdefine-key keymap ukbd key) func)))
Now you can change the point position by pressing a letter or cancel with C-g.
Press 2q to use the whole window instead of just the current top-level sexp.
lispy-ace-symbol
Bound to a.
Starting with this:
(defun lispy-define-key (keymap key def &optional from-start) "Forward to (`define-key' KEYMAP KEY (`lispy-defun' DEF FROM-START))." (let ((func (defalias (intern (concat "special-" (symbol-name def))) (lispy--insert-or-call def from-start))))( unless (member func ac-trigger-commands) (push func ac-trigger-commands)) (unless (member func company-begin-commands) (push func company-begin-commands)) (eldoc-add-command func) (define-key keymap (kbd key) func)))
by pressing a you get this:
(defun lispy-define-key (keymap key def &optional from-start) "Forward to (`define-key' KEYMAP KEY (`lispy-defun' DEF FROM-START))." (let ((func (defalias (intern (concat "special-" (symbol-name def))) (lispy--insert-or-call def from-start))))a unlessb(membercfuncdac-trigger-commands) e(pushffuncgac-trigger-commands)) (unless (member func company-begin-commands) (push func company-begin-commands)) (eldoc-add-command func) (define-key keymap (kbd key) func)))
Now you can mark a symbol by pressing a letter, or cancel with C-g.
Here's the end result of ad:
(defun lispy-define-key (keymap key def &optional from-start) "Forward to (`define-key' KEYMAP KEY (`lispy-defun' DEF FROM-START))." (let ((func (defalias (intern (concat "special-" (symbol-name def))) (lispy--insert-or-call def from-start)))) (unless (member func ac-trigger-commands) (push func ac-trigger-commands)) (unless (member func company-begin-commands) (push func company-begin-commands)) (eldoc-add-command func) (define-key keymap (kbd key) func)))
lispy-ace-symbol
's jump scope is the current list by default.
Calling it with digit-argument
will extend this to the current
list's parents.
Now you can follow up with
key | function name |
---|---|
F | lispy-follow |
C-1 | lispy-describe-inline |
e | lispy-eval |
E | lispy-eval-and-insert |
P | lispy-paste |
r | lispy-raise |
lispy-ace-subword
lispy-splice
Bound to /.
Splice the current list into the parent list. Move the point to the next list to splice in appropriate direction. If there are none within the parent list, move to the parent list in appropriate direction.
( |
-> / -> |
(a |
lispy-occur
Bound to y.
Do an occur for the current top-level sexp. Go back-to-paren afterwards.
This is useful e.g. to see where a particular variable is used within the current defun.
lispy-follow
Bound to F.
When region is active jump to the definition of marked symbol. Otherwise jump to the definition of the first symbol in current sexp.
Use D or M-, to go back.
Elisp, Clojure and Common Lisp are supported.
lispy-goto-symbol
pop-tag-mark
Bound to D and M-,.
This is a standard Emacs function that reverses:
- F (
lispy-follow
) - M-. (
lispy-goto-symbol
)
It's bound to M-* in the default Emacs. I like to bind it to M-, everywhere.
lispy-describe-inline
Bound to C-1.
Show the documentation for current function or currently
marked symbol (see lispy-ace-symbol
).
(defun lispy-define-key (keymap key def &optional from-start) "Forward to (`define-key' KEYMAP KEY (`lispy-defun' DEF FROM-START))." (let ((func (defalias (intern (concat "special-" (symbol-name def))) (lispy--insert-or-call def from-start)))) Return non-nil if ELT is an element of LIST. Comparison done with `equal'. The value is actually the tail of LIST whose car is ELT. (fn ELT LIST) (unless (member funca c-trigger-commands) (push func ac-trigger-commands)) (unless (member func company-begin-commands) (push func company-begin-commands)) (eldoc-add-command func) (define-key keymap (kbd key) func)))
lispy-arglist-inline
Bound to C-2.
Show the argument list for current function.
(defun lispy-define-key (keymap key def &optional from-start) "Forward to (`define-key' KEYMAP KEY (`lispy-defun' DEF FROM-START))." (let ((func (defalias (intern (concat "special-" (symbol-name def))) (lispy--insert-or-call def from-start)))) (member elt list) (unless (member funca c-trigger-commands) (push func ac-trigger-commands)) (unless (member func company-begin-commands) (push func company-begin-commands)) (eldoc-add-command func) (define-key keymap (kbd key) func)))
lispy-eval
Bound to e.
Eval current region or sexp. The result will be displayed in the minibuffer.
Elisp, Clojure, Scheme and Common Lisp are supported.
Elisp extensions:
lispy-lax-eval
When lispy-lax-eval
isn't nil
, "Symbol's value as variable is
void…" error will be caught and the variable in question will be set
to nil
.
eval of defvar
Will do a setq
in addition to defvar
(i.e. the behavior of C-M-x).
eval of defcustom
Same as for defvar
.
eval of defface
The behavior of C-M-x.
lispy-eval-and-insert
Bound to E.
Eval current region or sexp. The result will be inserted in the current buffer after the evaluated expression.
- Starting with
|(
the point will not be moved, allowing to press E again. - Starting with
)|
the point will end up after the inserted expression. - Starting with an active region, the region will be deactivated and result will be inserted at point.
lispy-bind-variable
Bound to xb.
Transform the current list expression into a let-bound variable;
iedit-mode
is used to name the new variable. Use M-m to finish
naming the variable.
(defun my-forward-line (arg) (message "%S lines" |
-> xbln M-m ChO-> |
(defun my-forward-line (arg) (let ((ln (forward-line arg))) |
lispy-unbind-variable
Bound to xu.
Unbind a let-bound variable. Also works for Clojure.
(defun foobar () (let ( |
-> xu -> |
(defun foobar () (let ( |
lispy-eval-and-replace
Bound to xr.
Eval current expression and replace it at point.
(foo |
-> xr -> |
|
lispy-store-region-and-buffer
Bound to xB.
Store current buffer and region for further usage. When region isn't active, store the bounds of current expression instead.
Currently, these functions make use of stored info:
key | function name |
---|---|
B | lispy-ediff-regions |
lispy-ediff-regions
Bound to B.
Comparable to ediff-regions-linewise
, except the region and
buffer selection is done differently:
- first buffer and region are defined by
lispy-store-region-and-buffer
. - second buffer and region are the current buffer and region (or current sexp bounds if the region isn't active)
The buffers can of course be the same.
A useful scenario for this function is C-x v ~
(vc-revision-other-window
) RET and then follow up by selecting one
function that was changed with b in one buffer and with B in other
buffer. This results in ediff just for that one single
function. This is helpful if ediff-buffers
isn't what you want.
Another scenario is to compare two different functions that have similar code,
for instance lispy-move-down
and lispy-move-up
.
lispy-to-lambda
Use xl (local) or C-4 l (global) to turn the current function definition into a lambda.
One use case is when I want to edebug a lambda but not the function
that's using it. So I extract the lambda with lispy-to-defun
, edebug it and
turn it back into a lambda with this function.
Other use case is that I simply want to get the lambda since the function isn't used anywhere else.
Starting with this:
(defun helm-owiki-action (x) (find-file (expand-file-name (format "%s.org" x)helm-owiki-directory)))
by pressing xl you will get this:
( lambda (x) (find-file (expand-file-name (format "%s.org" x) helm-owiki-directory)))
lispy-to-defun
Use xd (local) or C-4 d (global) to turn the current lambda into a defun.
You'll be prompted for a name, the lambda will be replaced with that name and the new definition will be in the kill ring.
Starting with this:
(mapcar( lambda (x) (* x x)) (number-sequence 1 10))
by pressing xd and entering square
and then pressing d C-m C-y
you'll get this:
(mapcar #'square (number-sequence 1 10)) (defun square (x) (* x x))
It's also possible to transform a toplevel function call into a defun with xd:
Starting with this
(foo-delete-region beg end)
by pressing xd you'll get this:
(defun foo-delete-region (beg end))
It's also possible to transform a block into a defun. Start with:
(defun cube (x) (* x( * x x)))
Enter xdsquare x[ to get:
(defun square (x) (* x x)) (defun cube (x) (* x( square x)))
lispy-parens
lispy-braces
lispy-brackets
lispy-quotes
Bound to ".
Insert a pair of quotes around the point.
Takes a prefix arg
.
The result depends on the following conditions, each tried one by one until one that holds true is found:
region is active, contained in string
Wrap the region with quoted quotes:
(message "We are the Knights who say |
-> " -> |
(message "We are the Knights who say \" |
region active
Wrap the region with quotes.
(list 'foo bar |
-> " -> |
(list 'foo " |
in string and arg
isn't nil
Unquote current string.
(list 'foo " |
-> C-u " -> |
(list 'foo bar |
in string and arg
is nil
Insert a pair of quoted quotes around point.
Starting with
"We are the Knights who say"
pressing " will give:
"We are the Knights who say \"\ ""
arg
isn't nil
Forward to lispy-stringify
.
otherwise
Insert quotes, with a single space on either side where appropriate, and position the point between the quotes.
Starting with
(message)
pressing " will give:
(message "" )
lispy-parens-down
Bound to C-8.
Exit current list and insert a newline and a pair of parens.
(foo |
-> C-8 -> |
(foo) ( |
lispy-space
Bound to SPC.
Insert a space.
Behave differently in this situation:
( |
-> SPC -> |
( |
lispy-pair
This function, taking arguments left
and right
, is used to generate
lispy-parens
,
lispy-braces
and lispy-brackets
, which in turn take prefix arg
.
The arguments align with those of lispy-slurp
.
The result depends on the following conditions, each tried one by one until one that holds true is found:
region active
Wrap the region with left
and right
.
inside a string before "\\"
Starting with
"a regex \\"
pressing ( will give:
"a regex \\(\ \)"
and pressing { will give:
"a regex \\{\ \}"
and pressing } will give:
"a regex \\[\ \]"
inside string or comment
Insert left
, right
and put the point between them.
Starting with:
"a string"
key | result |
---|---|
( | "a string (" |
) | "a string )" |
{ | "a string {}" |
} | "a string []" |
elisp character expression
Starting with
?\
pressing ( will self-insert it to give:
?\(
This also works for ), {, }.
This doesn't work for [ and ], they should be inserted with C-q [ and C-q ].
no arg
is explicitly specified
- Re-indent and insert space according to
lispy--space-unless
. - Insert
left
,right
and put the point between them. - Insert a space after
right
if it's appropriate.
arg
is positive
Wrap that number of sexps with left
and right
.
Starting with:
( do-some-thing) (do-other-thing)
pressing 1( will give:
((do-some-thing)) (do-other-thing)
1 here is responsible to setting arg
to 1. C-u will also cause a
single sexp to be wrapped.
arg
is 0
Wrap as many sexps as possible.
Starting with:
(foob ar baz quux)
pressing M-0( will give:
(foo (bar baz quux))
arg
is -1
Wrap to the end of the line where the current sexp ends or as far as possible before that position.
Starting with:
(foob ar baz quux)
pressing M--( will give:
(foo (bar baz) quux)
lispy-x
lispy-kill
Bound to C-k.
A replacement for kill-line
that keeps parens consistent.
The result depends on the following conditions, each tried one by one until one that holds true is found:
inside comment
Call kill-line
.
inside string and string extends past this line
Call kill-line
.
inside string that ends on this line
Delete up to the end of the string.
on a line of whitespace
Delete whole line, moving to the next one, and re-indent.
inside empty list
Delete the empty list.
parens between point and eol are balanced
Call kill-line
.
possible to up-list
Delete from point to end of list.
otherwise
Delete current sexp.
lispy-new-copy
Bound to n.
Copy current sexp or region to kill ring.
lispy-yank
Bound to C-y.
Replaces yank
.
The only difference is that yanking into an empty string will add
escape sequences.
Starting with:
( message "test")
pressing C-k " C-y will give:
"(message \"test\")"
whereas a regular yank
would give:
"(message "test")"
lispy-delete
Bound to C-d.
Replaces delete-char
, keeping parens consistent.
The result depends on the following conditions, each tried one by one until one that holds true is found:
region active
Delete region.
inside a string before \"
Delete \".
"say |
-> C-d -> |
"say |
at last char of the string
Move to the beginning of string. This allows to delete the whole string with the next C-d.
(message "more gold is required |
-> C-d -> |
(message |
in string near \\( or \\)
Remove \\( and \\).
(looking-at "\\([a-z]+ |
-> C-d -> |
(looking-at "[a-z]+ |
(looking-at " |
-> C-d -> |
(looking-at " |
the next char isn't end of string
Call delete-char
.
inside comment
Call delete-char
.
before lispy-left
Delete arg
sexps.
(foo |
-> 2 C-d -> |
|
before "
Delete string.
before lispy-right
Delete containing sexp.
(foo (bar) (baz |
-> C-d -> |
(foo (bar) |
otherwise
Call delete-char
.
lispy-delete-backward
Bound to DEL.
Replaces backward-delete-char
, keeping parens consistent.
The result depends on the following conditions, each tried one by one until one that holds true is found:
region active
Delete region.
at first char of the string
Move to the end of the string. This allows to delete the whole string with the next DEL.
(message " |
-> DEL -> |
(message "more gold is required" |
in string near \\( or \\)
Remove \\( and \\).
(looking-at "\\([a-z]+\\) |
-> DEL -> |
(looking-at "[a-z]+ |
(looking-at "\\( |
-> DEL -> |
(looking-at " |
in string or comment
Call backward-delete-char
.
after lispy-right
Delete arg
sexps.
(foo (bar) (baz) |
-> 2 DEL -> |
(foo) |
before lispy-left
Delete containing sexp.
(foo (bar) ( |
-> DEL -> |
(foo (bar) |
after a string
Delete string.
(message "more gold is required" |
-> DEL -> |
(message) |
otherwise
Call backward-delete-char
.
lispy-mark
Bound to C-M-,.
Mark the smallest comment or string or list that includes point.
This command will expand region when repeated.
lispy-kill-at-point
Bound to C-,.
Kill the smallest comment or string or list that includes point.
lispy-mark-symbol
Bound to M-m.
The result depends on the following conditions, each tried one by one until one that holds true is found:
lispy-bind-variable
in progress
Exit iedit-mode
and mark the newly bound variable with a region.
This allows to use lispy-convolute
to place the new let
binding
into an appropriate place.
in comment
Mark comment.
looking at space or parens
Skip space and parens and mark the next thing between them.
looking back lispy-right
Mark last symbol in previous list.
region is active
Call forward-sexp
.
otherwise
Forward to lispy-mark
.
lispy-string-oneline
Bound to O, when a string is marked.
Convert current string to one line.
Starting with
(message "foobar baz")
pressing M-m O will give:
(message "foo\nbar\nbaz")
This can be useful when debugging a macro-generated function (i.e. it
doesn't have a body). First produce the body with symbol-function
,
then prettify the body with M and O, then edebug
with x e.
lispy-outline-next
Bound to J.
Takes a numeric prefix arg
and
calls outline-next-visible-heading
arg
times or until
past the last outline-regexp
.
See lispy-shifttab
for more info.
lispy-outline-prev
Bound to K.
Takes a numeric prefix arg
and
calls outline-previous-visible-heading
arg
times or until
past the first outline-regexp
.
See lispy-shifttab
for more info.
lispy-shifttab
Bound to I.
Toggles on/off an org-mode
-like outline.
To make this work, lispy-mode
will modify outline-regexp
and
outline-level-function
for the current buffer while it's on.
To give an example of the recommended outline syntax:
;;* Level 1 ;;** Level 2 ;;*** Level 3
You can create new outlines with M-RET (lispy-meta-return
).
You can promote the current outline with:
- M-right (
lispy-meta-right
), - l (
lispy-right
).
You can demote the current outline with:
- M-left (
lispy-meta-left
), - h (
lispy-left
).
Useful together with:
key | function name |
---|---|
J | lispy-outline-next |
K | lispy-outline-prev |
i | lispy-tab |
lispy-tab
Bound to i.
The result depends on the following conditions, each tried one by one until one that holds true is found:
in outline
Hide/show outline.
region is active
Forward to lispy-mark-car
.
otherwise
Indent and prettify code.
Prettify means to remove hanging closing parens, extra spaces,
and to add space where it's needed, e.g. (lambda (x))
instead of
(lambda(x))
:
|
-> i -> |
|
lispy-edebug-stop
Bound to Z.
Does the same as q in edebug
, except current function's arguments
will be saved to their current values.
This allows to continue debugging with lispy-eval
(e) from
edebug
's current context.
The advantage is that you can edit the code as you debug, as edebug
puts your code in read-only mode.
lispy-flatten
Bound to xf.
Inline current function or macro call, i.e. replace it with function body. The function should be interned and its body find-able.
|
-> xf -> |
|
lispy-to-ifs
Bound to xi.
Transform current cond
expression to equivalent nested if
expressions. The whitespace, such as comments and newlines, is
preserved as much as possible.
The reverse is lispy-to-cond
.
|
-> xi -> |
|
lispy-to-cond
Bound to xc.
Transform current nested if
expressions to an equivalent cond
expression. Also works for
case
. The whitespace, such as comments and newlines, is preserved as much as possible.
The reverse is lispy-to-ifs
.
|
-> xc -> |
|
lispy-visit
Bound to V.
Visit another file within this project using projectile
or
find-file-in-project
(customize lispy-visit-method
to choose).
Use V to call projectile-find-file
.
Use 2V to call projectile-find-file-other-window
.
lispy-narrow
lispy-widen
Bound to W.
Forward to widen
.
lispy-oneline
Bound to O.
Turn current sexp into one line.
|
-> O -> |
|
lispy-multiline
Bound to M.
Extend current sexp into multiple lines.
Especially useful on results of macroexpand
.
Turn current sexp into one line.
|
-> M -> |
|
lispy-view
Bound to v.
Recenter current sexp to be on the first line of the window. When called twice in a row, recenter back to the original position.
It's just a slightly modified shorthand for the standard C-l (recenter-top-bottom
).
lispy-slurp
Bound to >.
Grow either current sexp or region (if it's active) in appropriate
direction. Opposite of lispy-barf
. With an arg of
0, grow as far as possible. With an arg of -1, grow until the end
of the line where the current sexp ends or as far as possible before
that position.
Example 1:
(progn) |
-> > -> |
(progn (foo)) |
Example 2:
"foo" |
-> > -> |
|
Example 3:
(foo bar |
-> > -> |
(foo bar baz |
Example 4:
((foo) |
-> 0> -> |
((foo bar baz quux) |
Example 5:
((foo) |
-> M--> -> |
((foo bar baz) |
lispy-barf
Bound to <.
Shrink either current sexp or region (if it's active) in appropriate
direction. Opposite of lispy-slurp
.
Example 1:
(progn (foo)) |
-> < -> |
(progn) |
Example 2:
|
-> < -> |
"foo" |
Example 3:
(foo bar bar |
-> < -> |
(foo bar |
lispy-other-mode
Bound to o.
This is a minor mode that changes the behavior of several key bindings, most notably the hjkl arrow keys. This mode can is turned off automatically after one of its key bindings is used. You can toggle it off with o if you change your mind about calling the modified hjkl.
key | function name |
---|---|
h | lispy-move-left |
j | lispy-down-slurp |
k | lispy-up-slurp |
l | lispy-move-right |
SPC | |
g |
lispy-move-left
Bound to oh.
Move current expression to the left, outside the current list.
(require 'ob-python) (let ((color "Blue")) |
-> oh -> |
(require 'ob-python) |
lispy-down-slurp
Bound to oj.
Move current expression to become the first element of the first list below.
|
-> oj -> |
'( |
lispy-up-slurp
Bound to ok.
Move current expression to become the last element of the first list above.
(list 'my-sword 'my-bow) |
-> ok -> |
(list 'my-sword 'my-bow |
lispy-move-right
Bound to ol.
Move current expression to the right, outside the current list.
(require 'ob-python) (message "What... is your favorite color?") (let ((color "Blue")) (message color) |
-> ol -> |
(require 'ob-python) (message "What... is your favorite color?") (let ((color "Blue")) (message color)) |
lispy-comment
Bound to ;.
Comment current expression or region. With a prefix arg, comment many expressions. With a prefix arg and already inside comment, uncomment instead.
(require 'ob-python) |
-> ; -> |
|
lispy-clone
Bound to c.
Copy current list or region and paste it below, without changing point or mark.
With a prefix arg, copy that many times.
|
-> 3c -> |
|
lispy-goto
Bound to g.
Collect the tags (e.g. functions, variables …) in current directory and offer a helm completion list to jump to a selected tag.
lispy-goto-local
Bound to G.
Similar to lispy-goto
, but only current file's tags are used instead
of whole directory's tags.
lispy-goto-recursive
Bound to ogr.
Similar to lispy-goto
, but all sub-directories' tags are used in
addition to directory's tags.
lispy-goto-projectile
Bound to 0g and ogp.
Similar to lispy-goto-recursive
, but projectile-project-root
is
used as the base directory.
lispy-goto-elisp-commands
Bound to oge
.
Navigate to interactive Elisp functions (commands) in current file.
lispy-mark-list
Bound to m.
Mark the current sexp. When the mark is already active, deactivate it instead.
lispy-raise
Bound to r.
Use current sexp or region as replacement for its parent.
(let ((foo 1)) |
-> r -> |
|
lispy-move-down
Bound to s.
Move current sexp or region down arg times. Don't exit the parent list. Also works for outlines.
(progn |
-> s -> |
(progn (bar) |
lispy-move-up
Bound to w.
Move current sexp or region up arg times. Don't exit the parent list. Also works for outlines.
It's the reciprocal of lispy-move-down
.
lispy-teleport
Bound to t.
Move the current sexp or region to a location specified by lispy-ace-paren
.
Press tt to teleport to any sexp in the current window.
lispy-undo
Bound to u.
Forward to undo
. If the mark is active, deactivate it first.
lispy-ace-symbol-replace
lispy-eval-other-window
Bound to p.
Eval the current sexp in the context of the other window. This is useful for debugging interactive Elisp functions:
- in one window keep the code of the function being debugged
- in the other window, keep the buffer on which the debugged function is supposed to work
Special behavior in let
(what gets evaled is on the right):
(let ( |
-> p -> |
(setq foo 10) |
Special behavior in cond
(what gets evaled is on the right):
(cond |
-> p -> |
(if (foo-1) (progn (bar-1)) (message "cond: nil")) |
Similar special behavior for pcase
.
Special behavior in mapcar, =mapc
, dolist
: cycle the loop variable through the list:
(mapcar( lambda (x) (* x x)) '(1 2 3))
x
will have value 1
after the first p, value 2
after the second p etc.
lispy-describe
Bound to xh.
A shorthand for describe-function
or describe-variable
.
If you want to call describe-variable
, you should mark the symbol
first. You can do this quickly with:
From special:
- 2m, 3m, etc. if you want the second or third element of the list accordingly
- a to select the symbol with
lispy-ace-symbol
Globally:
- M-m to mark symbol at point with
lispy-mark-symbol
lispy-beginning-of-defun
Bound to A.
Forward to beginning-of-defun
. When called twice in a row, restore
the previous point and mark positions.
A useful combo while debugging is Aa to select symbol, and eA to look at its value and go back. Repeat when needed.
lispy-convolute
Bound to C.
Exchange the order of application of two closest outer forms, relative to current expression or region.
(if (= (weight person) standard-duck-weight) (unless (sinks-in-water person) |
-> C -> |
(unless (sinks-in-water person) (if (= (weight person) standard-duck-weight) |
This operation reverses itself. See gif.
lispy-ace-char
Bound to Q.
Call ace-jump-mode
, while narrowed to current list.
lispy-raise-some
Bound to R.
Use current sexp and the following (if called from the left), or the preceeding (if called from the right) sexps, or the active region as replacement for their parent.
Example 1:
(progn (message "one") |
-> R -> |
|
Example 2:
(progn (message "one") (message "two") |
-> R -> |
progn (message "one") (message "two") |
lispy-ert
lispy-stringify
Bound to S.
Transform current sexp into a string. Quote newlines if arg
isn't 1.
(progn (message "one") |
-> S -> |
(progn (message "one") "(message \"two\")" |
lispy-paste
Bound to P.
When region is active, replace it with current kill.
Forward to yank
otherwise.
lispy-edebug
Bound to xe.
edebug
current defun.
Or cider-debug-defun-at-point
for Clojure.
2xe will eval current defun instead.
lispy-debug-step-in
Bound to xj. Works for Elisp and Clojure (commit:dfcd4b9).
- Evaluate the arguments at the current function's call
- Jump to the function's definition
- Set the result of evaluation to the function's arguments
For example, starting with:
( do-stuff 1 (+ 1 1) (+ 2 2))
after pressing xj you will jump to the definition of do-stuff
:
( defun do-stuff (x y z &optional a &rest b) (foo) (bar))
At this point the following global variables will be set to their corresponding values:
var | val |
---|---|
x | 1 |
y | 2 |
z | 4 |
a | nil |
b | nil |
lispy-kill-word
Bound to M-d.
Kill arg
words, keeping parens and quotes consistent
lispy-backward-kill-word
Bound to M-DEL.
Kill arg
words backward, keeping parens and quotes consistent.
lispy-kill-sentence
Bound to M-k.
Kill until the end of the current list or string.
If located exactly at the beginning of the list or string, kill only that list or string instead.
(message "Then shalt thou count to three |
-> M-k -> |
(message "Then shalt thou count to three |
digit-argument
Bound to 0, 1, 2, 3, 4, 5, 6, 7, 8, 9.
This is the standard Emacs function. Except instead of calling it globally with e.g. M-2, you can call it locally with just e.g. 2.
Many lispy commands take a prefix arg, e.g. 3j is equivalent to jjj.