Emacs: What's Major Mode
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:
- programing languages:
dired[see Emacs: File Manager, dired]
shell[see Emacs: Run Shell in Emacs]
image-mode[see Emacs: View Image File]
eww[see Emacs: Eww Web Browser]
Switch to a Major Mode
Each major mode typically has a associated command.
Just call the command.
For example, 【Alt+x】
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
So, in a sense if you want to “turn off” all major modes, just Alt+x
How to Get a List of Major Modes
apropos-command, then type “-mode”. (it's not a complete list, because some major mode's name does not end in “mode”)
auto-mode-alist. It'll list major modes associated with file name extension.
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”.
Set File to Open in a Major 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 init file
- Install Packages
- Install Package Manually
- Define Keys
- M-x customize
- What's Major Mode?
- What's Minor Mode?
- Set File to Open in a Major Mode
- Organize Init File
- Byte Compile Elisp
- What's Hook?
- Environment Variables in Emacs
- Set Default Window Size
- Font Setup
- Set Color Theme
- Turn Off Auto Backup
- Check OS, Version, Host Name
- Check Defined/Loaded