[comp.emacs] set EDITOR=emacs

worley@galaxy.UUCP (Dale Worley) (03/08/88)

Often programs want to allow the user to edit some lump of text, so
they start up a subprocess running "your favorite editor" to do so.
They usually use the EDITOR environment variable to let you specify
the editor.  Of course, if you normally run your shell inside an Emacs
shell window, you get fried if the program starts up a subordinate
Emacs, so you have to exit and run the program outside of Emacs.

What I want is a program "emacsclient" which acts like an editor (as
its invoker sees it), but what it really does is take the file name
and send it to the Emacs which ran the shell which ran the program
which ran emacsclient (in the house that Jack built).  Then Emacs
would set up a buffer for editing the file, and when I exited (C-c C-c
on the buffer), Emacs would tell emacsclient that the file was edited,
and it should return to its caller.

I know that some sort of facility like this exists for X windows, but
I would like it for Sun windows.  Does anybody know how to do this?

Dale

mdb@amadeus.silvlis.COM (Mark D. Baushke) (03/08/88)

> Date: Mon, 7 Mar 88 11:38:02 EST
> From: sun!eddie.mit.edu!think!compass!galaxy!worley (Dale Worley)
> To: galaxy!info-gnu-emacs
> Subject: set EDITOR=emacs
> 
> What I want is a program "emacsclient" ...[omitted]
> 
> I know that some sort of facility like this exists for X windows, but
> I would like it for Sun windows.  Does anybody know how to do this?
> 
> Dale

The feature your are asking about already exists in emacs 18.x and is
independent of X windows (it will work on BSD machines at 18.49 and
below, in 18.50 it will work on SYS V machines which have IPC --
#define HAVE_SYSVIPC).

(Try looking in your gnuemacs/etc/emacsclient.c)

Inside of the master emacs window do:

	M-x server-start

The documentation for this is:

server-start:
Allow this Emacs process to be a server for client processes.
This starts a server communications subprocess through which
client "editors" can send your editing commands to this Emacs job.
To use the server, set up the program `etc/emacsclient' in the
Emacs distribution as your standard "editor".

Next, 'set EDITOR=/usr/local/emacs/etc/emacsclient' and you are all set.

Mark Baushke
mdb@silvlis.com		<-- finally, our domain is registered with NIC
silvlis!mdb@sun.com	    Note: silvlis.com does NOT have an Internet Port

smithln@CS.ROCHESTER.EDU (03/08/88)

How about a shell script like
================================================================
#!/bin/sh
# Written by Neil Smithline on 3/7/88 - smithln@cs.rochester.edu
# System dependant location of emacs and emacsclient
EDIR=/usr/new

case $TERM in
emacs | xterm | xterms)	exec $EDIR/emacsclient $* ;;
*) 			exec $EDIR/emacs $* ;;
esac
================================================================
You can just add more terminal types (suntool terminal types) as needed.
Change EDIR as is needed on your system - Neil

----------------------------------------------------------------
Neil Smithline
ARPA:    smithln@cs.rochester.edu
UUCP:    ..!{allegra,decvax}!rochester!smithln 
Mail:    CS Dept., University of Rochester, Rochester NY 14627
----------------------------------------------------------------

michael@boulder.Colorado.EDU (Michael Schmidt) (03/10/88)

In article <8803072153.AA06846@elm.cs.rochester.edu>, smithln@CS writes:
>How about a shell script like
>================================================================
>#!/bin/sh
># Written by Neil Smithline on 3/7/88 - smithln@cs.rochester.edu
># System dependant location of emacs and emacsclient
>EDIR=/usr/new
>
>case $TERM in
>emacs | xterm | xterms)	exec $EDIR/emacsclient $* ;;
>*) 			exec $EDIR/emacs $* ;;
>esac

Why not just put a 

if ($term == emacs) then
	setenv EDITOR emacsclient
else
	setenv EDITOR emacs
endif

(or similiar) in your .cshrc?

	Michael Schmidt