Thanks very much, Judah!

Given this info, there's a fairly easy emacs haskell-mode work-around.  I made a shell script "ghci-no-tty" in my ~/bin that contains

    # So ghci+readline won't echo input
    cat | /usr/local/bin/ghci $*

and used "M-x customize-group" with the "haskell" group to set the "Haskell Program Name" variable to "/home/conal/bin/ghci-no-tty" (must be full path).

Now there's no more input echoing, and commands like automatic signature insertion ("\C-c\C-t") work again.

Hooray!

  - Conal

On Sun, Nov 16, 2008 at 10:31 PM, Judah Jacobson <judah.jacobson@gmail.com> wrote:
2008/11/16 Conal Elliott <conal@conal.net>:
> I'm still looking for a solution to this problem.  I've heard from a few
> people who are affected also, but not any solution.
>
> Barring a solution to ghci's behavior, does someone have an emacs-based
> workaround?
>
>   - Conal
>
> On Tue, Nov 11, 2008 at 4:41 PM, Conal Elliott <conal@conal.net> wrote:
>>
>> ghci echoes all of my input in emacs, when run via haskell-mode or via
>> "M-x shell", which then confuses various useful haskell-mode features.  I
>> built it from sources.  At the time I didn't have libedit-dev, so today I
>> installed libedit-dev (version 2.11~20080614 on ubuntu), did a clean make &
>> install, and I get exactly the same behavior.
>>
>> Does anyone have experience in getting through this problem?  Willing to
>> help me out?
>>
>> Thanks,
>>
>>   - Conal
>>
>

Hi Conal,

The problem is that eshell tells subprocesses that they're running in
a terminal (e.g., when queried via hIsTerminalDevice), but always
echos user input itself regardless of the tty's ECHO attribute.  This
confuses libedit, which assumes that if it's connected to a terminal
then it can turn off echoing in order to run its own rich line editor.

In "M-x shell", you can work around this issue by starting ghci with,
for example, "cat | ghci" to prevent ghci and libedit from trying to
run as if in a terminal.  Probably something similar could be done for
haskell-mode; I'm not familiar enough with emacs to fix it myself.

Incidentally, googling revealed that zsh has a similar issue:
http://www.zsh.org/mla/users/2001/msg00014.html (section 3.10)

Hope that helps,
-Judah