Article View: comp.emacs
Article #9622Re: cmushell-mode
From: John Robinson
Date: Mon, 26 Feb 1990 05:01
Date: Mon, 26 Feb 1990 05:01
61 lines
2888 bytes
2888 bytes
In article <RSM.90Feb25184117@coral.math.arizona.edu>, rsm@math (Robert S. Maier) writes:
>In article <wZtrldm00htFFhJS9X@cs.cmu.edu> Olin Shivers writes,
>>It is not possible to reliably track the current working directory
>>100% of the time. Forget it.
>
>It's certainly not possible with shell-cd-regexp, which is a bit of a
>hack. But in cmushell.el, authored by Olin Shivers, I find an
>intriguing alternative suggestion:
>
>;;; The right way would be to hack the shell so that when it changes
>;;; its pwd, for any reason, it notifies emacs via some ipc channel or
>;;; something.
>
>This sounds like a very good idea. Has anyone actually implemented
>it?
Well, you could take xterm's approach. Define a character sequence
that has the effect of notifying the terminal emulator to change
state. For xterm, this lets you put CWD in the title bar. Then, you
can alias cd and friends to also spit out the magic sequence.
Bash does this one better, because of PROMPT_COMMAND. Here's the bash
definition I use:
function xtitle () {
if [ "$oldxtitle" != "$*" ]
then
oldxtitle="$*"
echo -n "]0;$*"
fi
}
PROMPT_COMMAND='xtitle "$HOST: $PWD"'
bash executes prompt_command every time it's about to print the
prompt. The echo -n inside there wraps the $HOST: $PWD inside the
right character sequence to tell xterm to modify its title. In shell
mode, a process-filter could pick off this (or a similar) sequence and
update the shell's buffer's cwd.
It's too late for me tonight, but if anyone writes this process filter
please post or mail me - I'd use it!
>Are there any other pieces of the inferior shell's internal state,
>besides the current directory, that it would be desirable for Emacs to
>know about?
What host you're on, as in the above example. SubJobs might be
another.
>BASH developers, please note...
... maybe they already have :-)
bash, by the way, works fine inside shell buffers (it respects the
stty modes and doesn't start spewing needless ^M's and echos). But,
given that it has to emulate /bin/sh, this is de rigeur.
free of csh (and issue) at last!
--
/jr, nee John Robinson Life did not take over the globe by combat,
jr@bbn.com or bbn!jr but by networking -- Lynn Margulis
Technical Details
Message-ID:
<52634@bbn.COM>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!usc!zaphod.mps.ohio-state.edu!think!bbn!jr@bbn.comReferences:
<wZtrldm00htFFhJS9X@cs.cmu.edu> <RSM.90Feb25184117@coral.math.arizona.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!usc!zaphod.mps.ohio-state.edu!think!bbn!jr@bbn.com From: jr@bbn.com (John Robinson) Newsgroups: comp.emacs Subject: Re: cmushell-mode Summary: pick up CWD like xterm does it Message-ID: <52634@bbn.COM> Date: 26 Feb 90 05:01:31 GMT References: <wZtrldm00htFFhJS9X@cs.cmu.edu> <RSM.90Feb25184117@coral.math.arizona.edu> Sender: news@bbn.COM Reply-To: jr@bbn.com (John Robinson) Organization: BBN Systems and Technologies Corporation, Cambridge MA Lines: 61 In-reply-to: rsm@math.arizona.edu (Robert S. Maier)