Reputation: 23719
I want to automatically generate an HTML document, containing docs for a Perl file. To build it I need a list functions, contained in the file. Every function has the format '^sub name'. Is there any function to get all function names? Or how to write it?
Upvotes: 1
Views: 285
Reputation: 21152
You can use elisp search functions:
(defun find-perl-sub ()
(let ((subs))
(with-current-buffer "my-perl-file.pl"
(goto-char (point-min))
(while (re-search-forward "^[[:blank:]]*sub[[:blank:]]+\\([a-zA-Z0-9_]+\\)" nil t)
(push (match-string-no-properties 1) subs)))
subs
))
Upvotes: 1
Reputation: 28521
Note that extracting all the function names (together with their location in the buffer) is already done by imenu.
So you may prefer to use that. Just call imenu--make-index-alist
and then look at the result in imenu--index-alist
.
Upvotes: 2