home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / scheme / pcscheme / geneva / sources.exe / SOURCES / EDWIN / WORDS.S < prev   
Encoding:
Text File  |  1993-06-15  |  3.5 KB  |  96 lines

  1. ;;;
  2. ;;;    Copyright (c) 1985 Massachusetts Institute of Technology
  3. ;;;
  4. ;;;    This material was developed by the Scheme project at the
  5. ;;;    Massachusetts Institute of Technology, Department of
  6. ;;;    Electrical Engineering and Computer Science.  Permission to
  7. ;;;    copy this software, to redistribute it, and to use it for any
  8. ;;;    purpose is granted, subject to the following restrictions and
  9. ;;;    understandings.
  10. ;;;
  11. ;;;    1. Any copy made of this software must include this copyright
  12. ;;;    notice in full.
  13. ;;;
  14. ;;;    2. Users of this software agree to make their best efforts (a)
  15. ;;;    to return to the MIT Scheme project any improvements or
  16. ;;;    extensions that they make, so that these may be included in
  17. ;;;    future releases; and (b) to inform MIT of noteworthy uses of
  18. ;;;    this software.
  19. ;;;
  20. ;;;    3.  All materials developed as a consequence of the use of
  21. ;;;    this software shall duly acknowledge such use, in accordance
  22. ;;;    with the usual standards of acknowledging credit in academic
  23. ;;;    research.
  24. ;;;
  25. ;;;    4. MIT has made no warrantee or representation that the
  26. ;;;    operation of this software will be error-free, and MIT is
  27. ;;;    under no obligation to provide any services, by way of
  28. ;;;    maintenance, update, or otherwise.
  29. ;;;
  30. ;;;    5.  In conjunction with products arising from the use of this
  31. ;;;    material, there shall be no use of the name of the
  32. ;;;    Massachusetts Institute of Technology nor of any adaptation
  33. ;;;    thereof in any advertising, promotional, or sales literature
  34. ;;;    without prior written consent from MIT in each case.
  35. ;;;
  36. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  37. ;;;
  38. ;;;     Modified by Texas Instruments Inc 8/15/85
  39. ;;;
  40. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  41.  
  42. ;;;; Words
  43.  
  44. (define (forward-word mark n limit?)
  45.   (cond ((positive? n) (%forward-word mark n limit?))
  46.     ((negative? n) (%backward-word mark (- n) limit?))
  47.     (else mark)))
  48.  
  49. (define (%forward-word mark n limit?)
  50.   (let ((end (group-end mark)))
  51.     (define (loop mark n)
  52.       (let ((m (find-next-word-constituent mark end #F)))
  53.     (if (not m)
  54.         (limit-mark-motion limit? mark)
  55.         (let ((m (find-next-word-delimiter m end 'LIMIT)))
  56.           (if (= n 1)
  57.           m
  58.           (loop m (-1+ n)))))))
  59.     (loop mark n)))
  60.  
  61. (define (backward-word mark n limit?)
  62.   (cond ((positive? n) (%backward-word mark n limit?))
  63.     ((negative? n) (%forward-word mark (- n) limit?))
  64.     (else mark)))
  65.  
  66. (define (%backward-word mark n limit?)
  67.   (let ((end (group-start mark)))
  68.     (define (loop mark n)
  69.       (let ((m (find-previous-word-constituent mark end #F)))
  70.     (if (not m)
  71.         (limit-mark-motion limit? mark)
  72.         (let ((m (find-previous-word-delimiter m end 'LIMIT)))
  73.           (if (= n 1)
  74.           m
  75.           (loop m (-1+ n)))))))
  76.     (loop mark n)))
  77.  
  78. (define (forward-to-word mark limit?)
  79.   (find-next-word-constituent mark (mark-end mark) limit?))
  80.  
  81. (define (find-next-word-constituent start end limit?)
  82.   (or (find-next-char-in-set start end word-constituent-chars)
  83.       (limit-mark-motion limit? end)))
  84.  
  85. (define (find-previous-word-constituent start end limit?)
  86.   (or (find-previous-char-in-set start end word-constituent-chars)
  87.       (limit-mark-motion limit? end)))
  88.  
  89. (define (find-next-word-delimiter start end limit?)
  90.   (or (find-next-char-in-set start end word-delimiter-chars)
  91.       (limit-mark-motion limit? end)))
  92.  
  93. (define (find-previous-word-delimiter start end limit?)
  94.   (or (find-previous-char-in-set start end word-delimiter-chars)
  95.       (limit-mark-motion limit? end)))
  96.