Yi Tang Data Science and Emacs

Multiple Working Emacs

I work solely inside of Emacs, so when Emacs is down, I cannot do any work. Emacs itself is very reliable, but there might be some risks of downtime when upgrading Emacs or any of the 3rd party libraries that I use.

The downtime can be minimised by always having multiple Emacs versions and their 3rd party libraries available. This blog post documents how I implement it.

Installation

Firstly, install each Emacs into its separate folder, e.g. on my Debian box, I have ~/bin/emacs30.0.92/ installed 8 months ago and ~/bin/emacs30.2/ installed yesterday. This is easy to achieve by adding the prefix option when building Emacs from source, e.g.

 
./configure --with-tree-sitter  --prefix=$HOME/bin/emacs30.2

Daemon

Then have a separate systemd service for each Emacs version. Taking version 30.2 as an example, its unit file is saved as ~/.config/systemd/user/emacs30.2.service.

In that unit file, the Emacs executable is specified in full path to wherever it is installed

[Unit]
Description=Emacs text editor
Documentation=info:emacs man:emacs(1) https://gnu.org/software/emacs/
After=graphical-session.target


[Service]
Type=simple
ExecStart=%h/bin/emacs30.2/bin/emacs --fg-daemon=work --init-directory=%h/.config/emacs/emacs.d_30.2
ExecStop=%h/bin/emacs30.2/bin/emacsclient -s work --eval "(kill-emacs)"
Environment=SSH_AUTH_SOCK=%t/keyring/ssh
Restart=on-failure

[Install]
WantedBy=graphical-session.target

In the unit file, I also added the initial option init-directory so it has its own .emacs.d directory. It ensures the 3rd party packages will be installed there.

Note if there is an init.el file in that directory, Emacs will use that instead of the ancient ~/.emacs file.

GUI

Finally, to open an Emacs GUI that connects to the Emacs 30.2 daemon, run

 
~/bin/emacs30.2/bin/emacsclient -s work -c .

from the command line.

I sometimes found it is more natural to have a desktop application for GUI, so I have ~/.local/share/applications/emacsclient-30.2.desktop file, and the content is

[Desktop Entry]
Name=Emacs 30.2 (Client)
GenericName=Text Editor
Comment=Edit text
MimeType=text/english;text/plain;text/x-makefile;text/x-c++hdr;text/x-c++src;text/x-chdr;text/x-csrc;text/x-java;text/x-moc;text/x-pascal;text/x-tcl;text/x-tex;application/x-shellscript;text/x-c;text/x-c++;x-scheme-handler/org-protocol;
Exec=~/bin/emacs30.2/bin/emacsclient --create-frame -s work %F
Icon=emacs
Type=Application
Terminal=false
Categories=Development;TextEditor;
StartupNotify=true
StartupWMClass=Emacs
Keywords=emacsclient;
Actions=new-window;new-instance;

[Desktop Action new-window]
Name=New Window
Exec=~/bin/emacs30.2/bin/emacsclient --create-frame -s work %F

[Desktop Action new-instance]
Name=New Instance
Exec=~/bin/emacs30.2/bin/emacsclient --create-frame -s work %F

Not Perfect But Close

There could still be some risks of downtime due to conflicts between Emacs/package versions, or caused by updating the OS/other programs. These cases are rare, so this setup is good enough for me.

Rebate Architrave

Had a chill day walking around the canal path in London, at 6:30 pm, I was keen to continue on the home office project.

The existing wall is not plumb, so when I put the architrave, there’s a gap. This is a typical issue, and a small gap (less than 3mm) can be filled with deco chalk. In my case, the bottom has a 10mm gap, which I have to address.


10mm gap at the bottom between the architrave and the wall

In general, there are two ways: either add a small piece to the door lining to fill the gap, or rebate the architrave to accommodate the wall protrusion. I jumped to the rebate approach as I didn’t have any additional strips of wood for the first approach (happy skip days).

A quick measurement told me the architrave needs a rebate of 45mm wide, and the depth varies: starting from 1300mm height, reaching to 10mm deep at the bottom.

The easiest way to do this in this scenario is to cut 10mm deep across the board, as it is okay to have some voids behind the architrave, and there are still 25mm for the architrave to be fixed on.

My first attempt was using a track saw: first cut was at 45mm line, from the bottom all the way to the 1300mm mark. The next cut is right next to the previous cut to increase the rebate area. Repeating this process many times to get to the whole 45mm area. The groove in the photos below is made from 3-4 passes.

With a blade kerf of size 1.8mm, I figured it requires 25 cuts to get to 45mm. My efficiency-seeking brain took over and said: There must be a better way.

So I pulled out the Dewalt router from the drawer, set the depth, and clamped the architrave down to the table. The immediate problem I faced was that it didn’t cut in a straight line: it went like 45-60 degrees for some reason, so I couldn’t cut a long groove like I had done with a track saw.


Rebate using a track saw and a router

So I turned the router 90 degree and cut small and short chunks instead. It worked well: the grooves I cut using a track saw serve as a stopping line so I won’t cut extra. It was not perfect because there were tons of dust coming out from the router, and it made so much noise.

I put my headphones on and made a few more passes. I started seeing how it can be done for the whole 1300m length. Then I saw my neighbour over the fence, asking what I was doing. Well, it turned out to be 7:30 pm already, so I had to stop and leave it for tomorrow.

In hindsight, the track saw can do a much better job because I realised only 5-10 passes would be enough. The small pieces between grooves can be knocked off rather easily using a chisel. The track saw has better dust collection, and the noise is much lower.

Another completely different approach is to remove the protrusion on the wall using a multi-tool: placing the blade on the door lining so the cuts will be flush with the door lining, and pre-cutting the 45mm line to have a neat finish.

Terminating Ethernet Cable At Height For CCTV Cameras

On the Ground

The standard Cat 6 plug is a pain to work with: I have to untwist the 4 pairs, make them perfectly straight, lay the 8 wires side by side with no gaps, and then insert all of them into the RJ45 plug in one go.

It sounds easy, but since the wires are flexible, it is actually very hard: very often the wires move around and become misaligned or misplaced during the fitting. If that happened or any other part of it went wrong, I would have to pull out the whole lot and restart again.

I had successes before, usually after a couple of attempts, often accompanied by frustration in between. It requires me to activate the fight mode, give it 100% focus while sitting in an “Orz” position1, so there’s quite a lot of energy poured into it.

At Height

However, even if I want to, it becomes physically impossible when it comes to fitting a plug in the air for the CCTV cameras: the ladder is a bit wobbly with uneven ground underneath it, and it is windy and raining due to a summer storm.

Since I wasn’t happy with the normal Cat 6 plug, I was keen to try new products. So when I first saw the IDC Punch Down to RJ45 Plug from Kenable 2, I ordered a few. It turned out to be a smart little move (this time).

This product has a built-in RJ45 plug that is already wired up, so I can skip that difficult part. All I have to do is punch down the wires into the IDC terminal. Punching down itself is very easy; I can do it half-minded with one hand.

Another benefit is that I can split the fitting into multiple steps, and I can take mini breaks for my arms between steps. Once one or two wires are inserted into the IDC terminal, it binds the cable to the plug. The binding is strong, so it hangs in the air and swings a bit with the wind with no issues. Then I take my time for the rest of the wires. If you don’t appreciate how important it is, trust me, your arms become rather fatigued when working with your hands overhead.

The only flaw with this product is that the punch-down slots are too wide for the impact adjustable punch-down tool; I was lucky to have a tiny punch-down tool at hand to use.

Footnotes

1 For people who don’t know what “Orz” stands for, “O” is head, “z” is legs and hips, and “r” is arms.

2 This post is not affiliated with Kenable

Extend Ethernet Cable

I had to extend the main Ethernet cable that connects the main router in the living room to the secondary router in the new office. Technically, the cable size is spot on, but I had to cut back 2-3 times because a combination of my lack of experience and the LAP data module from Screwfix is rubbish.

It seems like an unusual task given that there are only a few products available on the market. I tested two, and I am happy with the results, so I am documenting here for people who might find it useful.

Jelly Crimps

The first product I tested was from my electrician. It took me a while to find out that its name is Jelly Crimps. You can get it from TLC or Amazon.

The little connector has two long sleeves that host two wires. It has a button in the middle; press it very hard, and it will release the gel. I highly recommend using a piler unless you have super strong figures.

The process is simply: insert the wires, press with a piler to release the gel, and repeat 8 times for each wire.


Jelly Crimps in Use

It costs about £0.2 to extend one cable, so it is very cost-effective. I wasn’t sure it would work, but it does, and my electrician vouches for it.

The only problem with this product is that it is not maintenance-free. According to my electrician, I will have to put these connectors into a back box and put a front cover over it, which changes it to a much bigger job.

Inline Coupler from Kenable

So I decided to look for a better solution, and I found this Cat 6 Inline Coupler from Kenable.

It got 2 terminate blocks built-in, one for the incoming cable, and one for the outgoing. There is a diagram of the Type B protocol printed on the product, so I don’t have to look it up on my phone. All I have to do is punch down the 16 wires one by one. With a quality punch down tool it is a lot easier and quicker than I thought.


Inline Coupler In Use

The product itself is solid, much better quality than the LAP data module. I didn’t have to worry about damaging the terminal or face plate when pushing it against the wall while using a punch-down tool.

The size is on a sweet spot, about 24mm depth, just enough to tuck it into the 25mm service void. I am not sure if it is maintenance-free or not, but I am comfortable leaving it in the service void as it has an enclosing cover on it.

Kenable is the only place that sells it at a reasonable price, about £2 each, while the rest of the sellers is asking for £5 so thank you Kenable for making it affordable.


Full 500 Mbps Speed in the Office

Re-discovery the Ancient Info Documentation System in the Age of LLM

So there are few notes that helped me to learn Info. Hopefully it can
bring more new users to the Info system.

Table of Contents

  1. Travel with Info
  2. Why Info is not Popular?
  3. dir the Index File
  4. Setup Info in MacOS

Travel with Info

The best time to learn difficult thing is in travelling. During my last two-week’s trip to Singapore/Malaysian, I was reading about Ledger Cli causally. without putting much efforts, it clicked. It suddenly started to make sense to me.

The more I learn, the more I want to learn more. I cannot wait for the next opportunities to open Emacs and dive into Ledger’s brilliant documentation. This is me with my Emacs in Changi Airport next to the Jewe.


Emacsing next to the Rain Vortex in Changi Airport

I was able to apply the learning and came up with the project-rule to keep data hygiene (will blog next). The positive feedback energise me. The flight to London is ready for boarding but I don’t want stop exploring during the 14 hours flight without WIFI.

That’s where I re-discovered the Info documentation system. I used it to read the ledger.el library between sleep sessions 8000 feet above the ground. Reading in plain text inside of Emacs has great benefits, no distractions, fraction free in taking notes. it was a breeze.

Then I stepped into learning the Info documentation system itself, how to navigate, search text/index and all that. I was able to pick it up quickly, the concepts and shortcuts are native to me as an experienced Emacs user.

I envisioned myself to use it to read all the documentation, e.g. Pandas library’s in Python. That would be ideal I told myself. However, I soon realised that Info documentation system is a niche tool: it is mostly used in GNU projects and Emacs libraries.

Why it is no popular? I was wondering myself. I decided to have a go myself. well, the journey to start is already full of hiccups. This is typical theme in learning legacy system, and could put many people off.

So there are few notes that helped me to learn Info. Hopefully it can bring more new users to the Info system.

dir the Index File

The first and most important thing I realised is, in the context of Info, the dir is not a directory, but a plain text file. I simply call it index file, then the rest becomes so much clearer.

The =dir=/index file is the entry point of the Info program. it has a lists of the available Info manuals with their name, Info file location, and desecration.

Setup Info in MacOS

Then there is a bug in emacs-plus: during the installation of Emacs, the dir file somehow got deleted in the cleaning process. So the manuals for the default libraries that comes with Emacs are not available. In my case, I only have few Info from the packages I installed post-installation, like orderlies, org-roam for example.

I took a slightly different approach to fix this problem: I kept the system level tools separate from the Emacs’s library, so i have two dir files.

 
# manuals of system level programs
cd /opt/homebrew/share/info
for file in * ; do install-info "$file" dir; done

# manuals of Emacs and Emacs libraries
cd /opt/homebrew/share/emacs/info
for file in * ; do install-info "$file" dir; done

Then tell Emacs the locations of those dir files as below.

 
(setq Info-directory-list
      (list "/opt/homebrew/share/info"
            "/opt/homebrew/share/info/emacs"))

Note, the convention is for each directory in the list, there is a dir file, on in Emacs, we are specifying the file using directory, and the file is happened to be called dir. I feel the naming can be improved to avoid such confusion!

After restarting Emacs, Info will show there are about 500+ manuals available, e.g. find tool, mu4e library, and Ledger3.

Lastly, an quick note install-info. As shown above, it is used to install Info manuals, taking ledger3.info as an example, to install it requires

 
install-info ledger3.info /opt/homebrew/share/info/dir

After that, the following line is added to the /opt/homebrew/share/info/dir file.

 
* Ledger3: (ledger3).           Command-Line Accounting

a bit of explanation:

  • *: mark the starting of the entry
  • Ledger3: is the node/manual name
  • ledger3: inside of a parenthesis is the path to the Info file without extension.
  • Command-Line Accounting: is the description of the manual.
If you have any questions or comments, please post them below. If you liked this post, you can share it with your followers or follow me on Twitter!