For the longest time I wanted to be able to write “smart quotes” from my GNU/Linux machines1. I managed to set this up on Fedora quite easily from Gnome’s settings (or the Tweak tool?) by setting the Compose key. The problem is that I rarely use Fedora, and most of my computing is done on machines that use dwm and GNU Guix System, so I need a solution that is Desktop-Environment–agnostic.
This works if you’re using an X server. I don’t use any Wayland WMs so I don’t know what the solution is for that.
To be able to write characters that are not on our keyboards we could
use the “Compose key”. To use it, we need to tell the computer what it
is. We’ll use
xmodmap for that, which will require a key name. That
can be obtained with
Fire up an
xev window instance from your terminal and press the key
you want to use as the future Compose key. The output should look like this:
KeyRelease event, serial 32, synthetic NO, window 0x1c00001, root 0x3b7, subw 0x0, time 43382046, (1046,262), root:(1059,306), state 0x0, keycode 135 (keysym 0xff20, Menu), same_screen YES, XLookupString gives 0 bytes: XFilterEvent returns: False
You need to extract the name of the key, in my case “Menu” (from this
keycode 135 (keysym 0xff20, Menu)). After this, you can set your
xmodmap -e "keysym Menu = Multi_key"
You’ll probably have a list of the available key combinations that use
the Compose key in
en_US.UTF-8 with your locale). If you’re using Guix, this
path will look like this:
You can also define new sequences in the
~/.XCompose file, like the
ones in the default configuration.
Important! Do not forget to use
include "%L" at the top of your
~/.XCompose file, to make the default combinations available.
Now you’ll probably be able to type smart quotes using
Compose + <
Compose + >) and then
A nice thing about exporting from Org mode is that it can automatically convert “dumb” quotes into the smart ones.