Emacs: What is Major Mode

By Xah Lee. Date: . Last updated: .

What is a Major Mode

Each buffer/file is associated with one major mode.

A “major mode” is a collection of emacs behaviors, designed for specific task.

Example of major modes:

Switch to a Major Mode

Each major mode typically has a associated command. e.g. Alt+x shell. If a mode is named “xx-mode”, the command to turn it on is usually named “xx” or “xx-mode”.

A proper major mode is usually automatically turned on when you open a file. [see Emacs: Set Default Major Mode]

fundamental-mode

The most basic major mode is fundamental-mode. If you want to “turn off” all major modes, type Alt+x fundamental-mode.

What is current major-mode

Current major mode's nick name shows in the mode line:

emacs major mode mode line 2022-05-15 Gxv4
major mode display name in mode line 2022-05-15

The current major mode's actual emacs lisp symbol is stored in a variable major-mode . This is more useful for emacs init and coding.

major-mode
A Buffer Local Variable . Value is Symbol for current buffer's major mode. [see Emacs: Show Variable Value, List Variables]

Major Mode, Minor Mode, Minibuffer, Hook