2

According to the Emacs manual, “the command M-x diff-buffers compares the contents of two specified buffers”. But Aquamacs (Aquamacs 3.2 GNU Emacs 24.4.51.2, macOS 10.14.4) gives me no match for this command. What can I use instead?

2 Answers 2

3

diff-buffers is a new command in Emacs 27.1.

Do you really want to see the diff output, rather than compare the buffers? Emacs has a nice built-in interface to compare two files: Ediff. (Note that Ediff has its own manual, separate from the Emacs user manual, even though it's been bundled with Emacs since the last century.) Run M-x ediff-buffers and choose the two buffers (defaulting to the current buffer and the last one you visited). There's also an “Ediff” submenu in the “Tools” menu.

After starting an Ediff session, the diff is in a buffer called *ediff-diff* (or *ediff-diff2* etc. if you have multiple active Ediff sessions). Perhaps more conveniently, or if you want a diff format that's different from the one Ediff uses, you can save the diff output to a file by typing wd (ediff-save-buffer) in the Ediff control buffer. Set ediff-custom-diff-options to control the options passed to diff when saving the diff.

I can't think of a generic way to run a command on two buffers. If both buffers are visiting files, you can use M-x diff:

  1. Visit file 1. Save if necessary.
  2. Run find-file (C-x C-f), press down or C-n (next-history-element) to have the full path to the current file, and copy the full path to the kill-ring (clipboard).
  3. Visit file 2. Save if necessary.
  4. Run M-x diff. Paste the path to file1, and accept the default for file2.
2

You are using Emacs version 24, but the online manual is for Emacs 27.

You either need to upgrade, or to read the Emacs manual that came with your copy of Emacs. Type C-h i to open the info viewer, then select Emacs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.