forked from BnMcGn/lisp-guide
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlisp-exploration.html
348 lines (226 loc) · 6.91 KB
/
lisp-exploration.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
<html>
<head>
<title>REPL Exploration Guide - Common Lisp</title>
<link href='style.css' rel='stylesheet' type='text/css' />
<link href='guide.css' rel='stylesheet' type='text/css' />
</head>
<body>
<div style="float: right">
<a href="https://github.com/BnMcGn/lisp-guide">Source repository</a>
</div>
<h1><a href="http://bnmcgn.github.io/lisp-guide/lisp-exploration.html">
Common Lisp REPL Exploration Guide</a>
</h1>
<p>Emacs/Slime edition</p>
<div class="glossary">
<h2>Glossary</h2>
<h3>symbol</h3>
<p>A name. Like a variable, but can be used without an attached value.</p>
<h3>system</h3>
<p>A library</p>
<h3>package</h3>
<p>A module, more fine-grained than a system. Systems often contain multiple packages.</p>
<h3>(at) point</h3>
<p>Emacs will often apply commands to the item under the cursor. This item is said to be at point.</p>
<h3>M-</h3>
<p>A reference to the <em>meta</em> modifier key. This is usually the Alt key on PCs and the command key on Macs. </p>
<h3>repl</h3>
<p>The interactive prompt of a live lisp session.</p>
<h3>quicklisp, alias ql</h3>
<p>Common Lisp's de facto package manager.</p>
</div>
<h2>Starting and Stopping Lisp</h2>
<h3>Start lisp from within emacs</h3>
<pre><code>M-x slime
</code></pre>
<h3>Stop the lisp repl in emacs</h3>
<pre><code>> ,quit
</code></pre>
<h2>Surroundings</h2>
<h3>List of available functions</h3>
<p>[???]</p>
<h3>Last three items in result history (most recent first)</h3>
<pre><code>> *
> **
> ***
</code></pre>
<h3>Last three items in result history (most recent first) as a list of all values</h3>
<pre><code>> /
> //
> ///
</code></pre>
<h3>Last three items in command history (most recent first)</h3>
<pre><code>> +
> ++
> +++
</code></pre>
<h3>Cycle though command history (previous, next item)</h3>
<pre><code>M-p
M-n
</code></pre>
<h3>Search command history for things that start with <em>search</em></h3>
<pre><code>> <i>search</i> M-p
</code></pre>
<h2>Available Packages & Quicklisp</h2>
<h3>List all loaded packages</h3>
<pre><code>> (list-all-packages)
</code></pre>
<h3>List all packages imported into a package</h3>
<pre><code>> (package-use-list (find-package '<i>package</i>))
</code></pre>
<h3>List of all available systems in the quicklisp repository</h3>
<pre><code>> (ql:system-list)
</code></pre>
<h3>Search the list of systems</h3>
<pre><code>> (ql:system-apropos <i>search</i>)
</code></pre>
<h3>Install and load a system</h3>
<pre><code>> (ql:quickload '<i>system</i>)
</code></pre>
<h3>Contents of a loaded package</h3>
<pre><code>> <i>package</i>:<tab>
</code></pre>
<h3>Contents of a package, including internal symbols</h3>
<pre><code>> <i>package</i>::<tab>
</code></pre>
<h2>Symbols and Objects </h2>
<h3>Is symbol in use?</h3>
<pre><code>> (boundp '<i>var</i>)
</code></pre>
<h3>Is symbol used in the function namespace?</h3>
<pre><code>> (fboundp '<i>var</i>)
</code></pre>
<h3>List all of the symbols in the current namespace</h3>
<pre><code>> (apropos "" *package*)
</code></pre>
<h3>Originating package of a symbol</h3>
<pre><code>> (symbol-package '<i>var</i>)
</code></pre>
<h3>Search for <em>thing</em> in the symbol list (with optional package specifier)</h3>
<pre><code>> (apropos "thing" '<i>package</i>)
</code></pre>
<h3>Docstring</h3>
<pre><code>> (describe <i>var</i>)</code> or <code>C-c C-d d</code> on point</pre>
<h3>Type of an object</h3>
<pre><code>> (type-of <i>var</i>)
</code></pre>
<h3>Inspect item at point</h3>
<pre><code>C-c C-v C-i</code></pre>
<table>
<th>Inspector commands</th>
<tr>
<td><enter></td>
<td>Inspect or act on the item at point</td>
</tr>
<tr>
<td>l</td>
<td>Return from an inspection</td>
</tr>
<tr>
<td><tab> </td>
<td>Jump to next inspectable</td>
</tr>
<tr>
<td>Shift-<tab> </td>
<td>Jump to previous inspectable</td>
</tr>
<tr>
<td>d</td>
<td>Describe</td>
</tr>
<tr>
<td>e</td>
<td>Evaluate an expression</td>
</tr>
<tr>
<td>v</td>
<td>Toggle verbose mode</td>
</tr>
<tr>
<td>q</td>
<td>Quit</td>
</tr>
<tr>
<td>p</td>
<td>Pretty print object at point</td>
</tr>
<tr>
<td>.</td>
<td>Jump to source</td>
</tr>
<tr>
<td>M-<enter></td>
<td>Store value at point in '*' for access in REPL</td>
</tr>
</table>
<h3>Another inspector</h3>
<pre><code>> (inspect <i>var</i>)
</code></pre>
<h3>Inheritance tree for a class</h3>
<pre><code>M-x slime-browse-classes
</code></pre>
<h3>List methods specializing on a class </h3>
<pre><code>M-x slime-who-specializes
</code></pre>
<h2>Paths, locations, config files</h2>
<h3>Lisp executable location</h3>
<pre><code>M-: inferior-lisp-program
</code></pre>
<h3>Version and variety of Common Lisp</h3>
<pre><code>> (lisp-implementation-version)
> (lisp-implementation-type)
</code></pre>
<h3>Operating system and machine info</h3>
<pre><code>> (software-version)
> (machine-version)
</code></pre>
<h3>Show the recommended folder for your projects</h3>
<pre><code>> ql:*local-project-directories*
</code></pre>
<h3>Location of a specific system</h3>
<pre><code>> (ql:where-is-system '<i>system</i>)
</code></pre>
<h3>Name of start up configuration file for your lisp</h3>
<pre><code>> (ql-impl-util::init-file-name-for (lisp-implementation-type))
</code></pre>
<h2>Code navigation</h2>
<h3>Jump to the definition of the item at point</h3>
<pre><code>M-.
</code></pre>
<h3>Return from jump</h3>
<pre><code>M-,
</code></pre>
<h3>List callers of a function</h3>
<pre><code>C-c <
</code></pre>
<h3>List functions that a function calls (callees)</h3>
<pre><code>C-c >
</code></pre>
<h3>Show the references, bindings or assignments of the global variable at point</h3>
<pre><code>C-c C-w r</code> <code>C-c C-w b</code> <code>C-c C-w s</code>
</code></pre>
<h3>Look up documentation for the symbol at point in the Common Lisp Hyperspec</h3>
<pre><code>C-c C-d h
</code></pre>
<p>Note: only for symbols defined in the Common Lisp standard</p>
<h2>Macros</h2>
<h3>Examine a macro expansion</h3>
<p>Given the following loop macro invocation:</p>
<pre><code>(loop for i from 1 to 3 do (print i))</code></pre>
<p>This will show the expansion:</p>
<pre><code>(macroexpand-1 '(loop for i from 1 to 3 do (print i)))</code></pre>
<h3>Explore the currently available reader macros</h3>
<pre><code>> (inspect *readtable*)
</code></pre>
<p>Note: not user friendly</p>
<h2>Crashes and errors</h2>
<h3>Stop a running task</h3>
<pre><code>C-c C-c
</code></pre>
<h3>Getting back to normal from the debugger</h3>
<pre><code>q</code> - or select <code>[Abort]</code>
</code></pre>
<br/>
<footer>Copyright 2016 Ben McGunigle</footer>
</body>
</html>