Emacs hangs after typing '/<anything>:' pattern - emacs

I am trying to connect to remote server by scp, but when I type C-x C-f /myhost: (no Enter pressing), emacs hangs for few minutes, then it allows to press Enter in minibuffer, and connects to host.
It Messages buffer it says:
For information about GNU Emacs and the GNU system, type C-h C-a.
Making completion list...
Whatever I type in minibuffer between / and : - it makes emacs hang.
ssh and scp work fine, I tried to turn on and turn off ssh agent - it didn't help.
Yesterday everything worked fine, I haven't installed any packages or changed emacs configs.
How to debug it?

Related

tramp ssh: Waiting for prompts from remote shell

I have been using emacs with tramp for a few weeks now to ssh into a server and edit some files. I do this by C-x C-f /ssh:username#server.com. Suddenly this has stopped working. I am getting "Waiting for prompts from remote shell problem" message.
However, If I don't provide a username (C-x C-f /ssh:server.com) then the connection seems to get established.
I am running emacs 24 using cygwin. How can I get this connection to work again?
There is one relatively common reason (at least on Windows/Cygwin platform): the ssh process started by tramp gets somehow stuck and unresponsive.
On my current desktop this happens once every month or so.
Just kill any ssh processes, either from your favourite cygwin terminal (with kill -9) or from your Windows task manager. This gets everything working again.
I have never encountered this problem on Linux, only on Windows/Cygwin.

Backspace doesn't work in ssh in term-mode inside emacs

I'm running a terminal inside emacs, using term-mode. In that terminal I'm ssh-ing to another host and on that host, the backspace key no longer works. It works fine if I'm ssh-ing from a different terminal emulator outside of emacs.
So just to be clear, I'm not running emacs on the remote host, I'm running a remote shell inside emacs.
So it is your terminal in emacs you need fix, :D
I had a similar issue with a perticular setup where backspace key through ssh act as delete key, seems emacs sometime have problem guessing which one is which in non-GUI setting.
what I did is change (normal-erase-is-backspace-mode 1) from 1 to 0. You could try that, but is sounds like a terminal issue to me.
reference in emacs manaul about that setting

Emacs 24.3.1 TRAMP hangs on opening file

I am running graphical Emacs 24.3.1 (this problem exists when using the console version as well) on Arch Linux. I am trying to use TRAMP to open files on a remote Fedora system by SSH with a private key which requires a password. Authentication works fine, and so does the listing of files. When I do try to open a file, my Emacs session hangs with "Tramp: Inserting `/{filename I'm trying to open}' ...done". It is not possible to abort with ESC ESC ESC or C-g. Does anyone have a solution to this?
Emacs 24 normally works very well with Tramp. What you might need is ControlMasterAuto in your .ssh/config file. This will ensure that the ssh connection information passes seamlessly to Emacs. This will also ensure that you only need to login once in a terminal and use multiple emacs frames in tramp mode. I have detailed the following steps
(1) Go to your .ssh/config file and add the following options
Host <hostname>
ControlMaster auto
ControlPath ~/.ssh/%r#%h:%p
ServerAliveCountMax=30
ServerAliveInterval=5
(2) Now login to the remote host through terminal.
(3) Open emacs frame and try opening the remote files through tramp (/ssh:). You must be able to connect to the remote host.
The above steps should work even for a two level authentication (using a rsa key +password).
This thread is old - however, a very similar problem on my FC22 laptop (tramp hanging when trying to type a colon following /su in the minibuffer) appears to be fixed by commenting the ::1 line in /etc/hosts.

Detaching and Re-attaching to Emacs server

I am already using Emacs server for some of the problems described in the documentation, For example, I have (server-start) in my .emacs init file, and I have set the EDITOR env. variable to emacsclient so that git and other programs don't open a new instance of Emacs when they need me to type text or log message. This is working great so far.
I am now wondering if I can use Emacs server for something else: I often launch Emacs remotely through an ssh -X session. Sometimes I need to close the ssh session (e.g. I need to reboot my local computer) and re-connect. It would be great if instead of fully closing Emacs for this, I could detach from Emacs, and reattach later.
Is this possible with Emacs server? I believe from things I have read online that the answer is yes, but:
My question:
How can I safely detach from an Emacs server and reattach later?
If you directly start Emacs from within the SSH session, you cannot gracefully detach, because the Emacs process becomes part of the process group created by the remote shell, and if the shell exists it will terminate all processes in its process groups.
However, you can start Emacs in Daemon mode first, with emacs --daemon. Emacs will load the configuration, start an edit server (even without an explicit (server-start) in your configuration), and detach from the terminal. This Emacs daemon will stay alive across different SSH session.
Subsequently, only use emacsclient to connect to the running daemon.
emacs --daemon or (server-start) in .emacs.
Next use emacsclient file, emacsclient -n file or emacsclient -c for just an attaching.
To leave attach as usual C-x C-c.

emacs as a screen/tmux alternative - detach from terminal

It's well known that emacs can be used as a terminal emulator (while itself is running in a terminal emulator), thus making it a valid alternative to more traditional terminal-in-a-terminal approaches, such as tmux or screen. However, there's one thing that could be done easily with the latter and I've found no alternative in emacs' term for this one so far.
Both tmux and screen can detach from a terminal and all tasks ran in their windows continue to run in background. It's done using C-b, d in tmux and C-a, d in screen by default. Later, I can return (reattach) to the terminal I've detached from by running something like tmux attach or screen -r. Also, sessions run in both of these terminal multiplexers are persistent - i.e. if I'm connected to some remote terminal and connection fails, I can reconnect and reattach to the terminal without losing any of my work - it really helps in case of faulty network link that occasionally breaks ssh connections.
Is there something like that available for emacs? Basically, I'd want to be able to:
Detach from emacs and leave it running in background with all the sub-processes ran in term buffers intact.
Reattach to it later and find all my processes running.
Automatic detachment of emacs from terminal on receiving a SIGHUP.
Use emacs daemon:
$ emacs --daemon
Then simply launch a new frame, equivalent for screen -x:
$ emacsclient -t