GNU Info

Info Node: (emacs-lisp-intro.info)Words in a defun

(emacs-lisp-intro.info)Words in a defun


Next: Readying a Graph Prev: Counting Words Up: Top
Enter node , (file) or (file)node

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-word-region'.  Note: Counting Words
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-word-region'.

   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.

Divide and Conquer
Words and Symbols
What to count?
Syntax
What constitutes a word or symbol?
count-words-in-defun
Very like `count-words'.
Several defuns
Counting several defuns in a file.
Find a File
Do you want to look at a file?
lengths-list-file
A list of the lengths of many definitions.
Several files
Counting in definitions in different files.
Several files recursively
Recursively counting in different files.
Prepare the data
Prepare the data for display in a graph.

automatically generated by info2www version 1.2.2.9