;;; -*- Mode:Lisp; Readtable:ZL; Package:USER; Base:8; Patch-File:T -*-
;;; Patch file for System version 124.102
;;; Reason:
;;;  Print quantities grammatically in all cases for the following Zwei
;;;  commands: Count Occurrences, Count Words, Count Lines, and Count
;;;  Characters.
;;; Written 24-Jun-88 12:36:18 by saz (David M.J. Saslav) at site Gigamos Cambridge
;;; while running on Brahms' First from band 1
;;; with Experimental System 124.90, Experimental Local-File 74.2, Experimental File-Server 23.1, Experimental Unix-Interface 12.0, Experimental ZMail 72.1, Experimental Tape 23.6, Experimental Lambda-Diag 16.2, Tiger 28.0, microcode 1761, SDU Boot Tape 3.14, SDU ROM 103, Beta 3 for in-house.



; From modified file DJ: L.ZWEI; COMS.LISP#92 at 24-Jun-88 12:37:36
#8R ZWEI#: 
(COMPILER-LET ((*PACKAGE* (PKG-FIND-PACKAGE "ZWEI")))
  (COMPILER::PATCH-SOURCE-FILE "SYS: ZWEI; COMS  "


(DEFCOM COM-COUNT-OCCURRENCES "Counts occurrences of a substring, after point." ()
  (MULTIPLE-VALUE-BIND (FUNCTION KEY REVERSE-P BJ-P)
      (GET-EXTENDED-STRING-SEARCH-STRINGS NIL "How many occurrences of:"
					  *STRING-SEARCH-SINGLE-LINE-COMTAB*)
    (DO ((BP (COND ((NOT BJ-P) (POINT))
		   ((NOT REVERSE-P) (INTERVAL-FIRST-BP *INTERVAL*))
		   (T (INTERVAL-LAST-BP *INTERVAL*)))
	     (FUNCALL FUNCTION BP KEY REVERSE-P))
	 (N 0 (1+ N)))
	((NULL BP)
	 (FORMAT *QUERY-IO* "~&There ~:[are~;is~] ~D occurrence~:P.~%" (eql (1- N) 1) (1- N)))))
  DIS-NONE)

))

; From modified file DJ: L.ZWEI; COMS.LISP#92 at 24-Jun-88 12:37:38
#8R ZWEI#: 
(COMPILER-LET ((*PACKAGE* (PKG-FIND-PACKAGE "ZWEI")))
  (COMPILER::PATCH-SOURCE-FILE "SYS: ZWEI; COMS  "


(DEFCOM COM-COUNT-WORDS "Counts the number of words in the region or buffer." (KM)
  (WITH-REGION-OR-WHOLE-INTERVAL (TEM)
    (let ((number-of-words (COUNT-OBJECTS 'FORWARD-WORD *INTERVAL*)))
      (FORMAT *QUERY-IO* "~&There ~:[are~;is~] ~D word~:P in the ~A.~%"
	      (eql number-of-words 1)
	      number-of-words
	      (IF TEM "region" "buffer"))))
  DIS-NONE)

))

; From modified file DJ: L.ZWEI; COMS.LISP#92 at 24-Jun-88 12:37:40
#8R ZWEI#: 
(COMPILER-LET ((*PACKAGE* (PKG-FIND-PACKAGE "ZWEI")))
  (COMPILER::PATCH-SOURCE-FILE "SYS: ZWEI; COMS  "


(DEFCOM COM-COUNT-LINES "Counts the number of lines in the region or buffer." (KM)
  (WITH-REGION-OR-WHOLE-INTERVAL (TEM)
    (let ((number-of-lines (1- (count-lines *interval*))))
      (FORMAT *QUERY-IO* "~&There ~:[are~;is~] ~D line~:P in the ~A.~%"
	      (eql number-of-lines 1)
	      number-of-lines
	      (IF TEM "region" "buffer"))))
  DIS-NONE)

))

; From modified file DJ: L.ZWEI; COMS.LISP#92 at 24-Jun-88 12:37:42
#8R ZWEI#: 
(COMPILER-LET ((*PACKAGE* (PKG-FIND-PACKAGE "ZWEI")))
  (COMPILER::PATCH-SOURCE-FILE "SYS: ZWEI; COMS  "


(DEFCOM COM-COUNT-CHARACTERS "Counts the number of characters in the region or buffer." (KM)
  (WITH-REGION-OR-WHOLE-INTERVAL (TEM)
    (let ((number-of-chars (COUNT-CHARS *INTERVAL*)))
      (FORMAT *QUERY-IO* "~&There ~:[are~;is~] ~D character~:P in the ~A.~%"
	      (eql number-of-chars 1)
	      number-of-chars
	      (IF TEM "region" "buffer"))))
  DIS-NONE)

))
