Emacs: Major Mode

By Xah Lee. Date: . Last updated: .

What is Major Mode

Example of major modes:

Technical Meaning of Emacs Major Mode

For elisp coders, technically a major mode means:

〔see Elisp: Create Major Mode

Switch to a Major Mode

Each major mode has a associated command. e.g. shell, js-mode, python-mode.

The command to turn on a major mode usually ends in “-mode”, but not always.

To switch to a major mode, just Alt+x major_mode_command_name

When you open a file, a chosen major mode is automatically turned on, depending on file name or other ways. 〔see Emacs Init: Set Default Major Mode

Find the Name of Current Major-Mode

The current major mode's name is stored in a variable major-mode

major-mode
A Buffer Local Variable . Value is Symbol of current buffer's major mode. 〔see Emacs: Show Variable Value

Major Mode's Display Name

Each major have a display name (a easy-to-understand name, or short name), that is displayed in Mode Line

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

Emacs, major mode, hook

Emacs Principle