Gentoo Development Guide

Configuring GNU Emacs

UTF-8 support

Emacs 21 has built-in Unicode support, and (fortunately) it supports UTF-8 far better than UTF-16 and other variants. Some extensions to this functionality are available in the package app-emacs/mule-ucs, although this is not necessary (and I would not recommend it unless absolutely necessary, as the potential for unexpected bugs or quirky behaviour is increased). The best solution is using Emacs 22 or higher as encoding support has been greatly improved.

In versions of Emacs below 21.3, and a non-UTF-8 locale is used when opening a UTF-8 file, auto-detection of the character set is effectively disabled and characters will be garbled. The UTF-8 character set can be preferred with M-x prefer-coding-system and entering utf-8 when prompted. Otherwise, it is necessary to tell Emacs that a UTF-8 file is being opened by prefixing the C-x C-f or C-x C-v command with C-x C-m c utf-8 RET. As a diagnostic measure, the coding system currently in use can be determined with C-h C <RET>.

Newer Emacs versions will autodetect the coding system for given text.

If it is desired to prefer UTF-8 to the regular character set, the following can be used inside of the Emacs startup file:

    (prefer-coding-system 'utf-8)

For specifying coding system to use on a per-file basis, the modify-coding-system function can be used.

Configuration tips and tricks

Files must end with a newline, in order to let tools like diff operate properly. To avoid accidental deletions, setting (setq require-final-newline 'ask) in your startup file will automatically check for the existence of it and ask you to add one.

Other useful settings can be disabled backup files (by (setq make-backup-files nil) and (setq vc-cvs-stay-local nil)), so you don't clutter CVS directories and confuse repoman with it (by adding unnecessary entries into a Manifest file e.g.). Emacs can even contact the outside world by using the X servers clipboard abilities when yanking, which is activated by (setq x-select-enable-clipboard t).

Gentoo specific additions

For easy editing of ebuilds an Emacs mode has been created, which is found in the package app-emacs/gentoo-syntax. It supports ebuilds, eclasses and eselect files, highlights keywords and also provides a hook for your own customisation.