Chapter 2: The Emacs Philosophy
Or: Why Everything Is a Buffer and That’s Actually Genius
Imagine if every window in your house was actually just a different view of the same infinite room. You could look through the kitchen window and see your documents. Look through the bedroom window and see your email. Look through the bathroom window and see… well, maybe IRC chat. That’s Emacs.
This chapter is about understanding why Emacs works the way it does. Once you grok this, everything else makes sense. Skip this chapter, and you’ll forever be fighting against Emacs instead of flowing with it.
The Buffer: Emacs’s Universal Container
In your IDE, you have files. In Emacs, you have buffers.
“But wait,” you say, “when I open a file, isn’t that the same thing?”
No. And this difference is everything.
A buffer is just a chunk of text that Emacs is managing. It might be:
- A file you’re editing
- The output of a command
- Your email inbox
- A chat room
- A terminal
- A web browser (yes, really)
- The Emacs tutorial
- This help documentation you’re reading
- A game of Tetris (I’m not joking)
🤔 Why Though? Because in Emacs, everything is text, and all text lives in buffers. This means you can use the same editing commands on your code, your email, your chat messages, and your git commit messages. Learn once, use everywhere.
The Three-Layer Cake: Frames, Windows, and Buffers
This is where newcomers get confused, because Emacs uses these words differently than every other program:
- Frame: What you call a “window” (the OS-level window with minimize/maximize buttons)
- Window: A viewport into a buffer (what you’d call a “pane” or “split”)
- Buffer: The actual content (kind of like a “tab” but not really)
Let me blow your mind: You can have the same buffer displayed in multiple windows. At the same time. Even in different frames. Change the text in one, it changes in all of them, because they’re all just views of the same buffer.
🚸 IDE Refugee Note: In VS Code, you have tabs that contain files. In Emacs, you have buffers that can be displayed in zero, one, or many windows. This seems insane until you realize you can have your code in one window and scroll to a different part of the same file in another window. Or have your README.md open in two windows with different formatting views.
Let’s See This in Action
Try this experiment:
- Open a file:
C-x C-f test.txt - Type some text: “Hello from buffer land!”
- Split the window horizontally:
C-x 2 - You now have the same buffer in two windows
- In the bottom window, add more text
- Notice it appears in both windows—they’re the same buffer!
- Switch the bottom window to a different buffer:
C-x b *scratch* - Now you have two different buffers visible
- Split again:
C-x 3(vertical split) - Create a new frame:
C-x 5 2
Congratulations, you’re now looking at multiple windows across multiple frames showing multiple buffers. You’ve entered the Matrix.
The Buffer List: Your Mission Control
See all your buffers:
C-x C-b
This opens the buffer list. It’s not just a list—it’s a buffer itself! Which means you can:
- Search it (with
C-s) - Edit it (though that’s advanced)
- Navigate it with normal movement commands
🎯 Pro Tip: Mark buffers for deletion with d, then execute with x. It’s like a file manager, but for buffers.
Special Buffers: The Hidden World
Buffers whose names start with * are special. They’re usually not associated with files:
*scratch*- Your playground (we’ll talk about this)*Messages*- Everything Emacs has told you*Completions*- Autocomplete suggestions*Help*- Help information*Buffer List*- The list of buffers
These buffers are part of Emacs itself. They’re how Emacs talks to you.
The Minibuffer: The Command Line That Isn’t
At the bottom of your Emacs frame is a single line that usually shows something like:
-UUU:----F1 test.txt All L1 (Text)
Below that, when you run commands, a space opens up. That’s the minibuffer. It’s—wait for it—also a buffer! A very special one where you enter commands, search terms, and filenames.
🤔 Why Though? Because if it’s a buffer, you can use all your editing commands in it. Made a typo in a long file path? Use normal editing commands to fix it. Want to paste something? Same commands work. It’s buffers all the way down.
Major Modes: One Buffer, One Personality
Every buffer has exactly one “major mode” that defines its primary behavior:
python-modefor Python filesmarkdown-modefor Markdownorg-modefor Org filesdired-modefor directory listingsmagit-modefor git operations
The major mode determines:
- How syntax highlighting works
- What special commands are available
- How indentation behaves
- What the Tab key does
See your current major mode in the modeline (that status bar at the bottom of each window).
Minor Modes: The Mix-ins
While a buffer has one major mode, it can have many minor modes. These add functionality:
line-number-mode- Show line numbersauto-fill-mode- Wrap text automaticallyflyspell-mode- Spell checkingcompany-mode- Autocompletion
Toggle them on and off:
M-x line-number-mode- Toggle line numbersM-x auto-fill-mode- Toggle auto-fill
🎯 Pro Tip: C-h m shows all active modes and their key bindings. It’s like a personalized manual for your current buffer.
The Scratch Buffer: Your Digital Napkin
When Emacs starts, it creates a buffer called *scratch*. This is your playground. It’s not connected to a file. It’s just… there.
;; This buffer is for text that is not saved, and for Lisp evaluation.
;; To create a file, visit it with C-x C-f and enter text in its buffer.
The scratch buffer starts in lisp-interaction-mode. Type some Elisp and press C-j to evaluate it:
(+ 2 2) C-j
4
🚸 IDE Refugee Note: This is like having a REPL always available, but for your editor’s programming language. Imagine if VS Code had a JavaScript console where you could modify VS Code itself while it’s running. That’s what this is.
The Philosophy in Practice: Why This Matters
Here’s where it all comes together. Because everything is a buffer:
- Universal Operations: Learn one set of commands, use them everywhere
- Composability: Any tool that works on buffers works on everything
- Introspection: Emacs can examine and modify itself
- Persistence: Buffers exist independently of windows and frames
- Flexibility: Display anything anywhere in any configuration
Real-World Example: The Power of Buffers
Let’s say you’re writing code and need to:
- Look at documentation
- Run tests
- Check git status
- Read email about a bug report
In a traditional IDE:
- Switch to browser for docs
- Switch to terminal for tests
- Switch to git client
- Switch to email client
In Emacs:
C-x 2to split windowC-h f function-namefor docs (opens in new window)M-x compileto run tests (output in a buffer)M-x magit-statusfor git (in a buffer)M-x mu4efor email (in a buffer)
All without leaving Emacs. All using the same key bindings. All searchable with the same commands. All copyable with the same keys.
The Kill Ring: Copy/Paste on Steroids
Since we’re talking philosophy, let’s discuss the kill ring. In Emacs:
- “Kill” (
C-w) means cut - “Yank” (
C-y) means paste - Copy is
M-w(kill-ring-save) — it saves the region to the kill ring without removing it
But here’s the beautiful part: Emacs remembers everything you’ve killed in a ring. Kill five different things, then cycle through them when yanking:
- Kill some text:
C-k - Kill more text:
C-k - Kill even more:
C-k - Yank the last:
C-y - Cycle to previous:
M-y - Keep cycling:
M-y
It’s not a clipboard; it’s a clipboard history that you can browse.
🤔 Why Though? Because when Emacs was created, there was no system clipboard. So they invented something better. Now we’re stuck with the names “kill” and “yank”, but we get infinite clipboard history, so it’s a fair trade.
Regions and Marks: Selection That Makes Sense (Eventually)
In Emacs, you don’t “select” text. You set a “mark” and move the “point” (cursor). The area between them is the “region”.
- Set mark:
C-<space> - Move cursor to extend region
- Do something with region (kill it, copy it, indent it, etc.)
Or use C-x h to mark the whole buffer. Because sometimes you just want it all.
Recursive Editing: Inception for Text
Sometimes, while you’re doing something in the minibuffer, you need to do something else. Emacs lets you recursively enter another command. You’ll see [...] in the modeline when you’re in a recursive edit.
Don’t panic. C-] gets you out. Or C-g if you want to abort completely.
This is like having multiple command lines stacked on top of each other. It sounds confusing, but it’s occasionally brilliant.
Your Growing Mental Model
By now, you should be starting to see Emacs differently:
- It’s not a text editor with features bolted on
- It’s a Lisp machine that happens to edit text
- Everything is text in buffers
- Buffers can be displayed in windows
- Windows live in frames
- Commands operate on buffers, not files
- The same commands work everywhere
This mental model is why Emacs users seem like they’re in a cult. Once you internalize this, every other editor feels like it’s fighting you.
Practical Exercises
🎮 Try This:
- Buffer Gymnastics:
- Open 5 different files
- Use
C-x bwith partial names to switch between them - Kill a buffer with
C-x k - Recover it from the recent files with
C-x C-fand arrow keys
- Window Management:
- Split horizontally:
C-x 2 - Split vertically:
C-x 3 - Delete other windows:
C-x 1 - Delete this window:
C-x 0 - Cycle through windows:
C-x o
- Split horizontally:
- The Same Buffer Trick:
- Open a long file
- Split the window
- Scroll to different parts in each window
- Edit in one, watch it change in the other
- Special Buffer Tourism:
- Visit
*Messages*buffer - Check out
*scratch* - Look at
*Buffer List* - Try
M-x list-packages(spoiler for Chapter 5!)
- Visit
What’s Next?
Now that you understand the Emacs philosophy, Chapter 3 will teach you to move through text like a wizard. We’ll cover the movement commands that make Emacs users look like they’re playing a text-based video game.
But here’s the secret: once you understand buffers, windows, and frames, you’ve already learned the hard part. Everything else is just memorizing keys.
“Emacs is not a mere editor; it is a way of life.” —Someone who understood buffers
Chapter 2 Summary
- Buffers are everything—files, processes, help, emails, everything
- Windows are viewports into buffers
- Frames are what you call windows (OS-level)
- Major modes give buffers personality
- Minor modes add features
- Everything is text and all text is in buffers
- Learn once, use everywhere—the same commands work in all contexts
Once you stop thinking “files” and start thinking “buffers,” you’ll understand why we never leave.