Configuring GNU Emacs

UTF-8 support

GNU Emacs has built-in Unicode support, and since version 23 it uses UTF-8 as its internal encoding. It is recommended to start Emacs from within a UTF-8 locale which will control the default coding system.

Emacs will normally autodetect the coding system for given text. In rare cases it may be 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.

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

    (prefer-coding-system 'utf-8)

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. Note that many modes for programming languages will add the newline automatically before saving the file.

Other useful settings can be disabled backup files (by (setq make-backup-files nil)), so you don't clutter the git repository 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/ebuild-mode. It supports ebuilds and eclasses, highlights keywords and also provides a hook for your own customisation.

Package app-emacs/nxml-gentoo-schemas improves editing of Gentoo specific XML files (e.g., metadata.xml). It provides auto-completion and on-the-fly validation, using a RELAX NG schema for each document type.