Emacs

Jump to: navigation, search
GNU Emacs



Developer: GNU Project
License: GPLv3+
Web: http://www.gnu.org/software/emacs/


GNU Emacs is an extensible, customizable text editor—and more. At its core is an interpreter for Emacs Lisp, a dialect of the Lisp programming language with extensions to support text editing.

Overview

The features of GNU Emacs include:

  • Content-sensitive editing modes, including syntax coloring, for a wide variety of file types including plain text; source code (for pretty much any programming/scripting language you can imagine); LaTeX.
  • Complete built-in documentation, including a tutorial for new users.
  • Support for many languages and their scripts, including all the European “Latin” scripts, Russian, Greek, Japanese, Chinese, Korean, Thai, Vietnamese, Lao, Ethiopian, and some Indian scripts.
  • Highly customizable, using Emacs Lisp code or a graphical customization interface.
  • Games such as Tetris, Snake, etc.
  • Spell checking as you type or when required (can also just check spelling of comments when in programming modes) with ability to add words.
  • A large number of extensions that add other functionality, including a project planner, mail and news reader, calculator (simple or programmable), PDF viewer, web browser, debugger interface, calendar, twitter client and more. Many of these extensions are distributed with GNU Emacs; others are available separately.

Commands

After learning a few basic keystroke commands, you can become a lot more productive in Emacs.
When typing a command you can use [TAB] completion, which will complete the command name for you or list the possible commands.

Guide to keys

C-x = (hold [CONTROL], press x, then release [CONTROL])
C-x C-s = (hold [CONTROL], press x, then press s, then release [CONTROL])
M-2 = (hold [ALT], press 2, then release [ALT])
[note M = META usually [ALT] or [ESCAPE] when using [ESCAPE] as META release it before pressing the next key (i.e. M-2 = press and release [ESCAPE] then press 2)].

Written commands

Sometimes the required action doesn't have an associated key-sequence, in these cases the written command must be used (M-x is pressed followed by the command):

ispell-buffer = (hold [ALT], press x, release [ALT], then type "ispell-buffer" in the mini buffer)

Lookup table

The following is a lookup table of basic commands. Emacs has so many commands it would be impossible to list them all, but hopefully this will be enough to get you started.

Action Key-sequence Command
Open file C-x C-f find-file
Close C-x C-c save-buffers-kill-emacs
Save file C-x C-s save-buffer
Save as C-x C-w write-file
Page down C-v scroll-up
Page up M-v scroll-down
Goto top M-< beginning-of-buffer
Goto end M-> end-of-buffer
Goto line M-g g goto-line
Goto start of line C-a beginning-of-line
Goto end of line C-e end-of-line
Search forwards C-s search term isearch-forward search term
Repeat last search forwards C-s C-s isearch-repeat-forward
Search backwards C-r search term isearch-backward search term
Repeat last search backwards C-r C-r isearch-repeat-backward
Cancel command C-g keyboard-quit
Kill line C-k kill-line
Kill sentence M-k kill-sentence
Yank last kill C-y yank
Yank previous kill M-y yank-pop
Split window horizontally C-x 2
Split window vertically C-x 3
Swap active window C-x o
Merge windows C-x 1
List buffers C-x C-b list-buffers
Switch to buffer C-x b switch-to-buffer
Switch active buffer left C-x [LEFT] previous-buffer
Switch active buffer right C-x [RIGHT] next-buffer
Kill Buffer C-x k kill-buffer
Spell-check current buffer none ispell-buffer
Spell-check current word none ispell-word
Indent code C-M-\ indent-region
Goto matching closing bracket C-M-f
Goto matching opening bracket C-M-b
Comment a region M-; comment-or-uncomment-region

Performing other tasks

To use Rmail or Gnus you will have to set up the relevant settings file: ~/.emacs

E-mail

Reading

Rmail

The simplest (to set up) E-mail client in Emacs, is Rmail, to invoke Rmail press:

M-x rmail

To use Rmail for reading E-mail, other than system mail, you will have to use a program to fetch your E-mail from the server, such as fetchmail or offlineimap.

Gnus

Another option is Gnus, which is primarily a newsreader, but can also be used for reading E-mail, and can be configured to get your E-mails from the server without the aforementioned mail fetching programs, but will take a little more setting up than Rmail.

Sending

Mail

Mail can send your E-mail, which is invoked with:

M-x mail 

You can also specify your: E-mail address, name, signature, etc in your ~/.emacs file, so that it is already filled in when you start composing an E-mail.

Newsreader

Gnus

Gnus is an outstanding newsreader and can be started by pressing:

M-x gnus

To use Gnus, you will first have to setup your ~/.gnus.el file, a brief guide to Gnus is available at: Gnus

IRC client

ERC is an Emacs IRC client which can be started with:

M-x erc

You must first add the following to your ~/.emacs file:

(require 'erc)

Getting Started

When you start ERC, you will be asked for some information:

IRC server:

irc.freenode.net

IRC port:

6667

Nickname:

your nickname

Password:

your password (optional)

The commands for ERC are just standard IRC commands.


Troubleshooting

Attempts to install or refresh packages from GNU ELPA results in 'failed to download gnu archive'.

The GNU ELPA repository is the default repository GNU Emacs pulls from. The GPG keys used by this repository were changed in September, 2019. As such, versions of Emacs released before Sep. 2019 face the issue of not being able to install packages from the repository due to signature verification errors.

This issue may be encountered by users of openSUSE Leap 15.2, as the version available in the repository is Emacs 25.3.1. Emacs 25.3 was released in 2017.

The most convenient solution for users experiencing this issue would be to download the gnu-elpa-keyring-update package from the website, which, when installed, would update the GPG keys stored by your installation of emacs, and allow you to access the packages again.

Simply download the tar file from the website, and run the command

M-x package-install-file

After pressing enter, Emacs will prompt you for the location of the downloaded package.

This method can also be used as a workaround if you wish to install some packages but haven't updated the GPG keys of your installation.


See also


External links