2

multi-term is my current goto when I want a command line in Emacs. However, I have noticed a strange behavior, and I am not sure whether it is a bug, or if it can be configured.

If I type a command at the prompt - or any text for that matter, and kill the text with backward-kill-word (M-BACKSPACE for me), the text no longer shows up, but behaves like it is still there (see the screenshot, and you will know what I mean). This is what happens when I type ls, kill the text with backward-kill-word, type ls again, and hit enter.

enter image description here

A similar, but slightly stranger thing happens when I move to the front of the text and use kill-word. Below is a the result of typing ls, moving to the beginning of the line, killing the text, and typing ls again (notice the cursor position too).

enter image description here

This certainly seems buggy, but I am not sure. This happens in term as well, which is to be expected, so the problem is likely with term and inherited by multi-term. If I just delete one character at a time, nothhing goes wrong (but who has time to delete one character at a time! I use Emacs so I don't have to do such things. I am not an animal!) Also, this only happens in char mode, not line mode, which leads me to believe that maybe it is an intentional feature that I just don't understand. The docs term include the following sentence:

In char sub-mode, each character (except `term-escape-char') is sent immediately to the subprocess.

I don't actually understand what this means, but sound potentially related...Any ideas what is going on? Thank you!

elethan
  • 4,755
  • 3
  • 29
  • 56
  • See that 'duplicate' answer for code which will prevent this from happening, but note that the fix is to *disable* killing (and yanking) commands in `term-char-mode`, because killing text in char mode puts the command line into an inconsistent state. In char mode you should only use the shell's bindings for movement and deletion. Also note that the purpose of line mode is to facilitate using Emacs' own editing commands. – phils Nov 25 '15 at 06:49

1 Answers1

2

This is not a bug. You can't use emacs commands in term-char-mode, you must toggle to term-line-mode for these commands...

But, you can use the terminal commands instead. For example C-w is the terminal backward-kill-word. fortunately, a lot of commands have (almost) the same behavior in terminal and in emacs (C-k, M-c, M-l, M-. ...).

Another problem is that multi-term (as term) intercept some commands so you must change the default configuration for using them.

Here the muti-term configuration I use: http://djangoliv.blogspot.fr/2015/10/emacs-term.html

important precisions:

  • I am using two instances of emacs. One for the terminal (the conf above) and another (server) for the rest. It let me use terms in another frame but with emacs facilities.
  • I use C-x (not C-c) as prefix in emacs term.
  • I use tabbar and tabbar-more (http://djangoliv.blogspot.fr/2015/11/tabbar.html)

Hope this help.

djangoliv
  • 3,169
  • 16
  • 31