15 October 2021 Peter Smith

Emacs and macrons

A bit better typograghy

I seem to be typing more words and expressions in Māori nowadays. That sees me wanting to use macrons on letters. (i.e., ā Ā ē Ē ī Ī ō Ō ū Ū).

When running Windows 10, that's not too hard; I select a Māori keyboard and away I go.

However, that's not the case under Emacs. I run Emacs under WSL2, and although my keyboard on the 'Windows' side says "English (New Zealand) Maori keyboard", Emacs doesn't see that. So I need to use short-cuts, etc., when wanting to type letters with macrons.

Now I can do it using the good old C-x 8 to get to all (and any) letters/alphabets. But it's tiresome.

Enter Xah Lee and his Unicode tutorial. I used his approach of binding some keys to insert math symbols, and changed it to insert characters with macrons.


  ;; set keys to insert macrons
  (define-key key-translation-map (kbd "<f9> a") (kbd "ā"))
  (define-key key-translation-map (kbd "<f9> A") (kbd "Ā"))
  (define-key key-translation-map (kbd "<f9> e") (kbd "ē"))
  (define-key key-translation-map (kbd "<f9> E") (kbd "Ē"))
  (define-key key-translation-map (kbd "<f9> i") (kbd "ī"))
  (define-key key-translation-map (kbd "<f9> I") (kbd "Ī"))
  (define-key key-translation-map (kbd "<f9> o") (kbd "ō"))
  (define-key key-translation-map (kbd "<f9> O") (kbd "Ō"))
  (define-key key-translation-map (kbd "<f9> u") (kbd "ū"))
  (define-key key-translation-map (kbd "<f9> U") (kbd "Ū"))

The result is to type the Ā, I just press f9 A; to get an ā, I press f9 a. That's about as easy as I can imagine it being.