[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: elisp - introspection - find all functions matching a certain string
From: |
Tassilo Horn |
Subject: |
Re: elisp - introspection - find all functions matching a certain string |
Date: |
Thu, 06 Sep 2007 09:28:06 +0200 |
User-agent: |
Gnus/5.110007 (No Gnus v0.7) Emacs/23.0.50 (gnu/linux) |
"metaperl.com" <metaperl@gmail.com> writes:
Hi,
>> How can I get a list of all the Emacs Lisp functions currently in
>> memory which start with the string "asciidoc"
>
> It occurred to me to hijack the source of apropos.el, but the function
> which does all the work, apropos-internal, does not appear in the
> source anywhere.
,----[ C-h f apropos-internal RET ]
| apropos-internal is a built-in function in `C source code'.
| (apropos-internal REGEXP &optional PREDICATE)
|
| Show all symbols whose names contain match for REGEXP.
| If optional 2nd arg PREDICATE is non-nil, (funcall PREDICATE SYMBOL) is done
| for each symbol and a symbol is mentioned only if that returns non-nil.
| Return list of symbols found.
`----
As you can see, it's defined in the C source code.
Regarding your original problem, you can also use this function:
--8<---------------cut here---------------start------------->8---
(defun matching-functions (regexp)
(let (commands)
(mapatoms (lambda (a)
(if (and (functionp a)
(string-match regexp (symbol-name a)))
(push (symbol-name a)
commands))))
(sort commands 'string-lessp)))
--8<---------------cut here---------------end--------------->8---
Bye,
Tassilo
--
If programmers deserve to be rewarded for creating innovative programs,
by the same token they deserve to be punished if they restrict the use
of these programs. (Richard M. Stallman)