sjh - mountain biking linux geek spice - mtb / linux / canberra / cycling / etc

Steven Hanley hackergotchi picture Steven
Hanley

About

email: sjh@svana.org

web: http://svana.org/sjh

Other online diaries:

Aaron Broughton,
Alison Russell,
Allan Bontjer,
Andrew Pollock,
Anthony Towns,
Chris Yeoh,
Jeremy Kerr,
Martijn van Oosterhout,
Michael Carden,
Michael Davies,
Michael Still,
Rusty Russell,
Tim Potter,
Tony Breeds,

Links:

Linux Weekly News,
XKCD,
Userfriendly,
Questionable Content,
Planet Linux Australia,
Bilbys,
CORC,

Canberra Weather: forecast, radar.

Subscribe: rss, rss2.0, atom

planet sjh
(online feed aggrgator for all the diaries I read regularly)

October
Mon Tue Wed Thu Fri Sat Sun
5
       

2007
Months
Oct

Categories:

Archive by month:

Fri, 05 Oct 2007

No count-words-region or similar in emacs? - 14:10
I have no idea how I never noticed this before, I was writing something a few minutes ago and wished to know how many words were in a section of it. Plain text in emacs. I tried Meta-X count-<tab> and a few variations and could not find a command that would count the words in a region of text, or a buffer or anywhere else. Strange I thought and decided to search online.

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.

[/comp/software] link


home, email, rss, rss2.0, atom