Upgrading to Emacs 25, Problems and Solutions

We have pointed out elsewhere that Emacs 25 on Windows hung when editing files containing non-ASCII characters. Thus we refrained from upgrading to Emacs 25. (Not completely sure if all non-ASCII characters are bad. Examples of bad characters: “(╯°□°)╯︵ ┻━┻” and “土雞”.) Now we need to upgrade. After googling somewhat we found this link on sluggish behaviour of Emacs 25.

It was hinted that this was possibly a font problem. Quick Solution: just select a good font. There is a menu item for setting fonts in Emacs. We just used it to set font to Open Sans. Wow, Emacs 25 ran fast again! Oh, wait, something felt weird. After staring at the screen for 60 seconds, we noticed that Open Sans is not monospaced, so that code in the text file looked especially weird. lol. Unfortunately as soon as we picked a monospaced font, Emacs became sluggish again. It seemed that for monospaced fonts, Emacs fell back to a bad font to display those non-ASCII characters. To make Emacs fall back to a good font, one may use the function set-fontset-font. For details please refer to the Emacs manual. We added the following lisp code to our init file for Chinese characters. First just find a font that works by using the menu and then you can look up its name by C-u C-x = on the character. We found that the Adobe Heiti Std R font worked well for us. It also tells you the culprit encoding or script or whatever. For “土雞”, you can see that the two characters are in unicode-bmp and of the han script. We put “unicode-bmp” rather than “han” in the code below just to be more general.

(set-fontset-font "fontset-default" 'unicode-bmp
    "-outline-Adobe Heiti Std R-normal-normal-normal-sans-32-*-*-*-p-*-iso10646-1" 
    nil 'prepend)
    ;; custom-set-faces was added by Custom.
    ;; If you edit it by hand, you could mess it up, so be careful.
    ;; Your init file should contain only one such instance.
    ;; If there is more than one, they won't work right.
    '(default ((t (:family "Inconsolata" :foundry "outline" :slant normal
        :weight normal :height 120 :width normal)))))

The effect is that for anything not in unicode-bmp, the font Inconsolata is used and for characters in unicode-bmp Adobe Heiti Std R is used.

If you have the same problem, we hope this helps. We are sure you can adapt the method to suit your own languages.

We have had enough for keeping several copies of mingw on our hard drive. (git has a copy, emacs has a copy…) Then we learned about MSYS2. One first installs it and then uses pacman to download software packages that depend on it. This forced us to upgrade from Emacs 24.5 to 25.1 and forced us to look into the font problem.

Now Win 10’s default Japanese input method does not work well with Emacs 25. ;_;