eintr: Words in a defun
14 Counting Words in a ‘defun’
******************************
Our next project is to count the number of words in a function
definition. Clearly, this can be done using some variant of
‘count-words-example’. Counting via Repetition and Regexps
Counting Words. If we are just going to count the words in one
definition, it is easy enough to mark the definition with the ‘C-M-h’
(‘mark-defun’) command, and then call ‘count-words-example’.
However, I am more ambitious: I want to count the words and symbols
in every definition in the Emacs sources and then print a graph that
shows how many functions there are of each length: how many contain 40
to 49 words or symbols, how many contain 50 to 59 words or symbols, and
so on. I have often been curious how long a typical function is, and
this will tell.
Menu