diff options
Diffstat (limited to 'content/emacs/multi-process-emacs.md')
-rw-r--r-- | content/emacs/multi-process-emacs.md | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/content/emacs/multi-process-emacs.md b/content/emacs/multi-process-emacs.md new file mode 100644 index 0000000..bd878c8 --- /dev/null +++ b/content/emacs/multi-process-emacs.md @@ -0,0 +1,82 @@ ++++ +title = "Multiprocess Emacs environment" +author = ["MichaĆ Sapka"] +date = 2024-06-17T17:46:00+02:00 +categories = ["emacs"] +draft = false +weight = 3003 +image_dir = "emacs" +image_max_width = 480 +primary_menu = "cool-emacs-appendix" +abstract = "Running dedicated Emacs processes" +alias = ["/cool-emacs/multi-process-emacs"] +[menu] + [menu.cool-emacs-appendix] + weight = 3003 + identifier = "multiprocess-emacs-environment" ++++ + +The more you move into Emacs, the happier you may become. +But at the same time, Emacs is not a **real** shell, but a text editor. +This means there is no real way to manage functionality similarly one would manage applications. +It's all a buffer - the file you opened, each IRC channel, email list, and so on. +There are ways to manage it, like dedicated "workspace" plugins[^fn:1] or simple tabs. +But all those don't fit my mental model. +I am "Editing a file" or "chatting" or "writing a web page". +Those are separate concerns, so I want to have dedicated spaces for them. + +At the same time I want them in Emacs, as it gives me a unified interface. +I don't need to think how to change IRC channel, how to spell check, or how to actually write in my selected keybindings. + + +## Dedicated Emacs instances {#dedicated-emacs-instances} + +This led me to use multiple, dedicated Emacs instances. +This way, I've a got a dedicated IRC client, Code editor, Notepad, Email client, and so on. +I have unified interface, but at the same time it's still akin to dedicated programs. + +This has the added benefit of fault protection. +Tramp session hanging entire Emacs doesn't disconnect me from IRC, as those are separate processes. + +Therefore, I have functions which I call _ultimate modes_[^fn:2] to configure Emacs for given use case. + +A simple ultimate mode for IRC would look like: + +```emacs-lisp +(defun mms-irc-mode() + "use this instance of Emacs for IRC" + (interactive) + + (load-theme 'ef-bio) + + (erc-tls :server "irc.tilde.chat" :port "6697" + :nick "mms" :full-name "https://michal.sapka.me") + (erc-tls :server "irc.libera.chat" :port "6697" + :nick "mms" :full-name "https://michal.sapka.me") + ) +``` + +This simple function: + +- Loads a dedicated theme, so I won't get lost. IRC is a happy place, therefore green. +- Connects me to my servers + +ERC is configured elsewhere, so all auto-joins are there, just redacted, but nothing limits the number of things the ultimate mode setup up. +Want to defer loading of bigger package? +Want to reconfigure Ispell language? +Or maybe you want to load parts of Emacs configurations only when they make sense? +Shy is the limit! + +Now, I can either run `Emacs` and call `mms-irc-mode` or have a dedicated OS level key binding to run Emacs in this mode via: + +```shell +emacs --eval='(mms-irc-mode)' +``` + +This method could easily be expanded to run dedicated `emacs servers` and connected clients, but I wanted a simpler way. + +[^fn:1]: Like [perspective.el](https://github.com/nex3/perspective-el) +[^fn:2]: Yes, it breaks the musical theory naming scheme. + I could have used "tonic" there to run the `erc` and pla play with the wordplay, but I decided against it. + Dammit Jim, I'm an engineer, not a musician! + Also, diatonic modes don't fit the "larger than major" mode. |