44

When posing questions on this site, people sometimes talk about "windows" when they mean "frames," and "buffers" or "files" when they mean "windows." So:

Q: What is the difference between a buffer, a file, a window, and a frame?

(I'm posing this question in the spirit of this Q&A combo: to promote correct use of the terms.)

Dan
  • 32,584
  • 6
  • 98
  • 168

2 Answers2

55

Emacs predates contemporary window-based operating systems, so its terminology also predates the current terms. Unfortunately, it means that new users and experienced users sometimes have trouble making themselves understood to each other, since they're using the terms in different ways.

In brief:

  • "Frames" are to Emacs what "windows" are to everything else
  • "Windows" are subdivisions of frames (think "window panes")
  • "Buffers" hold the contents you display/edit in windows
  • When we "open a file," we are, technically, opening a buffer that "visits" that file

The following annotated screenshot illustrates these points.

annotated screenshot

  • This Emacs session has two frames (blue outline) -- what, for most other programs, we would call "windows."
  • There are a total of three Emacs windows (red outline) open: one in the left frame, and two in the right frame.
  • The single window in the left frame is displaying the scratch buffer. It is not connected to (i.e., visiting) any file.
  • The top window in the right frame is displaying the buffer example.org, which is, in turn, visiting the file ~/path/to/example.org.
  • The bottom window in the right frame is displaying the indirect buffer example2, which has the same contents as the buffer example.org in the top window.

So here's the summary:

  • frames are what you call "windows" in basically all of your other software
  • windows are divisions of frames
  • buffers hold the stuff that you display in windows
  • buffers may or may not be visiting (i.e., be associated with) a file
Dan
  • 32,584
  • 6
  • 98
  • 168
  • 1
    Fantastic introductory summary, great graphic. For the full pedantic detail, there's one other thing to know about Emacs "frames": they extend the graphic-user-interface concept of multiple independent overlapping floating windows to the text-user-interface, that is, the terminal. So when running Emacs in the terminal, you *still* have frames at your disposal, it's just that (in contrast to a GUI) you can only see one at a time (unless you use tmux or GNU Screen). In practice you will usually only use and want one frame when running Emacs in the terminal, but the option is still there. – Phil Hudson Nov 24 '21 at 09:30
  • @PhilHudson: great addition, thanks. I only ever use Emacs in the GUI, so didn't know about the frames-on-the-terminal point you added. – Dan Nov 24 '21 at 12:40
11

I would point readers to (1) The glossaries of Emacs Wiki and (2) the Emacs manual for such information.

Also to the EmacsWiki Newbie page, which has lots of good introductory information about such things. And to the Emacs manual in general, which also introduces such things well: C-h r then i followed by typing whatever you want to learn about, e.g., window.

The EmacsWiki page linked from its glossary for entry window includes this graphic, which shows a frame with 3 windows, and indicates the menu bar for the current buffer and the mode lines of the windows. The 3 buffers shown in the windows are named *Help*, drews-lisp-20, and shrink-fit.el.

Emacs frame, windows, and window parts

(There are other combinations of things that could be asked about, BTW, if one really wants to ask such questions.)

Drew
  • 75,699
  • 9
  • 109
  • 225
  • 2
    +1 Pointing readers to the glossaries and the Emacs manual is the right answer for such standard answers so as to avoid misleading new users. – Emacs User Apr 29 '16 at 01:28