[[!sidebar content=""]] [[!meta title="Getting detached from Emacs"]] [[!meta copyright="Copyright © 2022 Niklas Eklund"]] [[!inline pages="internal(2022/info/detached-nav)" raw="yes"]] # Getting detached from Emacs Niklas Eklund (he/him, ) [[!inline pages="internal(2022/info/detached-before)" raw="yes"]] As an enthusiastic Emacs user I would find myself replacing the usage of an external terminal emulator with the Emacs alternative interfaces. This included using packages such as dired for file management, magit for git and proced for processes. However I always kept a terminal around for running shell commands. These were commands that I knew would either, take a long time to run, produce a lot of rapid text output or that I would run on a remote machine. In the remote case I would rely on tmux to be able to detach and let the command run even when I wasn't connected. To rid me of the need for the terminal emulator in these situations I developed the detached.el package. It is a package that builds on top of the dtach program, which provides the ability to detach and re-attach to processes, to offload Emacs from these processes. The package seamlessly integrates the ability to detach and attach into Emacs, and offers integration with many built in features such as shell, eshell, compile, org and dired. In this talk I will demonstrate the features of this alternative way to run detached processes and how the package can leverage built in Emacs functionality to provide a great experience. The user interface will be showcased and how the processes essentially becomes text, which fits very well into Emacs. # Bio - Blog: - Source code: My name is Niklas Eklund. I am 35 years young and I live in Gothenburg (Sweden) with my wife and our dog. In my daily work, I write code in C++ and Python. My free time I dedicate to music, board-games, improvement, and of course, Emacs. More than 4 years has passed since I first started using Emacs and there is so much to like about it: its community, the ethics and how it encourage me to experiment and explore. Whether it is about writing a small function, or a package, the ability to mold Emacs to what makes sense to us as individuals is something to cherish. # Discussion ## Questions and answers - Q: Can it replace ssh+tmux for persistent sessions on remote hosts? - A: Not yet; being considered for future work. - Q: I see integration with projectile in the readme, does it also integrate with project.el? - A: Not yet but should be easy to add. - Q:  Can you detach a session from shell-mode and reattach from eshell/vterm/term-mode?  Or start a compile in shell-mode and attach it from compilation-mode? - A:  - Q: How do you talk to **dtach? Could it be feasible to run a child emacs instead of dtach?  Would it make sense? Better communication maybe?** - A: - Q: How does it handle processes that require user input? (Usually to type y/n, etc). M-x compile is great but can\'t handle user input. - A: - Q:Can you rerun a command (session?) but in another directory? - A: - Q: What are some other places where this might be useful?  mu4e fetching mail?  Git processes started by Magit?  What things would you like to see working in a 1-2 year timeframe? - A:  - Q: What are you currently excited about in emacs?  [[!inline pages="internal(2022/info/detached-after)" raw="yes"]] [[!inline pages="internal(2022/info/detached-nav)" raw="yes"]]