Other online diaries:
Fri, 05 Oct 2007
No count-words-region or similar in emacs? - 14:10
From search engine results I found that somehow emacs does not natively have the few lines of lisp required to do this seemingly simple function anywhere by default. So there are some reasons this may be the case, the first of which is the definition of what constitutes a word may be in question, especially in different modes. However I just want a basic text mode word count capability.
Many online suggestions seemed to launch a sub-shell and run wc on a buffer or section of a buffer, this is obviously overkill. Fortunately one of the first search results is to an elisp intro that has a section detailing a function defined to do count words region, which is exactly what I needed, so it is now in my .emacs file.
The two things I find most surprising with this state of affairs are: 1. emacs does not have the capability somewhere in the huge amount of elisp distributed with it to do this natively and 2. Though I have been using emacs a lot for more than 10 years I never before noticed this was lacking.