Next: Introduction, Previous: (dir), Up: (dir) [Contents][Index]
This is the repl-utilities Reference Manual, generated automatically by Declt version 3.0 "Montgomery Scott" on Tue Dec 22 14:53:59 2020 GMT+0.
• Introduction | What repl-utilities is all about | |
• Systems | The systems documentation | |
• Files | The files documentation | |
• Packages | The packages documentation | |
• Definitions | The symbols documentation | |
• Indexes | Concepts, functions, variables and data types |
A set of utilities which ease life at the repl.
REPL-UTILITIES is tested on SBCL, CCL and CLISP, and further porting should be easy.
REPL-UTILITIES includes three sorts of features: introspective procedures, miscellaneous utility functions, and, pulling them together, methods to conveniently keep these symbols and optionally additional symbols available in whichever package you switch to.
For best effect load this package and use-package it from your lisp's init file.
If you wish to in-package another package at the repl in the course of developing it, you can retain access to these REPL-UTILITIES by using DEV to load and swap to the new package. DEV will import the REPL-UTILITIES symbols into the new package, if they won't cause name conflicts.
DEV also maps funcall over *DEV-HOOKS* after changing the package. *DEV-HOOKS* is an empty list. I personally add hooks which import (via REPL-UTILITIES:SHADOWED-IMPORT) several functions from other packages which I always want available at the REPL, and to change the *DEFAULT-PATHNAME-DEFAULTS* and emacs default-directory to match the source location of the package just loaded.
My favorite operator in here is DEFLEX, taken from Rob Warnock and aliased to LEX. It defines a global lexical variable -- this lets you use temporary test variables without earmuffs safely:
(defvar *x* (list 1 2 3))
(mapcar #'print *x*) ; painful
(lex x (list 1 2 3))
(mapcar #'print x) ; better
Following the lead of CL:IN-PACKAGE, the package changing, loading, and renaming operators (BRING, DEV, and NIC) expand into an EVAL-WHEN so that they can take effect before later forms are read.
The symbol and package introspection operators have been defined as macros to allow their arguments to be unquoted symbols. For convenience they automatically unquote quoted arguments.
The following is lightly edited output of
(repl-utilities:summary repl-utilities)
README: Print the documentation on the exported symbols of a package.
SUMMARY: Print the exported symbols along with the first line of their docstrings.
PACKAGE-APROPOS: Print all package names and nicknames which contain the given string.
DOC: Print any documentation for the symbol.
DEPENDENCY-LOCATIONS: Print the pathname of the system and of the systems needed to load it.
EXFNS: Print the external fboundp symbols of a package.
EXVS: Print the external globally special symbols of a package.
EXCS: Print the external symbols for which find-class is truthy.
EXTS: Print the external symbols which are type specifiers.
EXS: Print the external symbols of package.
NIC: Add an additional nickname to package.
ARGLIST: Return the arglist for the given function name.
DE: Shortening of describe. A Rob Warnock function.
TRACE-PACKAGE: Trace all of the symbols in *package*.
DEFLEX: Define a top level (global) lexical VAR with initial value VAL,
LEX: Shortening of deflex: define a global lexical variable.
PRINT-HASH: Print the hash table as: Key, Value~%
MAC: Bind *gensym-counter* to 0, Macroexpand-1 the form, pprint result.
DBGV: Print WHERE, execute FORMS, and print each form and its result to the STREAM.
RIG: Execute body with profiling and timing.
REPEATABLY: Use the same random state seed for every execution.
DEV: Load package and IN-PACKAGE it. SHADOWED-IMPORT REPL-UTILITIES exported symbols.
*DEV-HOOKS*: List of functions to be funcalled after a package is loaded with DEV.
BRING: Load package and import its exported symbols.
*BRING-HOOKS*: List of functions to be funcalled after a package is loaded with BRING.
SHADOWED-IMPORT: Import each symbol into PACKAGE, unless a symbol of the same name is present.
To view full docstrings and argument lists type:
(repl-utilities:readme repl-utilities)
in your repl, or view the api reference on quickdocs.
One of my primary motivations for introducting *dev-hooks* was to automate importing symbols that I always want available at the repl. For example, if you want to keep my much-todo library at hand, you can (from a context where it is already loaded) do the following:
(defun todo-imports ()
(repl-utilities:shadowed-import
(loop for s being the external-symbols of :much-todo
collect s)))
(pushnew 'todo-imports *dev-hooks*)
The use of 'todo-imports instead of #'todo-imports is significant for appropriate behavior when todo-imports is redefined.
This illustrates a reason I prefer importing to binding personal functions to keywords even though importing leaves the possibility of symbol conflicts: it encourages me to write code in a form that is suitable for sharing as an ASDF system.
One hook I am quite fond of tries to sync the *default-pathname-defaults* and emacs default-directory with the package I am switching into.
(defun d-p-d-package (&optional (package *package*))
"If the package's name is a homonym for an asdf system, change the *d-p-d* to its
location on disk and, if (setq slime-enable-evaluate-in-emacs t)
in emacs, set the slime repl's pathname default as well."
;; slime-enable-evaluate-in-emacs warns that it can be a security risk
(let ((pathloc (ignore-errors (funcall (find-symbol "COMPONENT-PATHNAME" "ASDF")
(funcall (find-symbol "FIND-SYSTEM" "ASDF")
(intern (package-name package)
:keyword))))))
(cond (pathloc
(setq *default-pathname-defaults* pathloc)
(when (find-package "SWANK")
(funcall (find-symbol "EVAL-IN-EMACS" "SWANK")
`(with-current-buffer (slime-output-buffer)
(setq default-directory
,(namestring *default-pathname-defaults*)))
:nowait)))
(t (format t "~& Couldn't find a source location for ~A~%"
package)))))
(pushnew 'd-p-d-package *dev-hooks*)
The most straightforward way to use REPL-UTILITIES, assuming you are using quicklisp, is to place the following in your lisp's init file after the quicklisp loading forms.
(funcall (find-symbol (symbol-name '#:quickload) (symbol-name '#:ql))
'#:repl-utilities)
(use-package '#:repl-utilities)
Or, in a running image, you can simply QL:QUICKLOAD it.
To load REPL-UTILITIES in an image without ASDF (an atypical use case), you can load it with the following:
(load "/path/to/repl-utilities/load")
(use-package '#:repl-utilities)
The REPL-UTILITIES features relating to systems wrap ASDF and QUICKLISP functionality. When ASDF is unavailable they print a message indicating the limitation.
Next: Files, Previous: Introduction, Up: Top [Contents][Index]
The main system appears first, followed by any subsystem dependency.
• The repl-utilities system |
Matt Niemeir <matt.niemeir@gmail.com>
BSD 2-clause
Ease common tasks at the REPL.
repl-utilities.asd (file)
Files are sorted by type and then listed depth-first from the systems components trees.
• Lisp files |
• The repl-utilities.asd file | ||
• The repl-utilities/package.lisp file | ||
• The repl-utilities/utils.lisp file | ||
• The repl-utilities/repl-utilities.lisp file |
Next: The repl-utilities/package․lisp file, Previous: Lisp files, Up: Lisp files [Contents][Index]
repl-utilities.asd
repl-utilities (system)
Next: The repl-utilities/utils․lisp file, Previous: The repl-utilities․asd file, Up: Lisp files [Contents][Index]
repl-utilities (system)
package.lisp
Next: The repl-utilities/repl-utilities․lisp file, Previous: The repl-utilities/package․lisp file, Up: Lisp files [Contents][Index]
package.lisp (file)
repl-utilities (system)
utils.lisp
Previous: The repl-utilities/utils․lisp file, Up: Lisp files [Contents][Index]
utils.lisp (file)
repl-utilities (system)
repl-utilities.lisp
Next: Definitions, Previous: Files, Up: Top [Contents][Index]
Packages are listed by definition order.
• The repl-utilities package |
package.lisp (file)
common-lisp
Definitions are sorted by export status, category, package, and then by lexicographic order.
• Exported definitions | ||
• Internal definitions |
Next: Internal definitions, Previous: Definitions, Up: Definitions [Contents][Index]
• Exported special variables | ||
• Exported macros | ||
• Exported functions |
Next: Exported macros, Previous: Exported definitions, Up: Exported definitions [Contents][Index]
List of functions to be funcalled after a package is loaded with BRING.
The functions are called with the package imported by bring as their only argument.
repl-utilities.lisp (file)
List of functions to be funcalled after a package is loaded with DEV.
During execution of these functions *PACKAGE* is already set to the package being loaded, and the repl-utilities symbols which will be imported already are. The functions are called with no arguments.
repl-utilities.lisp (file)
Next: Exported functions, Previous: Exported special variables, Up: Exported definitions [Contents][Index]
Attempt to ql:quickload or asdf:load-system a system with the same name as
package. Regardless of whether the load was successful import the package’s
exported symbols into the current package. If shadowing-import is nil, only
the symbols which won’t cause a symbol conflict are imported.
After importing the package funcall each element of *bring-hooks* with the
designated package as its argument.
Expands to an EVAL-WHEN :compile-toplevel :load-toplevel :execute
repl-utilities.lisp (file)
Print WHERE, execute FORMS, and print each form and its result to the STREAM.
repl-utilities.lisp (file)
Define a top level (global) lexical VAR with initial value VAL, which is assigned unconditionally as with DEFPARAMETER. If a DOC string is provided, it is attached to both the name |VAR| and the name *STORAGE-FOR-DEFLEX-VAR-|VAR|* as a documentation string of kind ’VARIABLE. The new VAR will have lexical scope and thus may be shadowed by LET bindings without affecting its dynamic (global) value.
repl-utilities.lisp (file)
Attempt to ql:quickload or asfd:load-system a system with the same name as
package, then swap to the package regardless of whether the load was
successful. Import repl-utilities exported symbols that don’t cause symbol
conflicts into the newly swapped to package.
Mnemonic for develop.
After swapping to the package map funcall over *dev-hooks*.
Expands to an EVAL-WHEN :compile-toplevel :load-toplevel :execute
repl-utilities.lisp (file)
Print any documentation for the symbol.
Includes variable, function, type, compiler macro, method
combination, and setf documentation.
repl-utilities.lisp (file)
Print the external symbols for which find-class is truthy.
repl-utilities.lisp (file)
Print the external fboundp symbols of a package.
repl-utilities.lisp (file)
Print the external symbols of package.
repl-utilities.lisp (file)
Print the external symbols which are type specifiers.
repl-utilities.lisp (file)
Print the external globally special symbols of a package.
repl-utilities.lisp (file)
Shortening of deflex: define a global lexical variable.
repl-utilities.lisp (file)
Bind *gensym-counter* to 0, Macroexpand-1 the form, pprint result.
If expression starts with a quotation, unquotes it first.
repl-utilities.lisp (file)
Add an additional nickname to package.
Expands to an EVAL-WHEN :compile-toplevel :load-toplevel :execute
repl-utilities.lisp (file)
Print all package names and nicknames which contain the given string.
repl-utilities.lisp (file)
Print the documentation on the exported symbols of a package.
repl-utilities.lisp (file)
Use the same random state seed for every execution.
Random state seed is changed when call-repeatably is reloaded.
repl-utilities.lisp (file)
Execute body with profiling and timing.
Arrange for profiling information to print before IO or timing data.
Profiling is only available in SBCL and with SB-SPROF available. RIG
attempts to load SB-SPROF.
repl-utilities.lisp (file)
Print the exported symbols along with the first line of their docstrings.
repl-utilities.lisp (file)
Trace all of the symbols in *package*.
This won’t attempt to trace any symbols in :cl
repl-utilities.lisp (file)
Previous: Exported macros, Up: Exported definitions [Contents][Index]
Return the arglist for the given function name. Implementations taken from slime.
utils.lisp (file)
Shortening of describe. A Rob Warnock function.
repl-utilities.lisp (file)
Print the pathname of the system and of the systems needed to load it.
repl-utilities.lisp (file)
Print the hash table as: Key, Value~%
repl-utilities.lisp (file)
Import each symbol into PACKAGE, unless a symbol of the same name is present. If print-when-shadowed-p is true, print a message for each not-imported symbol indicating that it was not imported.
utils.lisp (file)
Previous: Exported definitions, Up: Definitions [Contents][Index]
• Internal special variables | ||
• Internal macros | ||
• Internal functions | ||
• Internal generic functions | ||
• Internal conditions |
Next: Internal macros, Previous: Internal definitions, Up: Internal definitions [Contents][Index]
Types that might work with (documentation obj type)
utils.lisp (file)
A readtable where [ql quickload] reads as
‘(find-symbol ,(symbol-name ’quickload) ,(symbol-name ’ql))
utils.lisp (file)
Next: Internal functions, Previous: Internal special variables, Up: Internal definitions [Contents][Index]
repl-utilities.lisp (file)
Return the first form; useful when you want one of multiple possible conditionally read forms.
utils.lisp (file)
utils.lisp (file)
Next: Internal generic functions, Previous: Internal macros, Up: Internal definitions [Contents][Index]
repl-utilities.lisp (file)
repl-utilities.lisp (file)
repl-utilities.lisp (file)
repl-utilities.lisp (file)
If form is quoted, remove one level of quoting. Otherwise return form. This is a useful for defining convenience for macros which may be passed a quoted or unquoted symbol.
utils.lisp (file)
utils.lisp (file)
utils.lisp (file)
repl-utilities.lisp (file)
utils.lisp (file)
repl-utilities.lisp (file)
repl-utilities.lisp (file)
utils.lisp (file)
utils.lisp (file)
utils.lisp (file)
utils.lisp (file)
utils.lisp (file)
repl-utilities.lisp (file)
repl-utilities.lisp (file)
utils.lisp (file)
Next: Internal conditions, Previous: Internal functions, Up: Internal definitions [Contents][Index]
utils.lisp (file)
Previous: Internal generic functions, Up: Internal definitions [Contents][Index]
utils.lisp (file)
condition (condition)
Previous: Definitions, Up: Top [Contents][Index]
• Concept index | ||
• Function index | ||
• Variable index | ||
• Data type index |
Next: Function index, Previous: Indexes, Up: Indexes [Contents][Index]
Jump to: | F L R |
---|
Jump to: | F L R |
---|
Next: Variable index, Previous: Concept index, Up: Indexes [Contents][Index]
Jump to: | A B C D E F G L M N P R S T W |
---|
Jump to: | A B C D E F G L M N P R S T W |
---|
Next: Data type index, Previous: Function index, Up: Indexes [Contents][Index]
Jump to: | *
S |
---|
Jump to: | *
S |
---|
Previous: Variable index, Up: Indexes [Contents][Index]
Jump to: | C P R S U |
---|
Jump to: | C P R S U |
---|