Sign up ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

When I start MathKernel from the Emacs shell, there are always extra spaces inserted so the cursor goes to the far right side of the screen.

For example

% emacs -q M-x shell /Applications/


Mathematica 9.0 for Mac OS X x86 (64-bit)  
Copyright 1988-2013 Wolfram Research, Inc.
In[1]:=                                                                       |<-

where I am using |<- to show where the cursor is after the 70 whitespace characters are inserted after In[1]:=.

Does anyone knows why such a thing happens and how to prevent it?

share|improve this question

2 Answers 2

This can be prevented by turning off the terminal input library. In Mathematica 9.0.1 or later, the -rawterm command line switch can be used when starting the kernel. For Mathematica 9.0.0 this can be accomplished by adding the following line


to the kernel's init.m file.

share|improve this answer

I see the same problem running the Mma kernel 10 on Linux Debian Wheezy. This happens with emacs 23 and emacs 24; Running in either an X window or terminal. I can ssh into a remote machine from an emacs shell and run the Mma kernel on the remote machine and I see the problem. I do not see the problem if I run Mma 3.0 kernel. I had access to Mma 6 and 8 in the past and never saw the problem. But, I no longer have access and can't check them now. I do not have access to to Mma kernel 9 mentioned by the original poster. I tried both M-x shell and M-x eshell. Both show the problem. I spent quite a bit of time searching for similar problems with emacs shell mode, but found nothing.

EDIT: There are rumors saying that Mma/Wolfram is using GNU readline in kernels 9 and 10. ("rumor" not because they are hiding anything, but they don't document the kernel) Indeed, I notice that the arrow keys work with Kernel 10, and some other strange behavior as well. Ctrl-a Ctrl-k will kill the line, but you don't see the cursor move. This is all in a plain terminal. But it makes sense that this is what is causing the new emacs problem and why it does not occur for Mma kernel 8. Someone said that at a conference, a Wolfram employee said the readline keybindings are hardcoded. There are some posts that talk about removing some dlls in order to kill readline support. This may make emacs problem go away. It is extraordinarily difficult to get any information on using the Kernel from Wolfram web pages, which is strange since the document many things so well. But, if you google WolframKernel you find a page that lists some command line switches. I assume this is an exhaustive list, and I don't see one to disable readline. By the way, for me the new partial readline support breaks "rlwrap math" as well. We may have to wait to see if Wolfram improves this in their next version.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.