[comp.emacs] Setting terminal-emulator's environment

heiser@ethz.UUCP (Gernot Heiser) (12/05/87)

Using the  GNU emacs terminal-emulator   to run interactive  programs  would be
quite limited if the parent emacs  can't be used  for editing (when the program
run under the emulator starts up an editor).  While some  programs  (like `rn')
allow to explicitely specify the  editor, a general  solution would require  to
specify `emacsclient'  in the `EDITOR'   environment  variable of  the  process
running under the terminal emulator.

Naturally this could be done by running  the  shell under the emulator, setting
the   environment of  the shell, and  then running   the program  we are really
interested  in.  A  better way  would be    to set  the   environment from  the
`terminal-mode-hook'. Is there any means to achieve this???? (I'm running GNU
Emacs version 18.49.)
-- 
Gernot Heiser                   Phone:       +41 1/256 23 48
Integrated Systems Laboratory   CSNET/ARPA:  heiser%ifi.ethz.ch@relay.cs.net
ETH Zuerich                     EARN/BITNET: GRIDFILE@CZHETH5A
CH-8092 Zuerich, Switzerland    EUNET/UUCP:  {uunet,...}!mcvax!ethz!heiser

nate@cpocd2.UUCP (Nathan Hess) (12/18/87)

In article <261@bernina.UUCP> heiser@ethz.UUCP (Gernot Heiser) writes:

>   [...]         A better way  would be to set the environment from the
>`terminal-mode-hook'. Is there any means to achieve this???? (I'm running GNU
>Emacs version 18.49.)

Yes, there most definitely is a means to achieve this.  Here is a part
of my 'terminal-mode-hook' definition, which I have in my .emacs.  It's
kind of grungy, but, as they say, it works.  If anyone knows of a
better/faster/cleaner way of doing this, please pass it along!


(setq terminal-mode-hook
      '(lambda ()
	 (define-key terminal-escape-map "B" 'bury-buffer)
[...]
	 (if (string-equal (buffer-name (current-buffer)) "*Emacs tcsh*")
	     (progn
	       (sit-for 6 t)	; Let tcsh kick up
	       (send-string te-process "aliases;set prompt='tcsh<%\\!> ';stty dec tostop;setenv VISUAL '/usr/users/gnu/emacs/etc/emacsclient';setenv MORE -c;clear;w;echo ''\n")
	       (te-process-output t)))))
-- 
	   "How did you get your mind to tilt like your hat?"

...!{decwrl|hplabs!oliveb|pur-ee|qantel|amd}!intelca!mipos3!cpocd2!nate
<domainish> :   nate@cpocd2.intel.com		ATT :    (602) 961-2037

sharakan@think.COM (Eric Sharakan) (12/19/87)

In article <261@bernina.UUCP> heiser@ethz.UUCP (Gernot Heiser) writes:

   Using the GNU emacs terminal-emulator to run interactive programs
   would be quite limited if the parent emacs can't be used for editing
   (when the program run under the emulator starts up an editor).  While
   some programs (like `rn') allow to explicitely specify the editor, a
   general solution would require to specify `emacsclient' in the
   `EDITOR' environment variable of the process running under the
   terminal emulator.
   
   Naturally this could be done by running the shell under the emulator,
   setting the environment of the shell, and then running the program we
   are really interested in.  A better way would be to set the
   environment from the `terminal-mode-hook'. Is there any means to
   achieve this???? (I'm running GNU >Emacs version 18.49.)
   

The te-stuff-string function within the terminal emulator can be used
to send any string to the program (presumably shell) running in the
emulator.  I use this to do some stty setting as follows:

(setq terminal-mode-hook
      '(lambda () (setq terminal-scrolling t)
	 (setq terminal-escape-char 27)
	 (te-stuff-string "stty crtbs crterase crtkill ctlecho
")))

The last form does the same thing as if I had typed 'stty crtbs crterase ...'
at the prompt in the terminal emulator.  Simply replace that string with
"setenv EDITOR emacsclient<^J>" and you should be all set.

BTW, the other two forms within my terminal-mode-hook do the following:

- Set the terminal to scroll (as opposed to wrapping) when the bottom
of the terminal window is reached.

- Set the terminal escape character to <ESC>.  I don't like the
default value of CTL-^.

----
Eric Sharakan, Thinking Machines Corporation, Cambridge, Ma., 02142
sharakan@think.COM
ihnp4!think!sharakan
(617) 876-1111