1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
+++
title = "Multiprocess Emacs environment"
author = ["Michał Sapka"]
date = 2024-06-17T17:46:00+02:00
categories = ["emacs"]
draft = false
weight = 3002
image_dir = "cool-emacs"
image_max_width = 480
primary_menu = "cool-emacs-appendix"
abstract = "Running dedicated Emacs processes"
[menu]
[menu.cool-emacs-appendix]
weight = 3002
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.
|