(setq make-backup-files nil)

(defun doit-1 ()
  (interactive "*")
  (setq case-fold-search nil)
  (goto-char (point-min))
  (while (search-forward "Procedure: " nil t)
    (kill-word -1)
    (end-of-line)
    (insert-string " (procedure)")
    )
  (goto-char (point-min))
  (while (search-forward "Process: " nil t)
    (kill-word -1)
    (end-of-line)
    (insert-string " (process)")
    )
  (goto-char (point-min))
  (while (search-forward "Module: " nil t)
    (kill-word -1)
    (if (not (equal "\"" (buffer-substring (1- (point)) (point))))
	(kill-word -1))
    (end-of-line)
    (insert-string " (module)")
    )
  )

(defun doit-2 ()
  (interactive "*")
  (make-local-variable 'cp)
  (goto-char (point-min))
  (while (search-forward "\\\\*(pT" nil t)
    (get-cp 'cp)
    (delete-char 6)
    (insert-string cp)
    )
  )

(defun doit-3 ()
  (interactive "*")
  (make-local-variable 'name)
  (make-local-variable 'eol)
  (make-local-variable 'cp)
  (make-local-variable 'type1)
  (make-local-variable 'type2)
  (goto-char (point-min))
  (while (search-forward "\t" nil t)
    (setq name (buffer-substring
		(1- (point))
		(progn (search-forward " ") (point))
		))
    (end-of-line 2)
    (setq eol (point))
    (beginning-of-line)
    (if (search-forward name eol t)
	(progn
	  (beginning-of-line 0)
	  (if (search-forward "()" eol t)
	      (progn
		(get-cp 'cp)
		(beginning-of-line)
		(kill-line 1)
		(insert-string "*\t" cp)
		)
	    (progn
	      (get-type 'type1)
	      (beginning-of-line 2)
	      (get-type 'type2)
	      (if (equal type1 type2)
		  (progn (beginning-of-line 0)
			 (kill-line 1)
			 (insert-string "*\t"))
		(if (equal name "\tPSDrelease ")
		    (progn
		      (beginning-of-line 0)
		      (insert-string "\t"))
		  (error "%s: types \"%s\" and \"%s\" mismatched" name type1 type2))
		)
	      )
	    )
	  )
      (progn
	(beginning-of-line 0)
	(insert-string "\t")
	)
      )
    (beginning-of-line 2)
    )
  )

(defun upcase-cp-names ()
  "Convert the first word on each line to all upper case characters."
  (interactive "*")
  (goto-char (point-min))
  (while (< (point) (point-max))
    (upcase-word 1)
    (beginning-of-line 2)
    )
  )

(defun get-cp (arg)
  (interactive "v")
  (set arg (buffer-substring
	     (progn (beginning-of-line) (point))
	     (progn (search-forward "\t") (1- (point)))
	     ))
  )

(defun get-type (arg)
  (interactive "v")
  (set arg (buffer-substring
	     (progn (beginning-of-line) (search-forward "(") (point))
	     (progn (search-forward ")") (1- (point)))
	     ))
  )
