diary at Telent Netowrks

Wayland Emacs - no more fuzzy fonts#

Sun, 06 Dec 2020 20:28:24 +0000

Advent of blog day 7 blah bah

I haven't touched a computer all day today except to buy wood screws, so this post is neither new now original.

I can't easily find any record of when it was I permanently switched from X11 to Wayland: I know I've tried it a number of times without success before eventually saying "screw it why don't I give in and use GNOME", and mostly because my laptop has a HiDPI screen and GNOME/Wayland seems (or at any rate at the time, seemed) to be the only platform with an option for 1.5x scaling.

(Rant: this "scaling" thing is a nonsense. A not-stupid system would define everything including window decorations and icons and the like using a resolution-independent measure - like "points" - and have no need for all this "actually this pixel is twice as big as a real pixel" rubbish which has always been and will always be a kludge. Bitmapped graphics in any sensible format already carry "x resolution" and "y resolution" metadata: scale them instead of scaling the entire universe they inhabit. End rant)

Anyway, I spent a subjectively long time with a nice crisp Wayland Firefox window, a nice crisp Wayland terminal window, and an ugly fuzzy scaled XWayland Emacs window, because Emacs - the released version, at least - uses X11 for some stuff even when you tell it to build with Gtk so it has to run in XWayland.

No more! https://github.com/masm11/emacs/ is a fork of Emacs to "pure Gtk", which means it works as a native Wayland app. Build it with the --with-pgtk configure flag. I've been using it for about six weeks, and in my experience it has been about stable enough for daily use - there have been a couple of times it's frozen with an eventual "not responding" dialog, but both times when I waited for a few tens of seconds it came back to life without my intervention.

One wrinkle you may want to be aware of if you use Magit (if you use git and you don't use magit, I would heartily endorse it) is that Emacs 28 changes the signature of server-switch-buffer meaning that "the with-editor advice server-switch-buffer--with-editor-server-window-alist has too few arguments", meaning that you can't commit anything. Check the Github issue for more details: if like me you don't want to go around upgrading a bunch of stuff to versions newer than those in NixOS Stable, the workaround is to redefine server-switch-buffer--with-editor-server-window-alist in your .emacs or somewhere

(require 'with-editor)

;; patch needed until new emacs 28-compatible release of magit/with-editor (defun server-switch-buffer--with-editor-server-window-alist (fn &optional next-buffer &rest args) "Honor `with-editor-server-window-alist' (which see)." (let ((server-window (with-current-buffer (or next-buffer (current-buffer)) (when with-editor-mode (setq with-editor-previous-winconf (current-window-configuration))) (with-editor-server-window)))) (apply fn next-buffer args)))

Goodnight!