Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!apple!agate!linus!linus!mbunix!pjnesser From: pjnesser@mbunix.mitre.org (Nesser) Newsgroups: comp.emacs Subject: Re: count words region Message-ID: Date: 14 Mar 91 00:56:38 GMT References: Sender: news@linus.mitre.org (News Service) Organization: The Mitre Corp., Bedford, MA. Lines: 42 In-Reply-To: jj@medulla.cis.ohio-state.edu's message of 13 Mar 91 19:45:56 GMT Nntp-Posting-Host: mbunix.mitre.org Path: linus!linus!think.com!spool.mu.edu!uunet!tut.cis.ohio-state.edu!medulla.cis.ohio-state.edu!jj From: jj@medulla.cis.ohio-state.edu (John Josephson) Newsgroups: comp.emacs Date: 13 Mar 91 19:45:56 GMT Article-I.D.: medulla.JJ.91Mar13144556 Sender: news@tut.cis.ohio-state.edu Organization: Ohio State Computer Science Lines: 2 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 Try: (defun count-words-in-region (min max) "Counts the words in the current region, displaying the current count, along with a timestamp and the buffer name, in the *Word Count* buffer. If called from a program, expects MIN and MAX args as start and end buffer addresses." (interactive "r") (let ((real-buffer (current-buffer)) (buffer (get-buffer-create "*Word Count*"))) (set-buffer real-buffer) (call-process-region min max "/usr/ucb/wc" nil buffer nil) (set-buffer real-buffer) (princ (buffer-name) buffer) (princ " (region) as of " buffer) (princ (current-time-string) buffer) (terpri buffer) (pop-to-buffer buffer) (goto-char (point-min)) (pop-to-buffer real-buffer))) -- ---> Philip J. Nesser Member of the Technical Staff The MITRE Corporation ARPA: pjnesser@mbunix.mitre.org UUCP: ...!mit-eddie!pjnesser