There are two means of automatic initialization of CLOS slot values, :initform and :default-initargs. Chris Riesbeck makes a strong case for preferring :default-initargs.
Here’s a simplified example of the syntactic difference, taken from some Quicklisp code. Consider modeling version control…
After updating Slime it’s usually needed to restart Emacs so that the changes take effect, but restarting Emacs is quite inconvenient. After adding the following code into .emacs, M-x restart-slime will reload all the Emacs Lisp parts (CL side should be restarted with ,restart short-cut in the…
parse-integer takes :start and :end arguments, so you don’t have to extract integer subsequences from strings to pass them to parse-integer. For example, to parse date strings that look like “2011-10-01” into year, month, and date integers, you can do this:
(defun parse-date (string) "Parse a...
M-x slime-list-threads (you can also access it through slime-selector shortcut t) will list running threads by their names, and their statuses.
The thread on the current line can be killed with k, or if there’s a lot of threads to kill, several lines can be selected and k will kill all the…
Slime has a nice cross referencing facility, for example, you can see what calls a particular function or expands a macro.
It presents a list of places which reference a particular entity, from there you can recompile the thing which references by pressing C-c C-c on that line. C-c C-k will…
M-x slime-format-string-expand: expands the format control string at point.
”~a, ~a.” on SBCL yields
#'(LAMBDA (STREAM &OPTIONAL (#:FORMAT-ARG1502 (ERROR 'SB-FORMAT:FORMAT-ERROR :COMPLAINT "required argument missing" :CONTROL-STRING "~a, ~a." :OFFSET 1)) (#:FORMAT-ARG1503 (ERROR...
To create an empty file, like the Unix touch command does, you might try something like this:
;; BOGUS (close (open "foo.txt" :direction :output :if-does-not-exist :create :if-exists :append))open has a :direction option specifically for this purpose, though:
(open "foo.txt" :direction :probe
The naive way to swap the values of two places, a and b, is something like this:
;; BOGUS (setf temp a) (setf a b) (setf b temp)psetf (parallel setf) can do it in one form:
(psetf a b b a)But rotatef is best:
(rotatef a b)
Slime has many buffers, and sometimes it’s not easy navigating between them, slime-selector simplifies this task.
It’s not bound to any key by default, I bind it globally to C-z(global-set-key "\C-z" 'slime-selector)
Then it allows you to select a buffer by a letter.
Some of the most useful shortcuts are listed here, the full list can be seen by pressing “?”.
- r Current active REPL
- l Most recently visited lisp file
- d Debugger
- c List of implementations slime is connected to
- t Threads list
- i *inferior-lisp* buffer
- s *slime-scratch* buffer (for writing one-off code)
- v Log of slime events (useful for debugging Slime problems)