jbw@bucsb.UUCP (Joe Wells) (11/16/88)
Here is the latest version of my csh alias for resuming and/or starting Emacs. This one avoids forking "test" processes. I still haven't figured out a completely successful way to determine if an Emacs job is already running without using grep on the output of the jobs command. This alias is specific to GNU Emacs, although I suppose the general principles might be used for other programs. The alias works as follows. First, it checks if a Emacs job is running as a child of the current shell. If so, it puts command line arguments in a file and resumes the Emacs job. If that fails, it checks if an Emacs job is listening on the ~/.emacs_server socket (windowing system), and connects to it. If that fails, it starts up a new Emacs job. What kind of Emacs job it starts depends on the environment variables DISPLAY and WINDOW_PARENT, which indicate windowing environments. Any bugs or gripes to me, please. BTW, the ideas for this alias came from many people, they are not all my own. -- Joe Wells INTERNET: jbw%bucsf.bu.edu@bu-it.bu.edu UUCP: ...!harvard!bu-cs!bucsf!jbw --------------------cut here and put in .cshrc-------------------- set EMACS=<put name here to use to execute emacs on your system> set STOPPED_PATTERN='^\[[0-9]\] . Stopped ............ ' alias emacs \ ' \\ jobs >! /tmp/jobs$$ \\ && grep "$STOPPED_PATTERN$EMACS" /tmp/jobs$$ >& /dev/null \\ && echo `pwd` \!* >! ~/.emacs_args && %$EMACS \\ || if (! -e ~/.emacs_server || -f ~/.emacs_server) set status=1 \\ && emacsclient \!* \\ || @ status=1 - $?DISPLAY && eval "$EMACS -i \!* &" \\ || @ status=1 - $?WINDOW_PARENT && eval "emacstool -f emacstool-init \!* &" \\ || $EMACS -nw \!* \\ '