Xref: utzoo comp.emacs:4650 gnu.emacs:166 Path: utzoo!attcan!uunet!bu-cs!bucsb!jbw From: jbw@bucsb.UUCP (Joe Wells) Newsgroups: comp.emacs,gnu.emacs Subject: csh alias for resuming Emacs Summary: inews garbage Message-ID: <2188@bucsb.UUCP> Date: 16 Nov 88 03:31:24 GMT Reply-To: jbw@bucsf.bu.edu (Joe Wells) Followup-To: comp.emacs Organization: Boston Univ Comp. Sci. Lines: 38 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= 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 \!* \\ '