apropos, apropos-list
apropos, apropos-list Function
Syntax:
apropos string &optional package → ⟨no values⟩
apropos-list string &optional package → symbols
Arguments and Values:
string—a string designator .
package—a package designator or nil. The default is nil.
symbols—a list of symbols.
Description:
These functions search for interned symbols whose names contain the substring string.
For apropos, as each such symbol is found, its name is printed on standard output. In addition, if such a symbol is defined as a function or dynamic variable, information about those definitions might also be printed.
For apropos-list, no output occurs as the search proceeds; instead a list of the matching symbols is returned when the search is complete.
If package is non-nil, only the symbols accessible in that package are searched; otherwise all symbols accessible in any package are searched.
Because a symbol might be available by way of more than one inheritance path, apropos might print information about the same symbol more than once, or apropos-list might return a list containing duplicate symbols.
Whether or not the search is case-sensitive is implementation-defined.
Affected By:
The set of symbols which are currently interned in any packages being searched.
apropos is also affected by *standard-output*.
Expanded Reference: apropos, apropos-list
Finding symbols by substring with apropos
apropos prints information about all symbols whose names contain the given string as a substring. It returns no useful value.
(apropos "MAKE-HASH")
; Prints matching symbols, e.g.:
; MAKE-HASH-TABLE (fbound)
=> ; no useful return value (implementation-dependent)
Getting a list of matching symbols with apropos-list
apropos-list is the functional equivalent -- it returns a list of matching symbols rather than printing them.
(let ((results (apropos-list "MAKE-HASH")))
(not (null (member 'make-hash-table results))))
;; => T
Restricting search to a specific package
Both functions accept an optional package argument to restrict the search.
;; Search only in the COMMON-LISP package
(not (null (member 'make-hash-table
(apropos-list "MAKE-HASH" (find-package "COMMON-LISP")))))
;; => T
Case-insensitive matching
The search is typically case-insensitive (though this is implementation-dependent). Symbol names in Common Lisp are usually uppercase internally.
;; These produce the same results
(= (length (apropos-list "CONS"))
(length (apropos-list "cons")))
;; => impl-dependent