Emacs - Basic Configuration
Table of Contents
As is well-known, Emacs is a powerful editor. Due to its infinite customizability and extensibility, in some sense, it is an operation system (OS) rather than an editor. This page briefly introduces how to customize it.
Set values for predefined variables
(setq variable value)
Bind shortcut keys
Set global shortcut key
(global-set-key key command)
where key
is shortcut1, e.g. M-SPC
, <f7>
, and command
is the command name with a prefix of single quotation mark.
Set shortcut key for specific modes
(define-key keymap key command)
where keymap
is associated to some mode, e.g. c-mode-map
. Usually, each mode has its own keymap, which is the mode name appended with -map
.
Mode & hook
Emacs uses different modes to provide different editing environment. Generally, each file type has its own major-mode 2 and one or more minor-mode 3. Usually, each major-mode provides hook, mode name appended with -hook
. When entering some major-mode, the functions in the corresponding hook will be provoked.
Third party extension
After the installation, the configuration includes two steps
(add-to-list 'load-path path-of-the-extension) (require 'extension-name)