From xemacs-m  Tue Mar 11 13:38:46 1997
Received: from mail.cis.ohio-state.edu (mail.cis.ohio-state.edu [164.107.8.55])
	by xemacs.org (8.8.5/8.8.5) with SMTP id NAA15731
	for <xemacs-beta@xemacs.org>; Tue, 11 Mar 1997 13:38:44 -0600 (CST)
Received: from calico.cis.ohio-state.edu (calico.cis.ohio-state.edu [164.107.142.11]) by mail.cis.ohio-state.edu (8.6.7/8.6.4) with ESMTP id OAA10113; Tue, 11 Mar 1997 14:38:36 -0500
Received: (ware@localhost) by calico.cis.ohio-state.edu (8.8.0/8.6.4) id OAA01966; Tue, 11 Mar 1997 14:38:36 -0500 (EST)
To: xemacs-beta@xemacs.org
Subject: patch to comint so user input is highlighted.
From: Pete Ware <ware@cis.ohio-state.edu>
Date: 11 Mar 1997 14:38:34 -0500
Message-ID: <vwmwwre1ao5.fsf@calico.cis.ohio-state.edu>
Lines: 100
X-Mailer: Gnus v5.4.17/XEmacs 19.15

The following patch makes comint display user input in blue (or other
highlight means).  This works for shell-mode.  I've been playing with
telnet-mode but it needs more work.  I haven't tried any of the other
comint derived modes (theoretically, they'd work).

- Defines a new custom face: comint-input-face
- Adds functions comint-input-done, comint-input-setup.
- Defines a buffer local variable comint-input-extent to keep track of current
  user input.  This would be a good area for more customization as it
  might be a nice spot for mousing.

--pete

/usr/contrib/bin/diff -u comint.el.orig comint.el
--- comint.el.orig	Wed Mar  5 13:09:35 1997
+++ comint.el	Tue Mar 11 14:27:38 1997
@@ -355,6 +355,23 @@
 (put 'comint-scroll-show-maximum-output 'permanent-local t)
 (put 'comint-ptyp 'permanent-local t)
 
+(defface comint-input-face '((((class color)
+			      (background dark))
+			     (:foreground "red"))
+			    (((class color)
+			      (background light))
+			     (:foreground "blue"))
+			    (((class mono))
+			     (:bold t))
+			    (((class grayscale))
+			     (:bold t))
+			    (t 
+			     (:bold t)))
+  "How to display user input for comint shells."
+  :group 'comint-input-face)
+
+
+
 (defun comint-mode ()
   "Major mode for interacting with an inferior interpreter.
 Interpreter name is same as buffer name, sans the asterisks.
@@ -1346,7 +1363,9 @@
 	  (set-marker comint-last-input-start pmark)
 	  (set-marker comint-last-input-end (point))
 	  (set-marker (process-mark proc) (point))
+	  (comint-input-done)
 	  (funcall comint-input-sender proc input)
+	  (comint-input-setup)
 	  ;; XEmacs - A kludge to prevent the delay between insert and
 	  ;; process output affecting the display.  A case for a
 	  ;; comint-send-input-hook?
@@ -1354,6 +1373,27 @@
 			      (concat input "\n"))
 	  (comint-output-filter proc "")
 	  )))))
+(defun comint-input-done ()
+  "Finalized comint-input-extent so nothing more is added."
+  (if (not comint-input-extent)
+      (comint-input-setup))
+  (set-extent-property comint-input-extent 'start-closed nil)
+  (set-extent-property comint-input-extent 'end-closed nil)
+  (set-extent-property comint-input-extent 'detachable t)
+  )
+
+(defun comint-input-setup ()
+  "Insure the comint-input-extent is ready."
+  (setq comint-input-extent (make-extent (point) (point-max)))
+  (set-extent-property comint-input-extent 'detachable nil)
+  (set-extent-property comint-input-extent 'start-closed t)
+  (set-extent-property comint-input-extent 'end-closed t)
+  (set-extent-face comint-input-extent 'comint-input-face)
+  )
+
+(defvar comint-input-extent nil
+  "Current extent used for displaying text in buffer.");
+(make-variable-buffer-local 'comint-input-extent)
 
 ;; The purpose of using this filter for comint processes
 ;; is to keep comint-last-input-end from moving forward
@@ -1369,6 +1409,9 @@
 		opoint (point)
 		obeg (point-min)
 		oend (point-max))
+	  ;; Keep stuff being output (before input) from using input-extent
+	  (if comint-input-extent
+	      (set-extent-property comint-input-extent 'start-closed nil))
 	  (let ((buffer-read-only nil)
 		(nchars (length string))
 		(ostart nil))
@@ -1393,6 +1436,11 @@
 	    (set-marker comint-last-output-start ostart)
 	    (set-marker (process-mark process) (point))
 	    (redraw-modeline))
+	  ;; Now insure everything inserted after (user input) is in extent
+	  (if (not comint-input-extent)
+	      (comint-input-setup))
+	  (set-extent-endpoints comint-input-extent (point) (point-max))
+	  (set-extent-property comint-input-extent 'start-closed t)
 
 	  (narrow-to-region obeg oend)
 	  (goto-char opoint)

