(defun my-shell-mode (&optional buffer)
    (interactive)
;   (debug)
    (shell buffer)
;   (local-set-key "	" 'shell-filename-expand)
; Looks like something funky might be happening when a file is
; inserted into a shell buffer -- like it tries to execute the
; whole thing as a shell command.  Not quite sure about this,
; but we'll not take any chances right now till things are
; figured out.
;    (switch-to-buffer "*shell*")
;    (if (file-exists-p "shell")
;      (insert-file "shell"))
;    (end-of-buffer)
;    (set-mark (point))
;    (write-file "shell")

    ; Not sure when this annoying-ass motherfucker showed up as true, but
    ; TURN IT THE FUCK OFF!
    (setq comint-scroll-show-maximum-output nil)

    (process-kill-without-query (get-process "shell"))

    (if (or (string= HOSTNAME "VirtualPC") (string= HOSTNAME "VirtualPCHome")
	    (string= HOSTNAME "WindozePOS") (string= HOSTNAME "vpc"))
	(process-send-string (get-process "shell") "/usr/bin/tcsh\n"))

    (if (and (emacs-version-compare 19 27 '<)
	     (not (string= (substring (emacs-version) 0 1) "X")))
      (my-shell-bindings-old)
      (progn
	(my-shell-bindings)

	(if (not (string= (substring (emacs-version) 0 1) "X"))
	    (setq comint-output-filter-functions
		  (append comint-output-filter-functions
			  (list 'shell-strip-ctrl-m)))
	)
	(if (emacs-version-compare 19 34 '<)
	    (setq comint-process-echoes t)
	)
	(setq comint-prompt-regexp
	      (concat (getenv "HOSTNAME") "-gfisher\\[[0-9]*\\]: "))
      )
    )
    (if (string= (substring (emacs-version) 0 1) "X")
	(setq comint-process-echoes nil)
    )

    ; (set-line-spacing)  ; Turned off for now.  See comments in .emacs.

)

(defun my-shell-bindings ()
    (interactive)
;   (message "in my-shell-bindings")
    (message (concat "buffer name =" (buffer-name)))
    (local-unset-key "n")
    (local-unset-key "p")
    (local-unset-key "")
    (local-unset-key "˜")
    (local-set-key "" 'comint-next-input)
    (local-set-key "" 'comint-previous-input)
    (local-set-key "." 'comint-set-process-mark)
    (local-set-key "" 'my-comint-interrupt-subjob)
    (local-set-key "" 'my-comint-stop-subjob)
)

(defun my-shell-bindings-old ()
    (interactive)
;   (message "in my-shell-bindings")
;   (message (concat "buffer name =" (buffer-name)))
    (load "kshell.el")
    (local-unset-key "n")
    (local-unset-key "p")
    (local-set-key "" 'shell-next-command)
    (local-set-key "" 'shell-previous-command)
    (local-set-key "	" 'shell-filename-expand)
    (local-set-key "" 'shell-beginning-of-line)
;   (setq comint-prompt-regexp "phoenix-gfisher\\[[0-9]*\\]: ")
)

(defun my-shell-mode-file ()
    (interactive)
    (switch-to-buffer "*shell*")
    (insert-file "shell")
    (kill-buffer "shell")
    (write-file "shell")
    (end-of-buffer)
    (shell)
    (set-mark (point))
)

(defun fix-hp-shell-wierdness ()
"For some unknown reason, shell-mode in the version 19.19.1 on the HPs goes
wierd in terms of how it responds to comint-send-input.  I've located the fix,
which is embodied in this function, but have not ascertained exactly what
causes the problem to happen.  The shell always starts out fine, but as some
point, some command causes it to wierd out.  The low-level cause of the
wierdness is that the mode-local marker vars comint-last-input-start and
comint-last-input-end go from markers to nil.  This causes the set-marker
function to say ``Wrong type argument: markerp, nil'', and the output of the
shell command to be stuffed above the command, and the whole thing is just an
ugly pain after that.

The fix is to force the redeclaration of the aformentioned vars back to
markers.  It's not clear what this does to the local status of these, but dont
really care since it seems to work.  Just chalk this whole thing up to the fact
that using a 1993 version of software in 1997 is stupid and we hopefully wont
have to put up with it much longer."

    (interactive)
    (setq comint-last-input-start (make-marker))
    (setq comint-last-input-end (make-marker))
)


;
; 15jul02 -- next two functions need hopefully temporarily until Solaris 9
; issue with subjob control is resolved.
;
(defun my-comint-interrupt-subjob ()
    (interactive)
    (process-send-string nil "")
)

(defun my-comint-stop-subjob ()
    (interactive)
    (process-send-string nil "")
)