views:

161

answers:

2

I'd like to get emacs sql-mysql mode working in windows xp. I'm able to enter sql-mysql mode and connect to mysql database successfully. The problem is that the SQL buffer doesn't show the "mysql>" prompt. In other words, it's not interacting with mysql.exe.

I think it's because the mysql.exe program is going into "non-interactive" mode when it's started behind the scenes by emacs.

None of the mysql options seem to be of any help.

Any ideas about how to fix this? I can see this being a problem for emacs comint mode interacting with other command line utilities in windows as well, so maybe there's a os level solution?

+1  A: 

There is actually no way if you don't run it from a (pseudo)terminal. It checks file descriptors 0 1 by isatty and it sets batch mode if at least one of them is not a terminal. On the other side you can force batch mode.

Anyway this makes quite sense, because readline which is used for prompting needs a terminal to work reasonably. So the proper way to fix this is to run it in a pseudoterminal.

Michal Čihař
Thanks for the info, Michal. I'm starting emacs from cygwin. Any idea on how I can tell emacs to run mysql inside a pseudo terminal? Or perhaps I can trick isatty to always return 1? (I'm not very familiar with cygwin, as you can probably tell)
Dave Paroulek
Run it inside xterm or something like that. I really don't know Cygwin much.
Michal Čihař
+2  A: 

The problem is that emacs' builtin terminal uses pipes to talk to the client process. Mysql.exe is a native Windows programs, hence isatty() actually checks whether the file descriptor/handle in question is a console. That fails on pipes, hence mysql enters batch mode. I can't see a way to force interactive mode either. Shame, as it would presumably be trivial to implement.

Running it in xterm or other terminal based on Cygwin ptys will show the same issue, because Cygwin's pty emulation is based on Windows pipes.

ak
Well, not the answer I was hoping for, but thanks for the explanation.
Dave Paroulek