From: Chris Hanson Date: Fri, 25 Feb 2000 19:02:42 +0000 (+0000) Subject: Implement COUNT-WORDS-REGION. X-Git-Tag: 20090517-FFI~4233 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=5ae26036e23133eff548269861ea7a71c22cab59;p=mit-scheme.git Implement COUNT-WORDS-REGION. --- diff --git a/v7/src/edwin/texcom.scm b/v7/src/edwin/texcom.scm index 221dc52cd..ffcd65114 100644 --- a/v7/src/edwin/texcom.scm +++ b/v7/src/edwin/texcom.scm @@ -1,6 +1,6 @@ ;;; -*-Scheme-*- ;;; -;;; $Id: texcom.scm,v 1.40 2000/02/25 17:46:45 cph Exp $ +;;; $Id: texcom.scm,v 1.41 2000/02/25 19:02:42 cph Exp $ ;;; ;;; Copyright (c) 1986, 1989-2000 Massachusetts Institute of Technology ;;; @@ -110,6 +110,18 @@ With a zero argument, it transposes the words at point and mark." "p" (lambda (argument) (transpose-things forward-word argument))) + +(define (count-words-region region) + (let ((end (region-end region))) + (let loop ((start (region-start region)) (count 0)) + (let ((start (forward-to-word start 'LIMIT))) + (if (mark< start end) + (let ((count (+ count 1)) + (m (forward-word start 1 #f))) + (if m + (loop m count) + count)) + count))))) ;;;; Case Conversion