Skip to content

Commit d5bf1e2

Browse files
committed
CL: lisp-call-defun C-c C-y, at last!! o/
1 parent 02627aa commit d5bf1e2

3 files changed

Lines changed: 45 additions & 0 deletions

File tree

content/en/usage/common_lisp.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,51 @@ To compile and load a buffer, use `C-c C-k`. To compile a function: `C-c C-c`.
105105

106106
Common Lisp gives you type warnings and other errors at compile time.
107107

108+
## Call the form at point: `lisp-call-defun C-c C-y`
109+
110+
Lem implements a very efficient keyboard shortcut that allows to
111+
*prefill* a call to the toplevel form at point into the REPL:
112+
`Alt-x lisp-call-defun`, bound to `C-c C-y`.
113+
114+
When you are working on such a function:
115+
116+
```lisp
117+
(in-package :my-project)
118+
119+
(defun hello ()
120+
(print "test"))
121+
```
122+
123+
place the cursor inside the function or at its closing parenthesis,
124+
press `C-c C-y` and Lem will insert "(hello|)" at the REPL:
125+
126+
```lisp
127+
CL-USER> (my-project::hello|)
128+
^^^ cursor, ready to accept arguments.
129+
```
130+
131+
When you work on a class, Lem will insert a call to `make-instance`:
132+
133+
```lisp
134+
(defclass person ()
135+
())
136+
```
137+
138+
`C-c C-y` =>
139+
140+
```lisp
141+
CL-USER> (make-instance 'cl-user::person)
142+
```
143+
144+
The recognized forms to "insert the right thing" are: `defun`,
145+
`defun-setf`, `defstruct`, `defclass` and, implicitely, `defgeneric`
146+
and `defmethod`.
147+
148+
<a href="/lisp-call-defun-on-defun.png"> <img class="" src="/lisp-call-defun-on-defun.png" alt="Alt-x lisp-call-defun prefills a call to the toplevel form on the REPL."> </a>
149+
150+
<a href="/lisp-call-defun-on-defclass.png"> <img class="" src="/lisp-call-defun-on-defclass.png" alt="Alt-x lisp-call-defun prefills a call to the toplevel form on the REPL."> </a>
151+
152+
108153
## Evaluation
109154

110155
To evaluate the last s-expression, use `C-x C-e`. Lem prints the result in an overlay.
26.3 KB
Loading
26.1 KB
Loading

0 commit comments

Comments
 (0)