You are here

Grok Blog - Emacs multi-term and evil-local-mode

Submitted by blogmeister on Tue, 19/09/2017 - 16:41

My journey with emacs continues and after acquainting myself with the various terminals, I started using multi-term to connect to remote computing, and emacs is becoming a practical alternative to screen and tmux.

I have got into trouble with trying to edit files in the terminal using vim. Pressing i for evil’s insert mode causes the INSERT notification to appear twice in thewindow, one for the remote vim instance and one for emacs itself which also switches to INSERT mode. Using the ESC key and entering : to enter commands on the vim command-line is captured by emacs which is normally in evil mode, leaving no way to issue the ESC to the vim in the terminal to for issuing commands.

The other issue was that the terminal window entered some kind of scrolling mode, the term-line-mode, normally triggered by C-c C-j which is used to scroll through the terminal similar to the copy mode of screen. When I got into that mode I could see no way of exiting it except by killing the terminal window.

Further search lead me to the variables term-unbind-key-list and term-bind-key-list. The former sets keys whose normal behaviour is disabled in terminal windows, and the latter sets the commands some keys will run when in the terminal. term-unbind-key-list defaults to ("C-z" "C-x" "C-c" "C-h" "C-y" "[ESC]"), but I had no idea why ESC fails to work and is still captured by emacs. The command to set the ESC key to the terminal is term-send-esc and multi-term binds C-c C-e to it. Phew!! Problem partly solved. I also have to toggle evil-local-mode for some reason and I suspect that emacs starting in evil-mode results in rebinding the keys in term-unbind-key-list, ie ("C-z" "C-x" "C-c" "C-h" "C-y" "[ESC]").

It turns out that the combination of evil-mode C-c C-e followed by ESC results in endless scrolling. I need to test in other conditions to see if it is universal. When something appears to break in the terminal it has hard to tell whether is the correct expected behaviour you are seeing or it is something broken or conflicting which needs to be fixed.then report it.

I think emacs comes with more than its fair share of problems in the terminal, but I prefer to work in the terminal rather than in GUI mode.

This kind of problem illustrates why so many users don’t bother to investigate their problems before submitting bug reports or queries. In this case for example I would have to create a table listing a combination of states (assuming I know all of them),the sequence of steps taken, the outputs and God knows what else in order to submit a good bug report. But then I’d rather focus on trying to finish the task I set out to accomplish rather than go down the rabbit hole of trying to fix the problems that come up.

I am not even sure whether I’ve got some of the key sequences above right. I will consider setting evil-local-mode in terminals as I have decided not to use emacs in emacs-terminals to avoid confusion. That may help. In meanwhile I will have to remember to use C-c C-e in the place of the ESC key.

Add new comment