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 220.127.116.11, macOS 10.14.4) gives me no match for this command. What can I use instead?
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-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
- Visit file 1. Save if necessary.
C-x C-f), press
next-history-element) to have the full path to the current file, and copy the full path to the kill-ring (clipboard).
- Visit file 2. Save if necessary.
M-x diff. Paste the path to file1, and accept the default for file2.