Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!elroy.jpl.nasa.gov!usc!rpi!batcomputer!llenroc!cornell!uw-beaver!ubc-cs!alberta!anthony From: anthony@cs.UAlberta.CA (Anthony Mutiso) Newsgroups: comp.emacs Subject: Re: count words region Message-ID: Date: 14 Mar 91 17:07:50 GMT References: Sender: news@cs.UAlberta.CA Organization: Computing Science, U. of Alberta. Edmonton, Alberta. CANADA Lines: 28 In-Reply-To: pjnesser@mbunix.mitre.org's message of 13 Mar 91 21:56:38 GMT X-Zippy: Now my EMOTIONAL RESOURCES are heavily committed to 23% of the SMELTING and REFINING industry of the state of NEVADA!! >>>>> On 13 Mar 91 21:56:38 GMT, pjnesser@mbunix.mitre.org (Nesser) said: > Has anyone written a count-words-region command? I'm sure I'm > not the only one who would find it very useful. Thanks, .. jj Nesser> Try: Nesser> (defun count-words-in-region (min max) "Counts the words in Nesser> the current region, displaying the current count, along with a Nesser> timestamp and the buffer name, in the *Word Count* buffer. If Nesser> called from a program, expects MIN and MAX args as start and Nesser> end buffer addresses." (interactive "r") (let ((real-buffer Nesser> (current-buffer)) (buffer (get-buffer-create "*Word Count*"))) Nesser> (set-buffer real-buffer) (call-process-region min max Nesser> "/usr/ucb/wc" nil buffer nil) (set-buffer real-buffer) Nesser> (princ (buffer-name) buffer) (princ " (region) as of " buffer) Nesser> (princ (current-time-string) buffer) (terpri buffer) Nesser> (pop-to-buffer buffer) (goto-char (point-min)) (pop-to-buffer Nesser> real-buffer))) -- ---> Philip J. Nesser Member of the Nesser> Technical Staff The MITRE Corporation What about M-x count-match \W\w+\W Anthony -- Anthony Mutiso (anthony@cs.ualberta.ca) Life-motto: Logic Rules.