GNU Emacs

From Gentoo Wiki
Jump to: navigation, search

GNU Emacs is a powerful, extensible, self-documenting text editor. It is released by the Free Software Foundation and has been under development since 1976. In Gentoo, GNU Emacs is maintained by the team of the same name, which can be reached through Detailed developer information can be found on the project page.


USE flags

USE flags for app-editors/emacs-vcs The extensible, customizable, self-documenting real-time display editor

Xaw3d Add support for the 3d athena widget set global
aqua Include support for the Mac OS X Aqua (Carbon/Cocoa) GUI global
athena Enable the MIT Athena widget set (x11-libs/libXaw) local
cairo Enable support for the cairo graphics library global
dynamic-loading Enable loading of dynamic libraries at runtime local
games Support shared score files for games local
gconf Use gnome-base/gconf to read the system font name local
gfile Use gfile (dev-libs/glib) for file notification local
gsettings Use gsettings (dev-libs/glib) to read the system font name local
gtk3 Prefer version 3 of the GIMP Toolkit to version 2 (x11-libs/gtk+) local
gzip-el Compress bundled Emacs Lisp source local
imagemagick Use media-gfx/imagemagick for image processing local
libxml2 Use dev-libs/libxml2 to parse XML instead of the internal Lisp implementations local
m17n-lib Enable m17n-lib support global
mailutils Retrieve e-mail using net-mail/mailutils instead of the internal movemail substitute local
motif Add support for the Motif toolkit global
png Add support for libpng (PNG images) global
source Install C source files and make them available for find-function local
threads Add elisp threading support local
tiff Add support for the TIFF image format global
toolkit-scroll-bars Use the selected toolkit's scrollbars in preference to Emacs' own scrollbars local
wide-int Prefer wide Emacs integers (typically 62-bit). This option has an effect only on architectures where "long" and "long long" types have different size. local
xft Build with support for XFT font renderer (x11-libs/libXft) global
xpm Add support for XPM graphics format global
xwidgets Enable use of GTK widgets in Emacs buffers (requires GTK3) local

USE flags for toolkits gtk, motif, and athena are mutually exclusive. Generally, USE="gtk" is a good choice. However, if intending to use Emacs as a daemon, USE="motif -athena -gtk -Xaw3d" or USE="athena Xaw3d -gtk -motif" is recommended instead because of bug #292471. USE="athena Xaw3d" resembles USE="gtk" very well.


root #emerge --ask app-editors/emacs

Several versions side-by-side

In Gentoo, several Emacs versions can be installed on a system simultaneously. The upstream version already installs elisp and data files into versioned subdirectories. To avoid file collisions between slots, in the Gentoo installation also binaries and man pages are suffixed with their corresponding version number.

The eselect module from app-eselect/eselect-emacs can be used to link /usr/bin/emacs and its auxiliary programs to the ones belonging to the desired Emacs version. Consult the eselect user guide for details on eselect.


Emacs can be customized by clicking through the GUI (use M-x customize-group RET) or by using the ~/.emacs configuration file which is written in Emacs Lisp, Emacs' own Lisp dialect.


For a quick-start documentation, type in Emacs: C-h t (Ctrl+h followed by t). For further help on how to use Emacs, start emacs and type C-h r (Ctrl+h followed by r). To exit Emacs, type C-x C-c (Ctrl+x followed by Ctrl+c).

Additional elisp packages

Emacs has lots of additional packages written in elisp. There is a number of ways of their distribution, but the standard one is package.el nowadays. On Gentoo in can be used both on per-user and system-wide way.

To install package per-user use package.el distributed with GNU Emacs.

To install elisp packages system-wide under the Portage control you can use gs-elpa. Read layman documentation before using it, as gs-elpa represents ELPA repositories as layman overlays. It currently supports 4 repositories: gnu-elpa, marmalade, melpa and melpa-stable.

When the layman setup works, install gs-elpa:

root #emerge --ask app-portage/gs-elpa

After it you can start adding elisp repos and emerging packages, e.g.:

root #layman -L
root #layman -a gnu-elpa
root #layman -a melpa-stable
root #emerge --ask app-emacs/starter-kit app-emacs/starter-kit-bindings app-emacs/starter-kit-eshell app-emacs/starter-kit-lisp
Always add gnu-elpa repository first, as other repos depend on it.

Bugs related to gs-elpa should be reported on its issue tracker.

If you ever find bugs like [1], you can exclude packages from dependencies adding their name to the "external" object in the "common-config" section of /etc/g-sorcery/gs-elpa.json config file. For the example issue it would be (together with already added packages):

   "external": {"emacs": "virtual/emacs", "cl-lib": "virtual/emacs", "eieio": "virtual/emacs"}

See also