[comp.emacs] terminal.el again

mly@wheaties.ai.mit.edu (Richard Mlynarik) (05/18/89)

Oh by the way, if anybody ever gets inspired to work on it...  
It would be nice if somebody could hack together non-BSD/TERMCAP
stuff for terminal.el.  (As far as I know, the things which are needed
are a terminfo-or-wheatever equivalent of the termcap string
constructed in the function `terminal-emulator' and some equivalent
for `te-stty-string' (which is presently unconditionally
set to "stty -nl new dec echo".)

Have fun.

meissner@tiktok.dg.com (Michael Meissner) (05/22/89)

In article <2468@rice-chex.ai.mit.edu> mly-wh@wheaties.ai.mit.edu writes:
| Oh by the way, if anybody ever gets inspired to work on it...  
| It would be nice if somebody could hack together non-BSD/TERMCAP
| stuff for terminal.el.  (As far as I know, the things which are needed
| are a terminfo-or-wheatever equivalent of the termcap string
| constructed in the function `terminal-emulator' and some equivalent
| for `te-stty-string' (which is presently unconditionally
| set to "stty -nl new dec echo".)
| 
| Have fun.
| 

I did some hacking in this area some time ago.  Here is a terminfo
description for the terminal that terminal.el creates, and a simple
terminal for shell buffers.

emacs|emacs shell window,
	am,
	cols#80,
	cr=^M,
	ind=^J,
	lines#24,
	hs,
	tsl=\n,
#
emacs-virtual|terminal created by terminal.el,
	bel=^P^G,
	clear=^P\f,
	cols#79,
	cr=^P^A,
	cub1=^P^B,
	cud1=^P\n,
	cuf1=^P^F,
	cup=^P=%p1%'\s'%+%c%p2%'\s'%+%c,
	dch1=^Pd!,
	dch=^Pd%p1%'\s'%+%c,
	dl1=^P^K!,
	dl=^P^K%p1%'\s'%+%c,
	ed=^PC,
	el=^Pc,
	home=^P=\s,
	ich1=^P_!,
	ich=^P_%p1%'\s'%+%c,
	il1=^P^O!,
	il=^P^O%p1%'\s'%+%c,
	ind=^P\n,
	lines#24,
	mir,
	nel=\n,
	xon,

Here are some patches to 18.52 for shell.el and terminal.el to pass
the size correctly for terminfo systems.  I didn't change the stty
commands, since they worked fine under DG/UX.

*** ../orig_lisp/shell.el	Fri Apr 22 23:24:22 1988
--- shell.el	Fri Aug 19 11:51:55 1988
***************
*** 146,152
  
  (defun make-shell (name program &optional startfile &rest switches)
    (let ((buffer (get-buffer-create (concat "*" name "*")))
! 	proc status size)
      (setq proc (get-buffer-process buffer))
      (if proc (setq status (process-status proc)))
      (save-excursion

--- 146,152 -----
  
  (defun make-shell (name program &optional startfile &rest switches)
    (let ((buffer (get-buffer-create (concat "*" name "*")))
! 	proc status size term terminfo)
      (setq proc (get-buffer-process buffer))
      (if proc (setq status (process-status proc)))
      (save-excursion
***************
*** 155,160
        (if (memq status '(run stop))
  	  nil
  	(if proc (delete-process proc))
  	(setq proc (apply 'start-process name buffer
  			  (concat exec-directory "env")
  			  (format "TERMCAP=emacs:co#%d:tc=unknown:"

--- 155,175 -----
        (if (memq status '(run stop))
  	  nil
  	(if proc (delete-process proc))
+ 
+ 		;; For system V type systems, set up the COLUMNS
+ 		;; environment variable to tell the screen size
+ 		;; System V type systems, typically don't have
+ 		;; a terminfo entry for "emacs", if not use "dumb"
+ 		;; Michael Meissner, Data General
+ 	(if (not (setq terminfo (getenv "TERMINFO")))
+ 	    (if (file-exists-p "/usr/lib/terminfo")
+ 		(setq terminfo "/usr/lib/terminfo")))
+ 
+ 	(setq term "emacs")
+ 	(if terminfo
+ 	    (if (not (file-exists-p (concat terminfo "/e/emacs")))
+ 		(setq term "dumb")))
+ 
  	(setq proc (apply 'start-process name buffer
  			  (concat exec-directory "env")
  			  (format "COLUMNS=%d" (screen-width))
***************
*** 157,165
  	(if proc (delete-process proc))
  	(setq proc (apply 'start-process name buffer
  			  (concat exec-directory "env")
! 			  (format "TERMCAP=emacs:co#%d:tc=unknown:"
! 				  (screen-width))
! 			  "TERM=emacs"
  			  "EMACS=t"
  			  "-" program switches))
  	(cond (startfile

--- 172,181 -----
  
  	(setq proc (apply 'start-process name buffer
  			  (concat exec-directory "env")
! 			  (format "COLUMNS=%d" (screen-width))
! 			  (format "TERMCAP=%s:co#%d:tc=unknown:"
! 				  term (screen-width))
! 			  (concat "TERM=" term)
  			  "EMACS=t"
  			  "-" program switches))
  	(cond (startfile
***************
*** 204,210
  	(insert ?\n)
  	(move-marker last-input-end (point)))
      (beginning-of-line)
!     (re-search-forward shell-prompt-pattern nil t)
      (let ((copy (buffer-substring (point)
  				  (progn (forward-line 1) (point)))))
        (goto-char (point-max))

--- 220,229 -----
  	(insert ?\n)
  	(move-marker last-input-end (point)))
      (beginning-of-line)
!     (re-search-forward shell-prompt-pattern (save-excursion
! 					      (end-of-line)
! 					      (point))
! 		       t)
      (let ((copy (buffer-substring (point)
  				  (progn (forward-line 1) (point)))))
        (goto-char (point-max))

*** ../orig_lisp/terminal.el	Fri Apr 15 03:19:45 1988
--- terminal.el	Fri Aug 19 13:09:44 1988
***************
*** 1015,1021
  			     ;; control characteristics.  Then start the
  			     ;; "env" program to setup the terminal type
  			     ;; Then finally start the program we wanted.
! 			     (format "%s; exec %s TERM=emacs-virtual %s %s"
                                       te-stty-string
  				     (te-quote-arg-for-sh
  				       (concat exec-directory "env"))

--- 1015,1024 -----
  			     ;; control characteristics.  Then start the
  			     ;; "env" program to setup the terminal type
  			     ;; Then finally start the program we wanted.
! 			     ;; Provide some basic support for terminfo
! 			     ;; systems, providing you define the terminal
! 			     ;; type "emacs-virtual", Michael Meissner, DG
! 			     (format "%s; exec %s TERM=emacs-virtual %s %s %s %s"
                                       te-stty-string
  				     (te-quote-arg-for-sh
  				       (concat exec-directory "env"))
***************
*** 1021,1026
  				       (concat exec-directory "env"))
  				     (te-quote-arg-for-sh
  				       (concat "TERMCAP=" termcap))
  				     (mapconcat 'te-quote-arg-for-sh
  						(cons program args) " "))))
  	  (set-process-filter te-process 'te-filter)

--- 1024,1033 -----
  				       (concat exec-directory "env"))
  				     (te-quote-arg-for-sh
  				       (concat "TERMCAP=" termcap))
+ 				     (te-quote-arg-for-sh
+ 				       (format "LINES=%d" te-height))
+ 				     (te-quote-arg-for-sh
+ 				       (format "COLUMNS=%d" te-width))
  				     (mapconcat 'te-quote-arg-for-sh
  						(cons program args) " "))))
  	  (set-process-filter te-process 'te-filter)
--
Michael Meissner, Data General.
Uucp:		...!mcnc!rti!xyzzy!meissner		If compiles were much
Internet:	meissner@dg-rtp.DG.COM			faster, when would we
Old Internet:	meissner%dg-rtp.DG.COM@relay.cs.net	have time for netnews?