-;;* 
-;;  COPYRIGHT (C) PLANISWARE 2016-05-27
+;; -*- coding: windows-1252 -*- 
+;;  COPYRIGHT (C) PLANISWARE 2016
 ;;
 ;;  All Rights Reserved
 ;;

;;  employees for the sole purpose of conducting PLANISWARE business.
;;
;;**************************************************************************
(defun connect-is(host port)
  (interactive "sHost: \nnPort: ")
  (telnet host port)

	  ;;write data to a temp file and start emacs lisp interface
	  (insert data)
	  (write-region (point-min) (point-max) file)
	  (message "Starting interface ~a" file)
	  (fi:start-interface-via-file host "*common-lisp*" file))
	(with-current-buffer "*common-lisp*"
	    (setq-local *inside-connect-is* t))	    
	(delete-file file)	
	(kill-buffer buf)))))

(defun fi:subprocess-send-input ()
  "Send input to the subprocess.  At end of buffer, send all text after
last output as input to the subshell, including a newline inserted at the
end.  When not at end, copy current line to the end of the buffer and
send it,after first attempting to discard any prompt at the beginning of
the line by matching the regexp that is the value of
the buffer-local fi::prompt-pattern, which is initialized by each
subprocess mode."
  (interactive)
  (if fi::shell-completions-window (fi::shell-completion-cleanup))
  (end-of-line)
  (if (eobp)
      (progn
	(setq fi::last-input-start
	  (marker-position
	   (process-mark (get-buffer-process (current-buffer)))))
	(if (and (on-ms-windows) (not *on-windows-nt*))
	    (insert "\n\r")
	  (insert "\n"))
	(setq fi::last-input-end
	  (if (and (on-ms-windows) (not *on-windows-nt*))
	      (1- (point))
	    (point))))
    (let ((max (point)))
      (beginning-of-line)
      (re-search-forward fi::prompt-pattern max t))
    (let ((copy (buffer-substring (point)
				  (progn (forward-line 1) (point)))))
      (goto-char (point-max))
      (setq fi::last-input-start (point))
      (insert copy)
      (setq fi::last-input-end (point))))
  (fi::subprocess-watch-for-special-commands)
  (let ((process (get-buffer-process (current-buffer))))
    (cond ((null *inside-connect-is*)
	   (process-send-region process fi::last-input-start fi::last-input-end))
	  ((save-excursion
	     (goto-char fi::last-input-start)
	     (looking-at *ignored-commands-regexp*))
	   (process-send-string process "
"))
	  (t
	   (process-send-region process fi::last-input-start fi::last-input-end)))
      (fi::input-ring-save fi::last-input-start (1- fi::last-input-end))
      (when (and (on-ms-windows) (not *on-windows-nt*))
	(delete-char -1))
      (set-marker (process-mark process) (point))))
