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 “xyz-mode”, the command to turn it on is usually named “xyz” or “xyz-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]

List Major Modes

Alt+x apropos-command, then type “-mode”. (it's not a complete list, because some major mode's name do not end in “mode”) [see Emacs: Search Function/Command, List Commands]

Or, look at the variable auto-mode-alist.

auto-mode-alist
Alist of file name patterns vs corresponding major mode functions. [see Emacs: Show Variable Value]

Major Mode and Minor Mode

ErgoEmacs mascot-s276x226
Buy Xah Emacs Tutorial

Emacs Init

Init Basics

Keys

Font

Text Editing

Completion

File

Restore Things

Backup/AutoSave

Line

Appearance

Misc

Advanced Init Tips

packages