Emacs: What's Major Mode

By Xah Lee. Date: . Last updated: .

What's 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. Just call the command. For example, 【Alt+xshell.

Typically, if a mode is named “xyz-mode”, the command to turn it on is named “xyz” or “xyz-mode”.

To turn “off” a major mode, just switch to another major mode. There's always one major mode on.


The most basic major mode is fundamental-mode.

So, in a sense if you want to “turn off” all major modes, just Alt+x fundamental-mode.

How to Get a List of Major Modes

Alt+x apropos-command, then type “-mode”. (it's not a complete list, because some major mode's name does not end in “mode”)

Or, Alt+x describe-variable, then type auto-mode-alist. It'll list major modes associated with file name extension.

[see Emacs: Set File to Open in a Major Mode]

What's Current Major Mode?

Current buffer's major mode's name is stored in the variable major-mode.

To find out its value, Alt+x describe-variable, then type “major-mode”.

emacs find current major mode
M-x describe-variable, then type “major-mode”.

Set File to Open in a Major Mode

Emacs: Set File to Open in a Major Mode

Minor Modes

Emacs: What's Minor Mode

Writing a Toggle Mode Command

You can write a toggle command that toggles a set of minor modes or other things such as switching between 2 fonts. See: Elisp: How to Write a Toggle/Cycle Command

Emacs Customization

  1. Emacs init file
  2. Install Packages
  3. Install Package Manually
  4. Define Keys
  5. M-x customize
  6. What's Major Mode?
  7. What's Minor Mode?
  8. Set File to Open in a Major Mode
  9. Organize Init File
  10. Byte Compile Elisp
  11. What's Hook?
  12. Environment Variables in Emacs
  13. Set Default Window Size
  14. Font Setup
  15. Set Color Theme
  16. Turn Off Auto Backup
  17. Check OS, Version, Host Name
  18. Check Defined/Loaded

If you have a question, put $5 at patreon and message me.
Or Buy Xah Emacs Tutorial
Or buy a nice keyboard: Best Keyboards for Emacs


Emacs Lisp