Fedora KDE, Plasma Wayland, and Emacs

My previous attempts at using Fedora KDE with Wayland were pretty miserable, and KDE was pretty much unusable under Wayland with the nVidia drivers. Never tried it with the nouveau drivers at the time, but after dumping the nVidia drivers a while back, I thought I’d give KDE Plasma Wayland another shot.

I don’t know if Wayland support under KDE got better or if it’s because I’m not using the nVidia drivers anymore (probably both), but I’m finding Plasma is pretty snappy under Wayland.

I normally have emacs started as a systemd service (systemd --user start emacs) which runs emacs in daemon mode. Then I can just run emacsclient and have it connect to the already running emacs. One big issue I came across was not being able to run emacsclient and getting an *ERROR*: Display :0 can't be opened when I ran emacsclient -c from the command line.

The general consensus I found after searching the web for a while seemed to be that with systemd, the emacs daemon was starting before the graphical environment (Plasma), so display related environment variables weren’t available to emacs. Why this only happened with Plasma Wayland and not with Plasma X11, I don’t know.

When the emacs systemd service is enabled (systemd --user enable emacs), /usr/lib/systemd/user/emacs.service is symlinked into ~/.config/systemd/user/default.target.wants. My first attempt to fix the issue was to move emacs.service to graphical-session.target.wants, but that didn’t help.

Thinking about the apparent root cause of the issue, I found a Unix StackExchange post about how to have systemd services start in a particular order. I copied /usr/lib/systemd/user/emacs.service to ~/.config/systemd/user and linked it into graphical-session.target.wants. Then I added two lines to the [Unit] section:

Requires=plasma-kwin_wayland.service
After=plasma-kwin_wayland.service

This makes emacs.service a dependency of plasma-kwin_wayland.service and delays starting until after plasma-kwin_wayland.service has finished starting.

After rebooting and logging back in, I verified that the emacs daemon was still starting up (systemd --user status emacs) and was able to get emacsclient -c to bring up the emacs window. Everything was back to working the way I expected.

Building an emacs config

I have a long history of dabbling with emacs, having discovered it during my latter undergrad years (the emacs 18 era). I’d pick it up for a while, and then go back to whatever editor I happened to be using at the time. I liked emacs, but using it wasn’t anything that ever really stuck with me. Part of the reason was that I didn’t really have a solid use case for something like emacs. Emacs also has a not-so insignificant learning curve and getting into it can be pretty overwhelming and intimidating.

When I started on the PhD, I made a concerted effort to make emacs one of my primary tools, having learned about things like org-mode and distributions like spacemacs and doom-emacs from other people.

Org-mode makes setting up something like a research notebook pretty easy, and getting started is pretty simple. The basics are pretty easy to learn and when you want to do something more advanced, the documentation is very good.

Now, after spending the past couple of years of using emacs routinely, I’ve decided it’s time to learn more and start crafting my own emacs configuration. I’ll get to learn a little more elisp and dive into some of the packages I’ve become used to using. Might be something I keep and continue to evolve, or I might go back to spacemacs. Maybe I’ll try something else later.

It feels kind of like when a Jedi reaches the point in their training when they make their own light saber.

Dipping my toes into org-mode

I’ve taken one of the older but still very capable laptops in my collection and put it to use as my “school” computer.  The goal is to have something I can lug around and use for research, number crunching, and my research notebook.  Then I don’t have to worry about trying to keep all that stuff in sync if I were to use my work and home desktop computers.

My handwriting can get pretty messy, and even I have a hard time reading my own handwriting sometimes.  I decided I wanted to do some kind of electronic lab notebook to keep my research notes, data, bibliography, and whatnot. 

I’ve been making an effort to spend more time in Emacs, and I have a few developer friends who rave about org-mode, so it seemed like a promising choice.

A quick Google search returned a few blog posts by people who are already using org-mode for research lab notes and writing papers and other research related tasks.  Plenty of prior work out there to learn from as I develop my own workflow.